Skip to content

Commit 316a292

Browse files
author
MAHDTech
authored
Update manage-participants playbook (#71)
* Update manage-participants playbook - Add optional null entrypoint - Check url & token both defined and not null - Iterate over correct list of users to remove on ResourceClaim deletion - Use old galaxy requirements format for dependencies - Remove the git_config override injected through resource dispatcher in favor of vars at role level - Remove the use of __meta__ which has been deprecated upstream. - Update commit msg to include filenames * Update commit msg format * Remove all participants - Ensure all participants are removed when resourceclaim deleted - Update task name to be more descriptive - Ensure the queue is also cleared if defined * Fix indentation on callback when condition
1 parent 7e69d5d commit 316a292

File tree

8 files changed

+90
-50
lines changed

8 files changed

+90
-50
lines changed

inventory-generation/identity-management/main.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@
112112
ssh_key: "{{ ( repository_ssh_key | to_nice_yaml( default_style='>-', indent=4, width=5000 ) | trim) if repository_ssh_key is defined else omit }}"
113113
username: "{{ repository_username if repository_username is defined else omit }}"
114114
password: "{{ repository_password if repository_password is defined else omit }}"
115-
git:
116-
name: "{{ git.name if git.name is defined else omit }}"
117-
username: "{{ git.username if git.username is defined else omit }}"
118-
email: "{{ git.email if git.email is defined else omit }}"
119-
message: "{{ git.message if git.message is defined else omit }}"
120115

121116
- name: "Check For Existing Inventory File"
122117
stat:

manage-participants/completion_callback.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
- name: Completion Callback
77
gather_facts: false
88
hosts: localhost
9+
vars:
10+
agnosticd_callback_url: "{{ agnosticd_callback_url | default('') }}"
11+
agnosticd_callback_token: "{{ agnosticd_callback_token | default('') }}"
912
tasks:
1013

1114
- name: Skip completion callback
@@ -48,6 +51,6 @@
4851
{%- endif -%}
4952
headers:
5053
Authorization: Bearer {{ agnosticd_callback_token }}
51-
validate_certs: "{{ validate_tower_certs | default(true) }}"
54+
validate_certs: "{{ validate_tower_certs | default(yes) }}"
5255
# Best effort
5356
ignore_errors: true

manage-participants/destroy.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,46 @@
1515
when:
1616
- ipa_host is defined
1717

18-
- name: Remove participants from IdM
18+
- hosts: identity-hosts
19+
name: Process Identity removal list
20+
tasks:
21+
22+
- name: Create empty removal list
23+
set_fact:
24+
lodestar_identities_remove:
25+
users: []
26+
27+
- name: Add users to removal list
28+
set_fact:
29+
lodestar_identities_remove:
30+
users: "{{ lodestar_identities_remove.users + [ user_info ] }}"
31+
vars:
32+
user_info:
33+
first_name: "{{ identity.first_name | trim }}"
34+
last_name: "{{ identity.last_name | trim }}"
35+
email: "{{ identity.email | trim }}"
36+
user_name: "{{ identity.email.split('@')[0] | trim }}"
37+
state: "absent"
38+
with_items: "{{ lodestar_identities.users }}"
39+
loop_control:
40+
loop_var: identity
41+
when:
42+
- lodestar_identities.users is defined
43+
- lodestar_identities.users != []
44+
45+
- name: Remove all participants from IdM
1946
import_playbook: "../../requirements_roles/infra-ansible/playbooks/manage-identities/manage-idm-identities.yml"
2047
vars:
2148
identities: "{{ lodestar_identities }}"
2249
when:
23-
- lodestar_identities_remove is defined
24-
- lodestar_identities_remove != []
50+
- lodestar_identities.users is defined
51+
- lodestar_identities.users != []
2552

26-
- name: Remove partitipants from queue
53+
- name: Ensure queue is cleared
2754
import_playbook: "process_queue.yml"
2855
when:
29-
- lodestar_identities_remove is defined
30-
- lodestar_identities_remove != []
56+
- lodestar_identities_remove.users is defined
57+
- lodestar_identities_remove.users != []
3158

3259
- name: Update Anarchy with status
3360
import_playbook: completion_callback.yml

manage-participants/mail_users.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
3+
- hosts: mail-host
4+
gather_facts: false
5+
tasks:
6+
7+
- name: "Include additional variables / inventory content"
8+
include_vars:
9+
file: "{{ item }}"
10+
with_items: "{{ email_template | fileglob }}"
11+
12+
- name: Notify users
13+
import_playbook: "../../requirements_roles/infra-ansible/playbooks/notifications/email-notify-users.yml"
14+
vars:
15+
users: "{{ identities.users }}"

manage-participants/main.yml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22

33
- hosts: localhost
4-
name: Verify Identity Provider
4+
name: Verify Identity Provider and setup dependencies
55
tasks:
66

77
- name: Wait for IdM to be responsive
@@ -20,32 +20,22 @@
2020
vars:
2121
identities: "{{ lodestar_identities_remove }}"
2222
when:
23-
- lodestar_identities_remove is defined
24-
- lodestar_identities_remove != []
23+
- lodestar_identities_remove.users is defined
24+
- lodestar_identities_remove.users != []
2525

26-
- name: Remove partitipants from queue
26+
- name: Remove participants from queue
2727
import_playbook: "process_queue.yml"
2828
when:
29-
- lodestar_identities_remove is defined
30-
- lodestar_identities_remove != []
29+
- lodestar_identities_remove.users is defined
30+
- lodestar_identities_remove.users != []
3131

3232
- name: Add participants to IdM
3333
import_playbook: "../../requirements_roles/infra-ansible/playbooks/manage-identities/manage-idm-identities.yml"
3434
vars:
3535
identities: "{{ lodestar_identities }}"
3636

37-
- hosts: mail-host
38-
gather_facts: false
39-
tasks:
40-
- name: "Include additional variables / inventory content"
41-
include_vars:
42-
file: "{{ item }}"
43-
with_items: "{{ email_template | fileglob }}"
44-
45-
- name: Notify users
46-
import_playbook: "../../requirements_roles/infra-ansible/playbooks/notifications/email-notify-users.yml"
47-
vars:
48-
users: "{{ identities.users }}"
37+
- name: Mail Users
38+
import_playbook: mail_users.yml
4939

5040
- name: Update Anarchy with status
5141
import_playbook: completion_callback.yml

manage-participants/null.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
# vim: set ft=ansible:
3+
4+
################################################################################
5+
# Entry point used to send a completion callback and ends the playbook without action
6+
################################################################################
7+
8+
- import_playbook: completion_callback.yml
9+
10+
- name: End Playbook
11+
meta: end_play

manage-participants/process_queue.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,23 @@
4141
name: "../../requirements_roles/infra-ansible/roles/scm/git"
4242
vars:
4343
action: push
44+
git_config:
45+
name: Git Bot
46+
username: git-bot
47+
email: git-bot@no-reply
48+
message: |
49+
Removed processed files
50+
51+
The following files were removed from the job queue
52+
53+
{% for file in files_to_remove %}
54+
- {{ file | basename }}
55+
{% endfor %}
56+
remove_local: false
4457
when:
4558
- repository is defined
59+
- files_to_remove is defined
60+
- files_to_remove != []
4661

4762
- name: Pre-populate identities
4863
set_fact:

roles/requirements.yml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
---
2-
##################################################
3-
# Requirements (Roles)
4-
##################################################
52

6-
collections: []
7-
8-
roles:
9-
- name: infra-ansible
10-
scm: git
11-
12-
# TODO: Phase 1: Run from fork
13-
src: https://github.com/MAHDTech/infra-ansible
14-
version: feature/user-reset
15-
16-
# TODO: Phase 2: Run from main
17-
#src: https://github.com/redhat-cop/infra-ansible
18-
#version: main
19-
20-
# TODO: Phase 3: Run from release
21-
#src: https://github.com/redhat-cop/infra-ansible
22-
#version: v2.0.4
3+
- name: infra-ansible
4+
scm: git
5+
src: https://github.com/redhat-cop/infra-ansible
6+
version: main

0 commit comments

Comments
 (0)