diff --git a/Section1/show_version/README.md b/Section1/show_version/README.md index 81b2bd2c0e25c88e5fbd0b7dfd8b2a85a89788f9..4c955844e443a3f60905a983a39ea617418cf2d9 100644 --- a/Section1/show_version/README.md +++ b/Section1/show_version/README.md @@ -13,3 +13,8 @@ Run ``ansible-playbook -i hosts show_all_responses.yaml`` # Multiple lines of commands 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. + diff --git a/Section1/show_version/hosts b/Section1/show_version/hosts index 9c3f3e0e1e6a6816abf27ab9d842b93730441f31..a0aad7375d23a339f4e533fcd6b3d8ffaa15777d 100644 --- a/Section1/show_version/hosts +++ b/Section1/show_version/hosts @@ -1,9 +1,13 @@ [all:vars] ansible_connection=ssh ansible_user=zork +ansible_host=localhost [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] -vSRX ansible_host=localhost ansible_port=9023 ansible_ssh_pass=Swordfish123 +vSRX ansible_port=9023 ansible_ssh_pass=Swordfish123 diff --git a/Section1/show_version/show_all_responses.yaml b/Section1/show_version/show_all_responses.yaml index 464ec2623409ce937938ab7c3c17ba80bacf7c40..4f38ce3070726efca2ab520f08eb8ccb55d30dc0 100644 --- a/Section1/show_version/show_all_responses.yaml +++ b/Section1/show_version/show_all_responses.yaml @@ -1,12 +1,12 @@ --- - name: Play 1 - Show the software version on an Arista switch - hosts: veos + hosts: veos_hosts gather_facts: "no" connection: local 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' register: showvers - - name: Task 1.2 - Print output + - name: Task 1.2 - Print version debug: var=showvers diff --git a/Section1/show_version/show_version.yaml b/Section1/show_version/show_version.yaml index db4625462a91c736b614bf07fabf7d2f02d1be86..8bfe25c96dd7091878dba32ca01614ee07970bf3 100644 --- a/Section1/show_version/show_version.yaml +++ b/Section1/show_version/show_version.yaml @@ -1,26 +1,25 @@ --- - name: Play 1 - Show the software version on an Arista switch - hosts: veos + hosts: veos_hosts gather_facts: "no" connection: local 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' 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" +- name: Play 2 - Show the software version on a Juniper router + hosts: junos_hosts 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}}!" + - name: Task 2.1 - Gather version from switches using the raw module + raw: 'show version | no-more| match Junos ' + register: showvers + + - name: Task 1.2 - Print output + debug: var=showvers.stdout_lines[0] + diff --git a/Section1/show_version/show_version_all.yaml b/Section1/show_version/show_version_all.yaml deleted file mode 100644 index a78bb337139749545d52ae4f2a8f66043d2d93d9..0000000000000000000000000000000000000000 --- a/Section1/show_version/show_version_all.yaml +++ /dev/null @@ -1,12 +0,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 diff --git a/Section1/show_version/show_version_and_uptime.yaml b/Section1/show_version/show_version_and_uptime.yaml index 732b86ef61a8575f006b912431cf6cb705b48446..f31747596924001abb1f1825e09a93a50d0a139f 100644 --- a/Section1/show_version/show_version_and_uptime.yaml +++ b/Section1/show_version/show_version_and_uptime.yaml @@ -1,12 +1,12 @@ --- -- name: Play 1 - Show the software version on an Arista switch - hosts: veos +- name: Play 1 - Show output of multiple commands on an Arista switch + hosts: veos_hosts gather_facts: no vars: ansible_connection: network_cli ansible_network_os: eos 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: commands: - 'show version | include Software' diff --git a/Section1/show_version/show_version_arista.output b/Section1/show_version/show_version_arista.output new file mode 100644 index 0000000000000000000000000000000000000000..06e13f2b9e88f3c9f879e55ecaf6f0ca1f4490f0 --- /dev/null +++ b/Section1/show_version/show_version_arista.output @@ -0,0 +1,14 @@ + +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 + diff --git a/Section1/show_version/show_version_arista.yaml b/Section1/show_version/show_version_arista.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b7495863238e7c5814eb30d1cd60751b38fa51ea --- /dev/null +++ b/Section1/show_version/show_version_arista.yaml @@ -0,0 +1,26 @@ +--- +- 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}}!" diff --git a/Section1/show_version/show_version_juniper.yaml b/Section1/show_version/show_version_juniper.yaml index 4bded5d8d4234f52f3aa03c528b4b116063be2c9..cd91f7102b14390250cb4794018aecbefaae2bf2 100644 --- a/Section1/show_version/show_version_juniper.yaml +++ b/Section1/show_version/show_version_juniper.yaml @@ -5,8 +5,8 @@ connection: local tasks: - name: Task 1.1 - Gather version from switches - raw: 'show version | no-more' + raw: 'show version | no-more | match Junos: ' register: showvers - name: Task 1.2 - Print output - debug: var=showvers.stdout_lines + debug: var=showvers.stdout_lines[0]