Skip to content
Snippets Groups Projects
Commit 12b2a0aa authored by Dónal Cunningham's avatar Dónal Cunningham
Browse files

Changed to use veos_hosts and junos_hosts in example scripts

parent cade7202
Branches
Tags
No related merge requests found
...@@ -13,3 +13,8 @@ Run ``ansible-playbook -i hosts show_all_responses.yaml`` ...@@ -13,3 +13,8 @@ Run ``ansible-playbook -i hosts show_all_responses.yaml``
# Multiple lines of commands # Multiple lines of commands
Run ``ansible-playbook -i hosts show_version_and_uptime.yaml`` Run ``ansible-playbook -i hosts show_version_and_uptime.yaml``
# Device specific
There are device-specific `show version` playbooks. JunOS in particular paginates its output - so you have to run the command through `no-more` to stop it printing `--More--` and pausing for keyboard input which will never come.
[all:vars] [all:vars]
ansible_connection=ssh ansible_connection=ssh
ansible_user=zork ansible_user=zork
ansible_host=localhost
[veos_hosts] [veos_hosts]
veos ansible_host=localhost ansible_port=9022 ansible_ssh_pass=swordfish veos ansible_port=9022 ansible_ssh_pass=swordfish
#
# Why different passwords? JunOS is a lot stricter. Good!
#
[junos_hosts] [junos_hosts]
vSRX ansible_host=localhost ansible_port=9023 ansible_ssh_pass=Swordfish123 vSRX ansible_port=9023 ansible_ssh_pass=Swordfish123
--- ---
- name: Play 1 - Show the software version on an Arista switch - name: Play 1 - Show the software version on an Arista switch
hosts: veos hosts: veos_hosts
gather_facts: "no" gather_facts: "no"
connection: local connection: local
tasks: tasks:
- name: Task 1.1 - Gather version from switches - name: Task 1.1 - Gather version from switch using the raw module
raw: 'show version | include Software' raw: 'show version | include Software'
register: showvers register: showvers
- name: Task 1.2 - Print output - name: Task 1.2 - Print version
debug: var=showvers debug: var=showvers
--- ---
- name: Play 1 - Show the software version on an Arista switch - name: Play 1 - Show the software version on an Arista switch
hosts: veos hosts: veos_hosts
gather_facts: "no" gather_facts: "no"
connection: local connection: local
tasks: tasks:
- name: Task 1.1 - Gather version from switches - name: Task 1.1 - Gather version from switches using the raw module
raw: 'show version | include Software' raw: 'show version | include Software'
register: showvers register: showvers
- name: Task 1.2 - Print output - name: Task 1.2 - Print output
debug: var=showvers.stdout_lines[0] debug: var=showvers.stdout_lines[0]
- name: Play 2 - Verify switch software - name: Play 2 - Show the software version on a Juniper router
hosts: veos hosts: junos_hosts
vars:
eos_version: "4.25"
gather_facts: "no" gather_facts: "no"
connection: local connection: local
tasks: tasks:
- name: Task 2.1 - Assert we are running the correct EOS version ({{eos_version}}) - name: Task 2.1 - Gather version from switches using the raw module
assert: raw: 'show version | no-more| match Junos '
that: register: showvers
- "'{{eos_version}}' in showvers.stdout_lines[0]"
msg: "Oh noes! Switch not running eOS {{eos_version}}!" - name: Task 1.2 - Print output
debug: var=showvers.stdout_lines[0]
---
- name: Play 1 - Show the software version on all devices
hosts: all
gather_facts: "no"
connection: local
tasks:
- name: Task 1.1 - Gather version from switches
raw: 'show version'
register: showvers
- name: Task 1.2 - Print output
debug: var=showvers.stdout_lines
--- ---
- name: Play 1 - Show the software version on an Arista switch - name: Play 1 - Show output of multiple commands on an Arista switch
hosts: veos hosts: veos_hosts
gather_facts: no gather_facts: no
vars: vars:
ansible_connection: network_cli ansible_connection: network_cli
ansible_network_os: eos ansible_network_os: eos
tasks: tasks:
- name: Task 1.1 - Gather version from switches - name: Task 1.1 - Gather version and uptime from the switch using eos_command
eos_command: eos_command:
commands: commands:
- 'show version | include Software' - 'show version | include Software'
......
PLAY [Play 1 - Show the software version on a vSRX] ****************************
TASK [Task 1.1 - Gather version from switches] *********************************
changed: [vSRX]
TASK [Task 1.2 - Print output] *************************************************
ok: [vSRX] => {
"showvers.stdout_lines[0]": "Junos: 21.3R1.9"
}
PLAY RECAP *********************************************************************
vSRX : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
---
- name: Play 1 - Show the software version on an Arista switch
hosts: veos_hosts
gather_facts: "no"
connection: local
tasks:
- name: Task 1.1 - Gather version from switches
raw: 'show version | include Software'
register: showvers
- name: Task 1.2 - Print output
debug: var=showvers.stdout_lines[0]
- name: Play 2 - Verify switch software
hosts: veos
vars:
eos_version: "4.25"
gather_facts: "no"
connection: local
tasks:
- name: Task 2.1 - Assert we are running the correct EOS version ({{eos_version}})
assert:
that:
- "'{{eos_version}}' in showvers.stdout_lines[0]"
msg: "Oh noes! Switch not running eOS {{eos_version}}!"
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
connection: local connection: local
tasks: tasks:
- name: Task 1.1 - Gather version from switches - name: Task 1.1 - Gather version from switches
raw: 'show version | no-more' raw: 'show version | no-more | match Junos: '
register: showvers register: showvers
- name: Task 1.2 - Print output - name: Task 1.2 - Print output
debug: var=showvers.stdout_lines debug: var=showvers.stdout_lines[0]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment