-
Notifications
You must be signed in to change notification settings - Fork 1
/
gather_facts.yml
51 lines (48 loc) · 1.57 KB
/
gather_facts.yml
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
- name: Housekeeping
hosts: all
connection: local
gather_facts: no
run_once: true
tags: always
tasks:
- name: remove host config temp directory
file: path=/root/ansible_tmp/config state=absent
- name: remove host output temp directory
file: path=/root/ansible_tmp/output state=absent
- name: create host config temp directory
file: path=/root/ansible_tmp/config state=directory
- name: create host output temp directory
file: path=/root/ansible_tmp/output state=directory
- name: Gather facts from Junos devices
hosts: all
connection: local
gather_facts: no
roles:
- Juniper.junos
tasks:
- name: Save Junos output to destination files
juniper_junos_command:
command:
- "show version"
- "show chassis hardware"
dest: "/root/ansible_tmp/output/{{ inventory_hostname }}.output"
# Concatenate all output files to a single text file
- assemble:
src: /root/ansible_tmp/output/
regexp: '(.*\.output$)'
dest: /root/ansible_tmp/output/gather_facts.txt
delimiter: '-----------------'
run_once: true
# Send an email with gather_facts.txt attatchment
- mail:
host: mail.smtp2go.com
port: 443
secure: always
from: Ansible AWX <[email protected]>
to: '{{ to_email }}'
subject: Ansible AWX Gather Facts Report
body: 'Gather Fatcs playbook has been successfully executed.'
attach: /root/ansible_tmp/output/gather_facts.txt
delegate_to: localhost
run_once: true