-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_role.yml
44 lines (41 loc) · 1.11 KB
/
task_role.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
---
- hosts: group
gather_facts: true
tasks:
- set_fact:
down: "{{ansible_play_hosts_all|difference(ansible_play_hosts) }}"
- debug:
var: down
run_once: true
- name: mail
mail:
host: smtp.mail.com
port: 25
from: mail1@mail.com
username: mail1@mail.com
password: password1
to: mail1@mail.com
subject: Ansible Fail
body: Hello, Issue connectio ansible {{ down }}
delegate_to: localhost
run_once: true
when: down != None
- block:
- include_role:
name: role_1
tasks_from: "{{ item }}"
loop:
- task1
- task2
rescue:
- name: mail
mail: smtp.mail.com
host:
port: 25
from: mail1@mail.com
username: mail1@mail.com
password: password1
to: mail1@mail.com
subject: Ansible Report {{ ansible_hostname }}
body: Ansible ansible {{ ansible_hostname }} Fail. Task {{ ansible_failed_task.name }}
delegate_to: localhost