[Ansible Galaxy] Ansible host inventory

Host Inventory

Ansible works against multiple managed nodes or “hosts” in your infrastructure at the same time, using a list or group of lists known as inventory. Once your inventory is defined, you use patterns to select the hosts or groups you want Ansible to run against.

FAQs

to use the ‘ssh’ connection type with passwords, you must install the sshpass program

1
2
TASK [Gathering Facts] ***************************************************************************************************************
fatal: [192.168.80.7]: FAILED! => {"msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"}

You have to install sshpass package in your ansible control machine.

Ansible: To use the ‘ssh’ connection type with passwords, you must install the sshpass program - bidhankhatri.com.np - https://bidhankhatri.com.np/automation/ansible-ssh-connection-type-with-passwords-error/ to learn more.

Or Use Paramiko

Paramiko is a pure-Python (2.7, 3.4+) implementation of the SSHv2 protocol, providing both client and server functionality. It provides the foundation for the high-level SSH library Fabric, which is what we recommend you use for common client use-cases such as running remote shell commands or transferring files.

First, install Paramiko by pip.

1
$ pip install paramiko

Use -c paramiko options.

1
2
$ ansible-playbook -i hosts -c paramiko --ask-pass myplaybook.yml
SSH password:

See Ansible: To use the ‘ssh’ connection type with passwords, you must install the sshpass program" - Stack Overflow - https://stackoverflow.com/questions/42835626/ansible-to-use-the-ssh-connection-type-with-passwords-you-must-install-the-s to learn more.

References

[1] How to build your inventory — Ansible Documentation - https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html