-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest_teardown.smtp.yml
99 lines (88 loc) · 2.81 KB
/
test_teardown.smtp.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
- hosts: usm_server
remote_user: root
handlers:
- name: restart tendrl-notifier
service:
name: tendrl-notifier
state: restarted
vars:
# TODO: load admin and password from somewhere?
tendrl_user: "admin"
tendrl_password: "adminuser"
tendrl_api_url: "{{ tendrl_api_url_protocol | default('http') }}://{{ inventory_hostname }}/api/1.0"
tasks:
- debug:
var: tendrl_api_url
# this task comes from tendl-ansible,
# using default values from tendrl-notifier rpm package
- name: Reset email notifications in email.conf.yaml of tendrl-notifier
lineinfile:
dest: /etc/tendrl/notifier/email.conf.yaml
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
with_items:
- regexp: '^#? *email_id:.*'
line: "email_id: user1@example.com"
- regexp: '^#? *email_smtp_server:.*'
line: "email_smtp_server: smtp.example.com"
- regexp: '^#? *email_smtp_port:.*'
line: "email_smtp_port: 25"
notify:
- restart tendrl-notifier
- name: Login into Tendrl via API
local_action:
module: uri
url: "{{ tendrl_api_url }}/login"
method: POST
body: {"username":"{{ tendrl_user }}", "password":"{{ tendrl_password }}"}
body_format: json
register: login
- name: Disable and unconfigure email notifications for admin user via API
local_action:
module: uri
url: "{{ tendrl_api_url }}/users/admin"
method: PUT
body: {"name":"Admin", "username":"admin", "email":"admin@example.com", "role":"admin", "email_notifications":false}
body_format: json
headers:
Authorization: Bearer {{ login.json.access_token }}
- name: Logout via API
local_action:
module: uri
url: "{{ tendrl_api_url }}/logout"
method: DELETE
return_content: yes
headers:
Authorization: Bearer {{ login.json.access_token }}
- hosts: usm_client
remote_user: root
handlers:
- name: restart postfix
service:
name: postfix
state: restarted
tasks:
- name: Reconfigure postfix, set inet_interfaces back to localhost
lineinfile:
dest: /etc/postfix/main.cf
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: present
with_items:
- regexp: '^ *inet_interfaces *='
line: 'inet_interfaces = localhost'
notify:
- restart postfix
- name: Reconfigure postfix, drop mynetworks_style option
lineinfile:
dest: /etc/postfix/main.cf
regexp: '^ *mynetworks_style *='
state: absent
notify:
- restart postfix
- name: Keep postfix running and enabled
service:
name: postfix
state: started
enabled: yes