-
Notifications
You must be signed in to change notification settings - Fork 6
/
configure_admin_email_notifications.yml
59 lines (52 loc) · 1.61 KB
/
configure_admin_email_notifications.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
---
#
# Configure email notifications for user admin.
#
# It expects that Tendrl notifier is already properly configured
# (usable after tendrl.yml playbook).
#
# # parameters:
# recipient_email: where to send notification emails (required)
#
# tendrl_user: tendrl user (default: admin)
# tendrl_password: password for tendrl user (default: adminuser)
#
- hosts: usm_server
remote_user: root
vars:
tendrl_user: "admin"
tendrl_password: "adminuser"
tendrl_api_url: "{{ tendrl_api_url_protocol | default('http') }}://{{ inventory_hostname }}/api/1.0"
pre_tasks:
- name: Check that 'recipient_email' variable is defined properly
assert:
that:
- recipient_email is defined
tasks:
- debug:
var: tendrl_api_url
- name: Login into Tendrl
local_action:
module: uri
url: "{{ tendrl_api_url }}/login"
method: POST
body: {"username":"{{ tendrl_user }}", "password":"{{ tendrl_password }}"}
body_format: json
register: login
- name: Configure admin user
local_action:
module: uri
url: "{{ tendrl_api_url }}/users/admin"
method: PUT
body: {"name":"Admin", "username":"admin", "email":"{{ recipient_email }}", "role":"admin", "email_notifications":true}
body_format: json
headers:
Authorization: Bearer {{ login.json.access_token }}
- name: Logout
local_action:
module: uri
url: "{{ tendrl_api_url }}/logout"
method: DELETE
return_content: yes
headers:
Authorization: Bearer {{ login.json.access_token }}