-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprecheck03.yml
More file actions
36 lines (29 loc) · 1.31 KB
/
precheck03.yml
File metadata and controls
36 lines (29 loc) · 1.31 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
32
33
34
35
---
- 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)
vars:
ansible_ssh_pass: alta3
# 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