In the previous chapter, a general overview of Ansible terminology was provided. This covered many of the specific Ansible terms, such as playbooks, plays, tasks, modules, and inventory files. This section will continue to provide working examples of using Ansible for network automation, but will provide more detail on working with modules to automate a few different types of devices. Examples will include automating devices from multiple vendors, including Cisco, Arista, Cumulus, and Juniper.
The examples in this section assume the following:
Ansible is installed.
The proper APIs are enabled on the devices (NX-API, eAPI, NETCONF).
Users exist with the proper permissions on the system to make changes via the API.
All Ansible modules exist on the system and are in the library path.
Setting the module and library path can be done within the ansible.cfg file. You can also use the
-M flag from the command line to change it when executing a playbook.
The inventory used for the examples in this section is shown in the following section (with passwords removed and IP addresses changed). In this example, some hostnames are not FQDNs as they were in the previous examples.
[cumulus] cvx ansible_ssh_host=220.127.116.11 ansible_ssh_pass=PASSWORD [arista] veos1 [cisco] nx1 hostip=18.104.22.168 un=USERNAME pwd=PASSWORD [juniper] vsrx hostip=22.214.171.124 un=USERNAME pwd=PASSWORD
Just in case you’re wondering ...