Ansible ping

Some sanity checks for Ansible. Start with a basic host file.

all:
  servers:
    all:
      hosts:
        my_server:
          ansible_host: 192.168.0.1
        your_server:
          ansible_host: 192.168.1.2
          ansible_ssh_user: your_username
      vars:
        ansible_connection: ssh
        ansible_ssh_user: my_user
        ansible_ssh_private_key_file: /home/my_user/.ssh/id_ed25519_pi

Check that your server is up and reported correctly in your `/etc/ansible/hosts` file by having ansible ping it.

ansible -m ping my_server

If everything is configured correctly then you should get back

mu_server | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}

This should allow you to determine if at least there is a command and control connection available.

Work on your playbook and verify that it is valid yaml.

yamllint /home/ken/sourcecode/personal/ansible/my_example.yaml

Then verify that the playbook is sane

ansible-playbook --syntax-check /home/my_user/ansible/my_example.yaml

After that you should be able to run the playbook using.

ansible-playbook /home/my_user/ansible/my_example.yaml
This entry was posted in General. Bookmark the permalink.

Leave a Reply

Your email address will not be published.