File tree Expand file tree Collapse file tree
ansible-03-netconf-config Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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]
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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 :
Original file line number Diff line number Diff line change 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}}
Original file line number Diff line number Diff line change 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-
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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 :
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>
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">
Original file line number Diff line number Diff line change 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>
Original file line number Diff line number Diff line change 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>
2719 </server>
2820 </ntp>
2921 </native>
30- </config>
22+ </config>
You can’t perform that action at this time.
0 commit comments