Skip to content

Commit

Permalink
Day 3 Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
brooks043 committed Jan 30, 2019
1 parent 51db4ae commit ddb11b7
Show file tree
Hide file tree
Showing 13 changed files with 609 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ansible.cfg
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/
27 changes: 27 additions & 0 deletions inv/dev/nethosts
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
27 changes: 27 additions & 0 deletions inv/prod/nethosts
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
3 changes: 3 additions & 0 deletions precheck/ansible.cfg
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/
20 changes: 20 additions & 0 deletions precheck/ansible01.yml
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
28 changes: 28 additions & 0 deletions precheck/ansible02.yml
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
29 changes: 29 additions & 0 deletions precheck/ansible03.yml
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 }}"
28 changes: 28 additions & 0 deletions precheck/ansible04.yml
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
33 changes: 33 additions & 0 deletions precheck/ansible05.yml
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"
2 changes: 2 additions & 0 deletions precheck/ansible06.retry
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sw1
sw2
37 changes: 37 additions & 0 deletions precheck/ansible06.yml
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"
Loading

0 comments on commit ddb11b7

Please sign in to comment.