Professional Documents
Culture Documents
PNETLAB Store
PNETLab.com
1. Lab Topology
2. Requirements
CCNA.
3. Lab Objective
1
Download PNETLab Platform
PNETLAB Store
PNETLab.com
This lab started from basic step of using Ansible platform to connect routers in topology
using SSH sessions. Step by step to create playbook that push to routers.
4. Lab tasks
Task 4: Create playbook and push to Routers that configure IP address on interfaces.
5. Lab setup
This lab use Ansible platform version 2.9.6, you can get it on devices mode in
PNETLab GUI:
You should reading guide before download and use this platforms:
2
Download PNETLab Platform
PNETLAB Store
PNETLab.com
https://user.pnetlab.com/store/devices/guide?id=4
6. Solution
Task 1
!
ip domain-name local
crypto key generate rsa
1024
!
username ansi privilege 15 password 123
line vty 0 4
login local
transport input ssh
!
interface Ethernet0/1
ip address 192.168.10.10 255.255.255.0
no shutdown
!
R2
!
ip domain-name local
crypto key generate rsa
1024
!
username ansi privilege 15 password 123
line vty 0 4
login local
transport input ssh
!
3
Download PNETLab Platform
PNETLAB Store
PNETLab.com
interface Ethernet0/2
ip address 192.168.10.20 255.255.255.0
no shutdown
!
Task 2
ssh ansi@192.168.10.10
yes
---<123>---
exit
ssh ansi@192.168.10.20
yes
---<123>---
exit
4
Download PNETLab Platform
PNETLAB Store
PNETLab.com
Task 3
[devices]
R1 ansible_host=192.168.10.10
R2 ansible_host=192.168.10.20
create group_vars and host_vars where you will add input methods for groups or
hosts files yaml:
o mkdir /etc/ansible/group_vars
o touch /etc/ansible/group_vars/devices.yml
o mkdir /etc/ansible/host_vars
o touch /etc/ansible/host_vars/R1.yml
o touch /etc/ansible/host_vars/R2.yml
Add input methods, first with devices group:
o vim /etc/ansible/group_vars/devices.yml
5
Download PNETLab Platform
PNETLAB Store
PNETLab.com
---
ansible_user: ansi
ansible_ssh_pass: 123
...
interfaces:
- name: Ethernet0/0
description: Link to R2 configured by Ansible
ipv4: 200.100.1.1/24
o vim /etc/ansible/host_vars/R2.yml
interfaces:
- name: Ethernet0/0
description: Link to R1 configured by Ansible
ipv4: 200.100.1.2/24
You can edit variables as you wish but choose types of them carefully, if not it will
be error. In this lab use ios_interfaces and ios_l3_interfaces module, so
variables need match with modules rules. More informations you can see in this
link : https://docs.ansible.com/ansible/latest/modules/list_of_network_modules.html
Task 4
---
- name: This is the first playbook -> Devices Connecting...
hosts: devices
gather_facts: false
connection: network_cli
6
Download PNETLab Platform
PNETLAB Store
PNETLab.com
tasks:
- name: Turn on interface...
ios_interfaces:
config:
- name: "{{ item.name }}"
enabled: True
state: merged
loop: "{{ interfaces }}"
Task 5
Check configuration.
On R1:
7
Download PNETLab Platform
PNETLAB Store
PNETLab.com
On R2:
That’s all for starting with Ansible, finish this lab or you can try other configs!