Solving host connection issues
Ansible is often used to manage remote hosts or systems. To do this, Ansible will need to be able to connect to the remote host, and only after that will it be able to issue commands. Sometimes, the problem is that Ansible is unable to connect to the remote host. A typical example of this is when you try to manage a machine that hasn’t booted yet. Being able to quickly recognize these kinds of problems and fix them promptly will help you save a lot of time.
Follow these steps to get started:
- Let’s create a playbook called
remote.yaml
with the following content:--- - hosts: all tasks: - name: Touch a file ansible.builtin.file: path: /tmp/myfile state: touch
- We can try to run the
remote.yaml
playbook against a non-existent FQDN, as follows:$ ansible-playbook -i host.example.com, remote.yaml
In this case...