-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
609 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[defaults] | ||
host_key_checking = False | ||
inventory = /home/student/mycode/inv/dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[aristaswitches] | ||
; description of our arista inventory | ||
sw1 ansible_host=172.16.2.10 | ||
sw2 ansible_host=172.16.2.20 | ||
|
||
[ciscoswitches] | ||
; description of our cisco inventory | ||
cisco1 ansible_host=192.168.0.1 | ||
cisco2 ansible_host=192.168.0.2 | ||
|
||
[aristaswitches:vars] | ||
; variables specific to arista switches | ||
ansible_network_os=eos | ||
ansible_connection=network_cli | ||
ansible_become=yes | ||
ansible_become_method=enable | ||
ansible_user=admin | ||
ansible_ssh_pass=alta3 | ||
|
||
[ciscoswitches:vars] | ||
; variables specific to cisco switches | ||
ansible_network_os=ios | ||
ansible_connection=network_cli | ||
ansible_become=yes | ||
ansible_become_method=enable | ||
ansible_user=admin | ||
ansible_ssh_pass=ciscoskeerit123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[aristaswitches] | ||
; description of our arista inventory | ||
sw1 ansible_host=172.16.2.10 | ||
sw2 ansible_host=172.16.2.20 | ||
|
||
[ciscoswitches] | ||
; description of our cisco inventory | ||
cisco1 ansible_host=192.168.0.1 | ||
cisco2 ansible_host=192.168.0.2 | ||
|
||
[aristaswitches:vars] | ||
; variables specific to arista switches | ||
ansible_network_os=eos | ||
ansible_connection=network_cli | ||
ansible_become=yes | ||
ansible_become_method=enable | ||
ansible_user=admin | ||
ansible_ssh_pass=alta3 | ||
|
||
[ciscoswitches:vars] | ||
; variables specific to cisco switches | ||
ansible_network_os=ios | ||
ansible_connection=network_cli | ||
ansible_become=yes | ||
ansible_become_method=enable | ||
ansible_user=admin | ||
ansible_ssh_pass=ciscoskeerit123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[defaults] | ||
host_key_checking = False | ||
inventory = /home/student/mycode/inv/dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
- name: Another network playbook example | ||
# The line below uses regex to parse the inventory file | ||
hosts: ~^arista | ||
# gather_facts ALWAYS runs setup.py (server module) | ||
gather_facts: no # v2.5=< no is default if network_cli is selected for connection | ||
# if turned to yes you'll collect info about the local host :( | ||
|
||
tasks: | ||
# if we run this and have gather_facts set to no, then ansible_facts will be about our network devs | ||
- name: Harvest Arista facts | ||
eos_facts: | ||
when: ansible_network_os == 'eos' | ||
|
||
- name: Push to the local system | ||
copy: | ||
# use the to_no_json filter to display pretty json output | ||
content: "{{ ansible_facts | to_nice_json }}" | ||
dest: "/home/student/mycode/{{ inventory_hostname }}.txt" | ||
# the inventory_hostname variable always resolves to the current host being iterated against |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
- name: Another network playbook example | ||
# The line below uses regex to parse the inventory file | ||
hosts: ~^arista | ||
# gather_facts ALWAYS runs setup.py (server module) | ||
gather_facts: no # v2.5=< no is default if network_cli is selected for connection | ||
# if turned to yes you'll collect info about the local host :( | ||
|
||
tasks: | ||
# if we run this and have gather_facts set to no, then ansible_facts will be about our network devs | ||
- name: Harvest Arista facts | ||
eos_facts: | ||
when: ansible_network_os == 'eos' | ||
|
||
- name: Push to the local system -- by special tag request only | ||
copy: | ||
# use the to_no_json filter to display pretty json output | ||
content: "{{ ansible_facts | to_nice_json }}" | ||
dest: "/home/student/mycode/{{ inventory_hostname }}.txt" | ||
# the inventory_hostname variable always resolves to the current host being iterated against | ||
tags: | ||
- never | ||
- grabfacts | ||
|
||
# dig into the data we want to reveal | ||
- name: Getting at network interfaces | ||
debug: | ||
var: ansible_facts.net_interfaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
- name: Another network playbook example | ||
# The line below uses regex to parse the inventory file | ||
hosts: ~^arista | ||
# gather_facts ALWAYS runs setup.py (server module) | ||
gather_facts: no # v2.5=< no is default if network_cli is selected for connection | ||
# if turned to yes you'll collect info about the local host :( | ||
|
||
tasks: | ||
# if we run this and have gather_facts set to no, then ansible_facts will be about our network devs | ||
- name: Harvest Arista facts | ||
eos_facts: | ||
when: ansible_network_os == 'eos' | ||
|
||
- name: Push to the local system -- by special tag request only | ||
copy: | ||
# use the to_no_json filter to display pretty json output | ||
content: "{{ ansible_facts | to_nice_json }}" | ||
dest: "/home/student/mycode/{{ inventory_hostname }}.txt" | ||
# the inventory_hostname variable always resolves to the current host being iterated against | ||
tags: | ||
- never | ||
- grabfacts | ||
|
||
# dig into the data we want to reveal | ||
- name: Getting at network interfaces | ||
debug: | ||
# filters require that we start using mustache brackets surrounded in quotes | ||
var: "{{ ansible_facts.net_interfaces | length }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
- name: Another network playbook example | ||
# The line below uses regex to parse the inventory file | ||
hosts: ~^arista | ||
# gather_facts ALWAYS runs setup.py (server module) | ||
gather_facts: no # v2.5=< no is default if network_cli is selected for connection | ||
# if turned to yes you'll collect info about the local host :( | ||
|
||
tasks: | ||
# if we run this and have gather_facts set to no, then ansible_facts will be about our network devs | ||
- name: Harvest Arista facts | ||
eos_facts: | ||
when: ansible_network_os == 'eos' | ||
|
||
- name: Push to the local system -- by special tag request only | ||
copy: | ||
# use the to_no_json filter to display pretty json output | ||
content: "{{ ansible_facts | to_nice_json }}" | ||
dest: "/home/student/mycode/{{ inventory_hostname }}.txt" | ||
# the inventory_hostname variable always resolves to the current host being iterated against | ||
tags: | ||
- never | ||
- grabfacts | ||
|
||
# Precheck conditional number of interfaces | ||
- fail: | ||
msg: "FAIL. Network device lacks the correct number of interfaces." | ||
when: ansible_facts.net_interfaces|length != 13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
- name: Another network playbook example | ||
# The line below uses regex to parse the inventory file | ||
hosts: ~^arista | ||
# gather_facts ALWAYS runs setup.py (server module) | ||
gather_facts: no # v2.5=< no is default if network_cli is selected for connection | ||
# if turned to yes you'll collect info about the local host :( | ||
|
||
tasks: | ||
# if we run this and have gather_facts set to no, then ansible_facts will be about our network devs | ||
- name: Harvest Arista facts | ||
eos_facts: | ||
when: ansible_network_os == 'eos' | ||
|
||
- name: Push to the local system -- by special tag request only | ||
copy: | ||
# use the to_no_json filter to display pretty json output | ||
content: "{{ ansible_facts | to_nice_json }}" | ||
dest: "/home/student/mycode/{{ inventory_hostname }}.txt" | ||
# the inventory_hostname variable always resolves to the current host being iterated against | ||
tags: | ||
- never | ||
- grabfacts | ||
|
||
# Precheck conditional number of interfaces | ||
- fail: | ||
msg: "FAIL. Network device lacks the correct number of interfaces." | ||
when: ansible_facts.net_interfaces|length != 13 | ||
|
||
# Firmware precheck on correct major and minor versions | ||
- fail: | ||
msg: "FAIL. Network device is running wrong firmware." | ||
when: "'4.17' not in ansible_facts.net_version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
sw1 | ||
sw2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
- name: Another network playbook example | ||
# The line below uses regex to parse the inventory file | ||
hosts: ~^arista | ||
# gather_facts ALWAYS runs setup.py (server module) | ||
gather_facts: no # v2.5=< no is default if network_cli is selected for connection | ||
# if turned to yes you'll collect info about the local host :( | ||
|
||
vars: | ||
switchint: 13 | ||
switchver: "4.17" | ||
|
||
tasks: | ||
# if we run this and have gather_facts set to no, then ansible_facts will be about our network devs | ||
- name: Harvest Arista facts | ||
eos_facts: | ||
when: ansible_network_os == 'eos' | ||
|
||
- name: Push to the local system -- by special tag request only | ||
copy: | ||
# use the to_no_json filter to display pretty json output | ||
content: "{{ ansible_facts | to_nice_json }}" | ||
dest: "/home/student/mycode/{{ inventory_hostname }}.txt" | ||
# the inventory_hostname variable always resolves to the current host being iterated against | ||
tags: | ||
- never | ||
- grabfacts | ||
|
||
# Precheck conditional number of interfaces | ||
- fail: | ||
msg: "FAIL. Network device lacks the correct number of interfaces." | ||
when: ansible_facts.net_interfaces|length != switchint | ||
|
||
# Firmware precheck on correct major and minor versions | ||
- fail: | ||
msg: "FAIL. Network device is running wrong firmware." | ||
when: "switchver not in ansible_facts.net_version" |
Oops, something went wrong.