Ansible – Basic Playbook

LAB:  create a basic playbook just to ping 8.8.8.8

Host file contents under /etc/ansible/hosts. I have my NX-OS devices already included and configured the username for all devices (‘admin’)

Playbooks use YAML (YAML Ain’t Markup Language) which takes some getting used to. Below is the contents of my ‘playbook.yml’ file.
– ‘hosts’ maps to the ‘[LAB_NXOS]’ group within my /etc/ansible/hosts file.
– ‘connection: local’ (from what i understand) tells Ansible not to send a python script to the remote host for remote execution which NX-OS doesn’t support.
– ‘gather_facts: false’ isn’t supported by the Ansible module for NXOS. There are other modules which I will use later that can grab facts (serial number, hostname, configuration, etc)
– ‘nxos_command’ just tells Ansible to use the module specific for nxos. IOS uses ‘ios_command’.
– ‘commands’ is what you are actually running on the box

 

“playbook.yml”


Now to run the playbook.

Just to see what a failure looks like, I configured a static route on LEAF-2 for 8.8.8.8 pointing to null0 and ran it again

Ansible Playbook Documenation: http://docs.ansible.com/ansible/latest/playbooks.html
Tags:

Add a Comment

Your email address will not be published. Required fields are marked *