-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.yml
More file actions
78 lines (73 loc) · 2.41 KB
/
main.yml
File metadata and controls
78 lines (73 loc) · 2.41 KB
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
- hosts: localhost
gather_facts: false
tags:
- always
tasks:
- name: Debug
debug:
msg: "Cluster cible: {{ cluster_dso }}"
- name: Set pwd
# Comment
ansible.builtin.set_fact:
cacheable: false
current_keycloak_pwd: "{{ lookup('vars', current.keycloak_auth_password) }}"
- name: Read new users from CSV file
community.general.read_csv:
path: "{{ lookup('ansible.builtin.env', 'USERS_FILE') }}"
delimiter: "{{ lookup('ansible.builtin.env', 'CSV_DELIMITER', default=';') }}"
register: new_users
- name: Users to add
debug:
msg: "Prénom: {{ item.first_name }}, Nom: {{ item.last_name }}, courriel: {{item.email | trim}}"
loop: "{{ new_users.list }}"
- hosts: localhost
gather_facts: false
tags:
- never
- keycloak
tasks:
- name: "Create users on Keycloak"
community.general.keycloak_user:
auth_keycloak_url: "{{ current.keycloak_auth_url }}"
auth_username: "{{ current.keycloak_auth_username }}"
auth_password: "{{ current_keycloak_pwd }}"
auth_realm: "{{ current.keycloak_auth_realm }}"
realm: "{{ current.keycloak_realm }}"
username: "{{ item.email | trim }}"
firstName: "{{ item.first_name | trim | capitalize }}"
lastName: "{{ item.last_name | trim | capitalize }}"
email: "{{ item.email | trim }}"
enabled: true
emailVerified: true
credentials:
- type: password
value: "{{ temporary_password }}"
temporary: true
state: present
validate_certs: "{{ current.keycloak_validate_certs }}"
loop: "{{ new_users.list }}"
- hosts: localhost
gather_facts: false
tags:
- never
- openproject
tasks:
- name: "Create users on OpenProject"
ansible.builtin.uri:
url: "{{ openproject_url }}/api/v3/users"
url_username: "{{ openproject_api_key_username }}"
url_password: "{{ openproject_api_key_password }}"
method: POST
body:
login: "{{ item.email | trim }}"
password: "{{ temporary_password }}"
firstName: "{{ item.first_name | trim | capitalize }}"
lastName: "{{ item.last_name | trim | capitalize }}"
email: "{{ item.email | trim }}"
admin: "{{ openproject_admin }}"
status: "{{ openproject_status }}"
language: "{{ openproject_language }}"
force_basic_auth: true
status_code: 201
body_format: json
loop: "{{ new_users.list }}"