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

DC - Initial commit

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 317 additions and 0 deletions
---
- 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
PLAY [Play 1 - Show the software version on an Arista switch] *****************************************************************************************************
TASK [Task 1.1 - Gather version from switches] ********************************************************************************************************************
changed: [veos]
TASK [Task 1.2 - Print output] ************************************************************************************************************************************
ok: [veos] => {
"showvers": {
"changed": true,
"failed": false,
"rc": 0,
"stderr": "Shared connection to localhost closed.\r\n",
"stderr_lines": [
"Shared connection to localhost closed."
],
"stdout": "Software image version: 4.27.0F\r\n",
"stdout_lines": [
"Software image version: 4.27.0F"
]
}
}
PLAY RECAP ********************************************************************************************************************************************************
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
hosts: veos
gather_facts: no
vars:
ansible_connection: network_cli
ansible_network_os: eos
tasks:
- name: Task 1.1 - Gather version from switches
eos_command:
commands:
- 'show version | include Software'
- 'show uptime'
register: eos_commands
- name: Task 1.2 - Print output
debug: var=eos_commands.stdout_lines
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": [
"Model: vSRX",
"Junos: 21.3R1.9",
"JUNOS OS Kernel 64-bit XEN [20210828.6e5b1bf_builder_stable_12_213]",
"JUNOS OS libs [20210828.6e5b1bf_builder_stable_12_213]",
"JUNOS OS runtime [20210828.6e5b1bf_builder_stable_12_213]",
"JUNOS OS time zone information [20210828.6e5b1bf_builder_stable_12_213]",
"JUNOS OS libs compat32 [20210828.6e5b1bf_builder_stable_12_213]",
"JUNOS OS 32-bit compatibility [20210828.6e5b1bf_builder_stable_12_213]",
"JUNOS py extensions [20210915.190147_builder_junos_213_r1]",
"JUNOS py base [20210915.190147_builder_junos_213_r1]",
"JUNOS OS vmguest [20210828.6e5b1bf_builder_stable_12_213]",
"JUNOS OS crypto [20210828.6e5b1bf_builder_stable_12_213]",
"JUNOS OS boot-ve files [20210828.6e5b1bf_builder_stable_12_213]",
"JUNOS network stack and utilities [20210915.190147_builder_junos_213_r1]",
"JUNOS libs [20210915.190147_builder_junos_213_r1]",
"JUNOS libs compat32 [20210915.190147_builder_junos_213_r1]",
"JUNOS runtime [20210915.190147_builder_junos_213_r1]",
"JUNOS na telemetry [21.3R1.9]",
"JUNOS Web Management Platform Package [20210915.190147_builder_junos_213_r1]",
"JUNOS vsrx modules [20210915.190147_builder_junos_213_r1]",
"JUNOS srx libs compat32 [20210915.190147_builder_junos_213_r1]",
"JUNOS srx runtime [20210915.190147_builder_junos_213_r1]",
"JUNOS srx platform support [20210915.190147_builder_junos_213_r1]",
"JUNOS common platform support [20210915.190147_builder_junos_213_r1]",
"JUNOS vsrx runtime [20210915.190147_builder_junos_213_r1]",
"JUNOS Routing mpls-oam-basic [20210915.190147_builder_junos_213_r1]",
"JUNOS Routing lsys [20210915.190147_builder_junos_213_r1]",
"JUNOS Routing 32-bit Compatible Version [20210915.190147_builder_junos_213_r1]",
"JUNOS Routing aggregated [20210915.190147_builder_junos_213_r1]",
"JUNOS probe utility [20210915.190147_builder_junos_213_r1]",
"JUNOS pppoe [20210915.190147_builder_junos_213_r1]",
"JUNOS Openconfig [21.3R1.9]",
"JUNOS mtx network modules [20210915.190147_builder_junos_213_r1]",
"JUNOS modules [20210915.190147_builder_junos_213_r1]",
"JUNOS srx libs [20210915.190147_builder_junos_213_r1]",
"JUNOS hsm [20210915.190147_builder_junos_213_r1]",
"JUNOS srx Data Plane Crypto Support [20210915.190147_builder_junos_213_r1]",
"JUNOS daemons [20210915.190147_builder_junos_213_r1]",
"JUNOS srx daemons [20210915.190147_builder_junos_213_r1]",
"JUNOS cloud libs [20210915.190147_builder_junos_213_r1]",
"JUNOS cloud init [20210915.190147_builder_junos_213_r1]",
"JUNOS SRX TVP AppQos Daemon [20210915.190147_builder_junos_213_r1]",
"JUNOS Extension Toolkit [20210915.190147_builder_junos_213_r1]",
"JUNOS Juniper Malware Removal Tool (JMRT) [1.0.0+20210915.190147_builder_junos_213_r1]",
"JUNOS J-Insight [20210915.190147_builder_junos_213_r1]",
"JUNOS Online Documentation [20210915.190147_builder_junos_213_r1]",
"JUNOS jail runtime [20210828.6e5b1bf_builder_stable_12_213]",
"JUNOS FIPS mode utilities [20210915.190147_builder_junos_213_r1]",
"JUNOS dsa dsa [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 a vSRX
hosts: vSRX
gather_facts: "no"
connection: local
tasks:
- name: Task 1.1 - Gather version from switches
raw: 'show version | no-more'
register: showvers
- name: Task 1.2 - Print output
debug: var=showvers.stdout_lines
[defaults]
host_key_checking = False
stdout_callback = yaml
nocows = True
inventory = hosts
---
- name: Copy the relevant files to the target
# become: true
hosts: testhost
vars:
source_file: foo.conf
destination_directory: /tmp/foo.conf
tasks:
- name: copy foo.conf to server
copy:
src: "{{ source_file }}"
dest: "{{ destination_directory }}"
backup: yes
# owner: scapegoat
# group: scapegoat
# mode: "0644"
# foo.conf
#
# This file was copied using Ansible's "copy" module.
[all:vars]
ansible_user=zork
ansible_ssh_pass=swordfish
[veos_hosts]
veos ansible_port=9022 ansible_host=localhost ansible_network_os=eos ansible_connection=network_cli
[debian_hosts]
testhost ansible_port=9023 ansible_host=localhost
[guinea_pigs]
veos ansible_connection=ssh ansible_host=localhost ansible_port=9022 ansible_user=zork ansible_ssh_pass=swordfish
---
- name: Install Apache2 on all webservers
hosts: webservers
sudo: yes # Must be root
tasks:
- name: Install Apache
apt: pkg=apache2 state=latest # httpd if using yum
- name: Generate config file
copy: src=httpd.conf dest=/etc/httpd.conf
- name: Restart Apache
service:
name=httpd state=started
---
- name: Install mod_rewrite on all webservers
hosts: webservers
sudo: yes # Gotta be root
tasks:
- name: Install Apache
apt: pkg=apache2 state=latest
- name: enable mod_rewrite
apache2_module:
name : rewrite
state : present
notify:
- restart apache2
handlers:
- name: Restart Apache
service: name=apache2 state=restarted
---
- name: A play to run the ping module
hosts: testhost
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: Copy the relevant files to the target
vars:
source_file: foo.conf
destination_directory: /etc/foo
tasks:
- name: "copy foo.conf to server"
copy:
src: {{ source_file }}
dest: {{ destination_directory }}
owner: foo
group: foo
mode: ‘0644’
backup: yes
logging_level: 4
syslog_level: 4
log_buffer: 45000
radius_host:
- host: 193.1.219.33
- host: 193.1.248.38
logging:
- host: 193.1.219.117
- host: 193.1.219.36
- host: 193.1.248.123
dns:
- server: 193.1.186.2
- server: 193.1.186.3
domain_name: services.hea.net
vlans:
- name: vlan 1234
description: "[UNI] Panopticon"
port_type: svi
ip_address: 87.44.43.2/28
ipv6_address: 2001:770:6:1705::1/64
ip_helper_address:
- address: 87.44.1.23
- address: 87.44.4.56
#
vrrp_group: 1
vrrp_ip: 87.44.43.1
vrrp_priority: 60
vrrp_auth: sooper_seekrit
vrrp_preempt: True
#
shutdown: False
default: False
---
- 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
---
- name: Play 1 - Show the software version on an Arista switch
hosts: veos
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}}!"
---
- name: Check the version of code on a switch
hosts: veos
gather_facts: no # or False
tasks:
- name: Gather version from switches
raw: ‘show version’
register: show_version
---
# Oh look, a comment…
# …spread out over multiple lines
- name: Set up Apache # Or nginx, or Mongoose
hosts: webservers
tasks:
- name: install Apache
- name: generate Apache config file
- name: download Web content to relevant directory
- name: restart Apache
- name: eat cake
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment