Search code examples
sshansibleansible-ad-hoc

How to pass a user / password in ansible command


I want to use Ansible as part of another Python software. in that software I have a hosts list with their user / password.

Is there a way to pass the user / pass of the SSH connection to the Ansible ad-hoc command or write it in any file in encrypted way?

Or do i understand it all wrong, and the only way to do it is with SSH certification?


Solution

  • The docs say you can specify the password via the command line:

    -k, --ask-pass.
    ask for connection password

    Ansible can also store the password in the ansible_password variable on a per-host basis.