Skip to content

Commit a8fbfdd

Browse files
authored
Merge pull request #121 from CiscoDevNet/f-ansible-iosxe-labs-update
F ansible iosxe labs update
2 parents 5d8914d + 19bae2c commit a8fbfdd

14 files changed

Lines changed: 94 additions & 119 deletions
Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11
#simple IOS config in ansible
22
---
3-
- name: Sample IOS show version for Ansible 2.5
4-
hosts: iosxe
5-
gather_facts: no
6-
3+
- hosts: iosxe
4+
name: Sample IOS config for Ansible
5+
connection: network_cli
76
tasks:
8-
9-
- name: GATHERING FACTS
10-
ios_facts:
11-
gather_subset: hardware
12-
13-
- name: display current IOS version
14-
debug:
15-
var: ansible_net_version
16-
17-
- name: run show ip int brie
18-
ios_command:
19-
commands: show ip interface brief
20-
register: myint
21-
22-
- name: display value of "myint" variable
23-
debug:
24-
var: myint["stdout_lines"][0]
25-
26-
## Lab 1
27-
- name: run show users
28-
ios_command:
29-
commands: show users
30-
register: shuser
31-
32-
- name: display value of "shuser" variable
33-
debug:
34-
var: shuser["stdout_lines"][0]
7+
- name: Gather facts
8+
ios_facts:
9+
gather_subset: hardware
10+
11+
- name: Display current IOS version
12+
debug:
13+
var: ansible_net_version
14+
15+
- name: Run show ip int brief command
16+
ios_command:
17+
commands: show ip interface brief
18+
register: myint
19+
20+
- name: Display value of "myint" variable
21+
debug:
22+
var: myint["stdout_lines"][0]
23+
24+
## Lab 1
25+
- name: Run show users
26+
ios_command:
27+
commands: show users
28+
register: shuser
29+
30+
- name: Display value of "shuser" variable
31+
debug:
32+
var: shuser["stdout_lines"][0]
3533

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#simple IOS config in ansible
2+
---
3+
- hosts: iosxe
4+
name: Sample IOS config for Ansible
5+
connection: network_cli
6+
tasks:
7+
- name: Run show ip int brief command
8+
ios_command:
9+
commands: show ip interface brief
10+
register: myint
11+
12+
- name: Display value of "myint" variable
13+
debug:
14+
var: myint["stdout_lines"][0]

intro-ansible/ansible-02-ios-modules/02-ios_command_show_ntp.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#simple IOS config in ansible
22
---
3-
- name: Sample IOS show ntp for Ansible 2.5
4-
hosts: iosxe
5-
gather_facts: no
6-
3+
- hosts: iosxe
4+
name: Sample IOS show ntp for Ansible
5+
connection: network_cli
76
tasks:
8-
97
- name: run show ntp associations
108
ios_command:
119
commands: show ntp associations

intro-ansible/ansible-02-ios-modules/02-lab_cleanup.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#simple IOS config in ansible
22
---
3-
- name: Sample IOS NTP config for Ansible 2.5
4-
hosts: iosxe
5-
gather_facts: no
6-
3+
- hosts: iosxe
4+
name: Clean up Playbook
5+
connection: network_cli
76
tasks:
8-
97
- name: delete ntp server 10.{{item}}.{{pod_number}}.65 via CLI
108
ios_config:
119
lines:

intro-ansible/ansible-02-ios-modules/02-loopback_create.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#simple IOS config in ansible
2-
---
3-
- name: Sample IOS config for Ansible 2.5
4-
hosts: iosxe
5-
gather_facts: no
62

3+
---
4+
- hosts: iosxe
5+
name: Sample IOS Interface config for Ansible
6+
connection: network_cli
77
tasks:
88

