Commit be3ea1ca authored by Dónal Cunningham's avatar Dónal Cunningham
Browse files

DC - reorganised the show version playbooks

parent 6d1d0033
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
This repo holds sample Ansible playbooks for the GÉANT OAV Ansible course. This repo holds sample Ansible playbooks for the GÉANT OAV Ansible course.
These mostly consist of vEOS examples but there is a `show_version_juniper` example in `Section1/show_version/`. These mostly consist of vEOS examples but there is a `show_version_juniper` example in `Section2/playbooks/show_version/`.
Some of the files are accompanied by example output, e.g. `show_version.yaml` produced `show_version.output`. Some of the files are accompanied by example output, e.g. `show_version.yaml` is accompanied by `show_version.output`.
[defaults]
deprecation_warnings=False
# don't like cows? that's unfortunate.
# set to 1 if you don't want cowsay support or export ANSIBLE_NOCOWS=1
nocows = 1
# You can only have one 'stdout' callback type enabled at a time. The default
# is 'default'. The 'yaml' or 'debug' stdout callback plugins are easier to read.
#
stdout_callback = default
#stdout_callback = yaml
#stdout_callback = debug
inventory = hosts
...@@ -4,6 +4,7 @@ host_key_checking = False ...@@ -4,6 +4,7 @@ host_key_checking = False
stdout_callback = yaml stdout_callback = yaml
# Damned cows...
nocows = True nocows = True
inventory = hosts inventory = hosts
[all:vars] [all:vars]
ansible_user=zork ansible_user=zork
ansible_ssh_pass=swordfish ansible_ssh_pass=swordfish
ansible_host=localhost
[veos_hosts] [veos_hosts]
veos ansible_port=9022 ansible_host=localhost ansible_network_os=eos ansible_connection=network_cli veos ansible_port=9022 ansible_network_os=eos ansible_connection=network_cli
[debian_hosts] [debian_hosts]
testhost ansible_port=9023 ansible_host=localhost testhost ansible_port=9024
#
# Why different passwords? JunOS is a lot stricter. Good!
#
[junos_hosts]
vSRX ansible_port=9023 ansible_ssh_pass=Swordfish123
[guinea_pigs]
veos ansible_connection=ssh ansible_host=localhost ansible_port=9022 ansible_user=zork ansible_ssh_pass=swordfish
PLAY [A play to run the ping module] ******************************************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************************************************************
ok: [testhost]
TASK [A task to invoke the ping module] ***************************************************************************************************************************************
ok: [testhost]
TASK [A task to print the output] *********************************************************************************************************************************************
ok: [testhost] =>
ping_results:
changed: false
failed: false
ping: pong
PLAY RECAP ********************************************************************************************************************************************************************
testhost : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
--- ---
- name: A play to run the ping module - name: A play to run the ping module
hosts: testhost hosts: debian_hosts
tasks: tasks:
- name: A task to invoke the ping module - name: A task to invoke the ping module
ping: ping:
......
[WARNING]: Could not match supplied host pattern, ignoring: fakeserver
PLAY [A play to run the ping module] **********************************************************
skipping: no hosts matched
PLAY RECAP ************************************************************************************
---
- name: A play to run the ping module
hosts: fakeserver
tasks:
- name: A task to invoke the ping module
ping:
register: ping_results
- name: A task to print the output
debug: var=ping_results
PLAY [A play to run the ping module against an unreachable host] ***************
TASK [Gathering Facts] *********************************************************
fatal: [vSRX]: UNREACHABLE! => changed=false
msg: 'Failed to connect to the host via ssh: ssh: connect to host localhost port 9023: Connection refused'
unreachable: true
PLAY RECAP *********************************************************************
vSRX : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
---
- name: A play to run the ping module against an unreachable host
hosts: vSRX
tasks:
- name: A task to invoke the ping module
ping:
register: ping_results
- name: A task to print the output
debug: var=ping_results
---
- name: Check the version of code on all switches
hosts: veos
gather_facts: no # or False
tasks:
- name: Gather version from switches
raw: ‘show version| include Software’
register: show_version
- name: Display the version
debug: var=show_version
...@@ -4,19 +4,19 @@ The hosts file in this directory has two hosts defined - one vEOS, one JunOS. ...@@ -4,19 +4,19 @@ The hosts file in this directory has two hosts defined - one vEOS, one JunOS.
``` ```
[all:vars] [all:vars]
ansible_connection=ssh
ansible_user=zork ansible_user=zork
ansible_ssh_pass=swordfish
ansible_host=localhost ansible_host=localhost
ansible_connection=ssh
[veos_hosts] [veos_hosts]
veos ansible_port=9022 ansible_ssh_pass=swordfish veos ansible_port=9022
# #
# Why different passwords? JunOS is a lot stricter. Good! # Why different passwords? JunOS is a lot stricter. Good!
# #
[junos_hosts] [junos_hosts]
vSRX ansible_port=9023 ansible_ssh_pass=Swordfish123 vSRX ansible_port=9023 ansible_ssh_pass=Swordfish123```
```
You will need to replace the host information to match your test/learning environment. You will need to replace the host information to match your test/learning environment.
...@@ -34,4 +34,4 @@ Run ``ansible-playbook -i hosts show_version_and_uptime.yaml`` ...@@ -34,4 +34,4 @@ Run ``ansible-playbook -i hosts show_version_and_uptime.yaml``
# Device specific # 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 since it's hidden by Ansible will never come. 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 - since the prompt is hidden by Ansible - will never come.
[defaults]
host_key_checking = False
#stdout_callback = yaml
nocows = True
inventory = hosts
[all:vars]
ansible_user=zork
ansible_ssh_pass=swordfish
ansible_host=localhost
ansible_connection=ssh
[veos_hosts]
veos ansible_port=9022
#
# Why different passwords? JunOS is a lot stricter. Good!
#
[junos_hosts]
vSRX ansible_port=9023 ansible_ssh_pass=Swordfish123
PLAY [Play 1 - Show the software version on an Arista switch] ***************************************************************************************************** PLAY [Play 1 - Show the software version on an Arista switch] ******************
TASK [Task 1.1 - Gather version from switches] ******************************************************************************************************************** TASK [Task 1.1 - Gather version from switch using the raw module] **************
changed: [veos] changed: [veos]
TASK [Task 1.2 - Print output] ************************************************************************************************************************************ TASK [Task 1.2 - Print version] ************************************************
ok: [veos] => { ok: [veos] => {
"showvers": { "showvers": {
"changed": true, "changed": true,
...@@ -21,6 +21,6 @@ ok: [veos] => { ...@@ -21,6 +21,6 @@ ok: [veos] => {
} }
} }
PLAY RECAP ******************************************************************************************************************************************************** PLAY RECAP *********************************************************************
veos : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 veos : 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 - name: Play 1 - Show the software version on an Arista switch
hosts: veos_hosts hosts: veos_hosts
gather_facts: "no" gather_facts: no
connection: local connection: local
tasks: tasks:
- name: Task 1.1 - Gather version from switch using the raw module - name: Task 1.1 - Gather version from switch using the raw module
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment