TODO: test with multiple hosts
Prompts for the ansible_password
if not defined, with the option to also set the ansible_become_password
if not defined.
This avoids the need to call ansible-playbook
with --ask-pass
and --ask-become-pass
.
This works when ansible_become_method
is set to sudo
or, for Windows, ansible.builtin.runas
.
This repo uses the FQCN convention.
Include the collection in the Ansible Galaxy requirements.yml
:
---
collections:
- name: huyz.general
You can then include the role huyz.general.prompt_password
.
- name: Prompt for ansible_password if needed
ansible.builtin.include_role:
name: huyz.general.prompt_password
vars:
copy_to_become_password: true