OrhanErgun - AnsibleFundamentals
OrhanErgun - AnsibleFundamentals
Fundamentals
for Network Engineers
www.orhanergun.net
- Certs & Skills
www.orhanergun.net
- Ansible Fundamentals Topics
1 Ansible Understanding
• 1.a What is Ansible
• 1.b Why Ansible
• 1.c Ansible Use Cases
2 LAB Setup
• 2.a LAB
• 2.a i LAB Overview
• 2.a ii LAB Setup (Install VMs, Prerequisites and Ansible)
• 2.b Ansible Engine
• 2.b i Host Inventory
• 2.b ii ansible config
3 Starting Automation
• 3.a First PlayBook
www.orhanergun.net
- Prerequisites
• Network (ex. CCNA, CCNP)
• Python beginner
• Linux Administration
www.orhanergun.net
- What is Ansible
• Started as open-source project, now owned by RedHat.
www.orhanergun.net
- Why Ansible
• Uses YAML format
• Light weight
www.orhanergun.net
- Ansible Use Cases
www.orhanergun.net
- Ansible Use Cases (cont.)
www.orhanergun.net
- Ansible LAB Overview-Setup
Ø PC Specs
• 8 Core
• 16 GB RAM
• 60 GB Storage
Ø Software
• Hypervisor such as VMware Workstation
• Microsoft VS code
Ø VMs
• EVE-NG
• Linux OS such as RHEL
www.orhanergun.net
- Ansible Engine
Ø Inventory
• Store information for target managed nodes
• Contains IP, FQDN, vars, etc…..
• Most common format are INI & YAML
Ø Playbook
• May have single or multiple plays
• Each play defines (target & at least one task)
• Written in YAML supposed to be
human-friendly to read.
www.orhanergun.net
- Inventory INI example
[all:vars]
ansible_connection=network_cli
ansible_user=cisco
[datacenter:children] [routers:vars]
routers ansible_become=yes
switches ansible_become_method=enable
ansible_network_os=cisco.ios.ios
[routers] ansible_user=my_ios_user
172.17.10.1 ansible_password=my_ios_password
172.17.10.2
[switches]
172.17.10.3
172.17.10.4
www.orhanergun.net
- Inventory YAML example
routers: swithces:
hosts: hosts:
R01: SW01:
ansible_host: 172.17.10.1 ansible_host: 172.17.10.3
R02: SW02:
ansible_host: 172.17.10.2 ansible_host: 172.17.10.4
vars: datacenter:
ansible_network_os: cisco.ios.ios children:
ansible_user: my_cisco_user routers:
switches:
www.orhanergun.net
- Playbook example
Ø Play
• List of tasks
• Run linearly by default
Ø Task
• Action
• Could be run with playbook
or ad hoc command
Ø Module
• Code that Ansible execute
• Ex. VLAN interfaces in network device
www.orhanergun.net