-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprecheck2role01.yml
More file actions
32 lines (27 loc) · 1.28 KB
/
precheck2role01.yml
File metadata and controls
32 lines (27 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---
- name: Building Precheck Failures
hosts: arista_switches # group within the inventory to match on
connection: network_cli # required when connecting to switch devices
become: yes
become_method: enable
gather_facts: yes # this defines ansible_facts
# (it runs *_facts on the target network switches)
# best practice says this file will be searched for in a local vars/ folder
vars_files:
- vars/switchprecheckvalues.yml
tasks:
# dig into the data we want to reveal
- name: Getting at network interfaces
debug:
var: ansible_facts
verbosity: 1
# build a precheck condition where the playbook will FAIL if a condition is not met
- name: "Precheck condition - Is switch running image {{ switch_image }}"
fail:
msg: "This switch does not appear to have the correct image loaded. Exiting..."
when: ansible_facts.net_image != switch_image
# build a precheck condition where the playbook will FAIL if a condition is not met
- name: "Precheck condition - Is switch running image version {{ switch_image_version }}"
fail:
msg: "This switch does not appear to have the correct version of the firmware loaded. Exiting..."
when: ansible_facts.net_version != switch_image_version