99
- name: Create loopback {{pod_number}}
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
#simple IOS config in ansible
22
---
3-
- name: Sample IOS NTP config for Ansible 2.5
4-
hosts: iosxe
5-
gather_facts: no
6-
3+
- hosts: iosxe
4+
name: Sample IOS NTP config for Ansible
5+
connection: network_cli
76
tasks:
8-
97
- name: set ntp server 10.{{item}}.{{pod_number}}.65 via CLI
108
ios_config:
119
lines:
1210
- ntp server 10.{{item}}.{{pod_number}}.65
1311
with_items: "{{loops}}"
14-
15-

intro-ansible/ansible-02-ios-modules/02-ntp_delete.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#simple IOS config in ansible
22
---
3-
- name: Sample IOS NTP config for Ansible 2.5
3+
- name: Sample IOS NTP config for Ansible
44
hosts: iosxe
55
gather_facts: no
66

intro-ansible/ansible-03-netconf-config/03-lab_cleanup.yaml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
- name: NETCONF delete NTP server
3-
hosts: iosxe
4-
connection: local
2+
- hosts: iosxe
3+
name: Clean up Lab
4+
connection: network_cli
55
gather_facts: False
66

77
tasks:
@@ -11,12 +11,7 @@
1111

1212
- name: Remove NTP server 10.111.{{pod_number}}.66 with NETCONF
1313
netconf_config:
14-
host: "{{inventory_hostname}}"
15-
port: "{{netconf_port}}"
16-
username: "{{ansible_user}}"
17-
password: "{{ansible_password}}"
18-
hostkey_verify: False
19-
xml: |
14+
content: |
2015
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
2116
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
2217
<ntp>
@@ -34,12 +29,7 @@
3429

3530
- name: Delete a loopback with NETCONF
3631
netconf_config:
37-
host: "{{inventory_hostname}}"
38-
port: "{{netconf_port}}"
39-
username: "{{ansible_user}}"
40-
password: "{{ansible_password}}"
41-
hostkey_verify: False
42-
xml: |
32+
content: |
4333
<config>
4434
<interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
4535
<interface operation="delete">

intro-ansible/ansible-03-netconf-config/03-loopback_create.yaml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
---
2-
- name: NETCONF sample 1
3-
hosts: iosxe
4-
connection: local
2+
- hosts: iosxe
3+
name: Sample IOS Interface config for Ansible
4+
connection: network_cli
55
gather_facts: False
6-
76
tasks:
8-
97
- set_fact:
10-
ansible_connection: local
11-
8+
ansible_connection: netconf
129
- name: Create a loopback Loopback1{{pod_number}} with NETCONF
1310
netconf_config:
14-
host: "{{inventory_hostname}}"
15-
port: "{{netconf_port}}"
16-
username: "{{ansible_user}}"
17-
password: "{{ansible_password}}"
18-
hostkey_verify: False
19-
xml: |
20-
<config>
11+
content: |
12+
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
2113
<interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
2214
<interface>
2315
<name>Loopback1{{pod_number}}</name>
Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
---
2-
- name: NETCONF create NTP server
3-
hosts: iosxe
4-
connection: local
2+
- hosts: iosxe
3+
name: Sample IOS NTP config for Ansible
4+
connection: network_cli
55
gather_facts: False
6-
76
tasks:
8-
97
- set_fact:
10-
ansible_connection: local
11-
8+
ansible_connection: netconf
129
- name: Define NTP server 10.111.{{pod_number}}.66 with NETCONF
13-
netconf_config:
14-
host: "{{inventory_hostname}}"
15-
port: "{{netconf_port}}"
16-
username: "{{ansible_user}}"
17-
password: "{{ansible_password}}"
18-
hostkey_verify: False
19-
xml: |
20-
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
21-
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
10+
ansible.netcommon.netconf_config:
11+
content: |
12+
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
13+
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
2214
<ntp>
2315
<server xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-ntp">
2416
<server-list>
@@ -27,4 +19,4 @@
2719
</server>
2820
</ntp>
2921
</native>
30-
</config>
22+
</config>

0 commit comments

Comments
 (0)