ansible returns with “Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6))

It appears that you don’t have the docker module installed. You will need to install it via your system package manager (apt install python-docker, for example), or using pip (pip install docker). If you have multiple Python versions, make sure that you’ve installed the docker module into the version that Ansible is using.

Run Ansible playbook without inventory

Prerequisites. You need to have ssh server running on the host (ssh localhost should let you in). Then if you want to use password authentication (do note the trailing comma): $ ansible-playbook playbook.yml -i localhost, -k In this case you also need sshpass. In case of public key authentication: $ ansible-playbook playbook.yml -i localhost, And … Read more

How Exactly Does Ansible Parse Boolean Variables?

Variables defined in YAML files (playbooks, vars_files, YAML-format inventories) YAML principles Playbooks, vars_files, and inventory files written in YAML are processed by a YAML parser first. It allows several aliases for values which will be stored as Boolean type: yes/no, true/false, on/off, defined in several cases: true/True/TRUE (thus they are not truly case-insensitive). YAML definition … Read more

Accessing inventory host variable in Ansible playbook

You are on the right track about hostvars. This magic variable is used to access information about other hosts. hostvars is a hash with inventory hostnames as keys. To access fields of each host, use hostvars[‘test-1’], hostvars[‘test2-1’], etc. ansible_ssh_host is deprecated in favor of ansible_host since 2.0. So you should first remove “_ssh” from inventory … Read more

Ansible provisioning ERROR! Using a SSH password instead of a key is not possible

Create a file ansible/ansible.cfg in your project directory (i.e. ansible.cfg in the provisioning_path on the target) with the following contents: [defaults] host_key_checking = false provided that your Vagrant box has sshpass already installed – it’s unclear, because the error message in your question suggests it was installed (otherwise it would be “ERROR! to use the … Read more

Where to store Ansible host file on Mac OS X

While Ansible will try /etc/ansible/hosts by default, there are several ways to tell ansible where to look for an alternate inventory file : use the -i command line switch and pass your inventory file path add inventory = path_to_hostfile in the [defaults] section of your ~/.ansible.cfg configuration file use export ANSIBLE_HOSTS=path_to_hostfile as suggested by DomaNitro … Read more