Im currently working on ansible to automate few server infrastructure activities, i would like to specify --ask-pass and—ask-become-pass for Ansible in non-interactive way.
My Scenario:
when i run the below command, I'm getting the expected output after manually providing the SSH and BECOME password.
ansible-playbook ping.yml --ask-pass --ask-become-pass -i hosts -c paramiko
when i tried executing the below command by placing the ansible_ssh_pass and ansible_become_pass details in inventory file, it works fine in non interactive way.
ansible-playbook ping.yml -i hosts -c paramiko
$ ansible-playbook ping.yml -i hosts -c paramiko
PLAY [all] *******************************************************************************************
TASK [Gathering Facts] *******************************************************************************************
ok: [*************.com]
TASK [ping] *******************************************************************************************
ok: [*************.com]
PLAY RECAP *******************************************************************************************
**************.com : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
but in the above method the credentials are exposed and I feel it is not a best practice. Is there any possible way to handle both the ansible_ssh_pass and ansible_become_pass in non interactive way other than having the credential details in inventory file?
Ansible version : 2.9.9
OS : Linux