March 2016
Intermediate to advanced
30 pages
56m
English
This chapter walks through many of the terms and key concepts that have been gradually introduced already in this report. These are terms such as inventory file, playbook, play, tasks, and modules. We also review a few other concepts that are helpful to be aware of when getting started with Ansible for network automation.
Please reference the following sample inventory file and playbook throughout this section, as they are continuously used in the examples that follow to convey what each Ansible term means.
Sample inventory:
# sample inventory file # filename inventory [all:vars] user=admin pwd=admin [tor] rack1-tor1 vendor=nxos rack1-tor2 vendor=nxos rack2-tor1 vendor=arista rack2-tor2 vendor=arista [core] core1 core2
Sample playbook:
---# sample playbook# filename site.yml-name:PLAY 1 - Top of Rack (TOR) Switcheshosts:torconnection:localtasks:-name:ENSURE VLAN 10 EXISTS ON CISCO TOR SWITCHESnxos_vlan:vlan_id=10name=WEB_VLANhost={{ inventory_hostname }}username=adminpassword=adminwhen:vendor == "nxos"-name:ENSURE VLAN 10 EXISTS ON ARISTA TOR SWITCHESeos_vlan:vlanid=10name=WEB_VLANhost={{ inventory_hostname }}username={{ user }}password={{ pwd }}when:vendor == "arista"-name:PLAY 2 - Core (TOR) Switcheshosts:coreconnection:localtasks:-name:ENSURE VLANS EXIST IN COREnxos_vlan:vlan_id={{ item }}host={{ inventory_hostname }}username={{ user }}password={{ pwd }}with_items:-10-20 ...
Read now
Unlock full access