-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_report.yaml
More file actions
25 lines (25 loc) · 860 Bytes
/
send_report.yaml
File metadata and controls
25 lines (25 loc) · 860 Bytes
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
- name: Send consolidated VM report
hosts: localhost
gather_facts: true
vars:
collected_metrics: >-
{{
hostvars |
dict2items |
selectattr('value.vm_metrics', 'defined') |
map(attribute='value.vm_metrics') |
list
}}
timestamp: "{{ ansible_date_time.date }} {{ ansible_date_time.time }}"
subject_line: "📊 VM Report – {{ ansible_date_time.date }} {{ ansible_date_time.hour }}:{{ ansible_date_time.minute }}"
tasks:
- name: Send animated HTML report via email
mail:
host: "{{ smtp_server }}"
port: "{{ smtp_port }}"
username: "{{ email_user }}"
password: "{{ email_pass }}"
to: "{{ alert_recipient }}"
subject: "{{ subject_line }}"
body: "{{ lookup('template', 'templates/report_email.html.j2') }}"
subtype: html