communishift: mark admin namespace as do not delete

will move project offboarding into separate playbook
add fasjson lookup for communishift project notifications

Signed-off-by: David Kirwan <davidkirwanirl@gmail.com>
This commit is contained in:
David Kirwan 2024-11-25 14:27:53 +00:00
parent c88ab2cb08
commit 19edfbb42e
No known key found for this signature in database
GPG key ID: A5893AB6474AC37D
6 changed files with 29 additions and 23 deletions

View file

@ -35,6 +35,8 @@ br1_nm: 255.255.255.0
collectd_apache: true
# communishift project resource overrides
communishift_projects:
communishift-admins:
do_not_delete: true # Marked do not delete 2024-11-25
communishift-eventbot:
name: communishift-eventbot
communishift-fedora-review-service:

View file

@ -16,6 +16,11 @@
loop_control:
loop_var: communishift_package
- name: Communishift Retrieve FASJSON data
include_role:
name: communishift
tasks_from: retrieve-communishift-admin-data
- name: Communishift Cluster Cleanup Tasks
with_items: "{{ communishift_projects }}"
include_role:

View file

@ -57,26 +57,28 @@ matched_groups:
type: str
returned: always
sample:
[
{
{
"communishift-yyy": {
"group_name": "communishift-yyy",
"group_members": [
{"username": "user1": {"emails": ["user1@gmail.com"]}},
{"username": "user2": {"emails": ["user2@gmail.com"]}},
{"username": "user3": {"emails": ["user3@gmail.com"]}},
{"username": "user4": {"emails": ["user4@gmail.com"]}}
]
],
"email_list": ["user1@gmail.com", "user2@gmail.com", "user3@gmail.com", "user4@gmail.com"]
},
{
"communishift-abc": {
"group_name": "communishift-abc",
"group_members": [
{"username": "user1": {"emails": ["user1@gmail.com"]}},
{"username": "user3": {"emails": ["user3@gmail.com"]}},
{"username": "user7": {"emails": ["user7@gmail.com"]}},
{"username": "user9": {"emails": ["user9@gmail.com"]}}
]
],
"email_list": ["user1@gmail.com", "user3@gmail.com", "user7@gmail.com", "user9@gmail.com"]
}
]
}
msg:
description: The output message that the module generates.
@ -159,28 +161,25 @@ def run_module():
groups_response = get_groups(http_client)
# print(json.dumps(groups_response))
communishift_groups = []
communishift_groups = {}
regexp = re.compile(r"%s" % (group_name_pattern))
for v in groups_response["result"]:
if regexp.search(v["groupname"]):
group = {"groupname": v["groupname"], "groupmembers": []}
group = {"groupname": v["groupname"], "groupmembers": [], "email_list": []}
group_member_res = get_group_members(http_client, v["groupname"])
# print(json.dumps(group_member_res))
for v in group_member_res["result"]:
user_data_res = get_group_member_data(http_client, v["username"])
# user_data_res["result"]["emails"] contains {"user1": {"emails": ["user1@gmail.com"]}}
u = {"username": v["username"], "emails": user_data_res["result"]["emails"]}
for val in group_member_res["result"]:
user_data_res = get_group_member_data(http_client, val["username"])
u = {"username": val["username"], "emails": user_data_res["result"]["emails"]}
group["groupmembers"].append(u)
communishift_groups.append(group)
# print(v["groupname"])
# print(json.dumps(communishift_groups))
group["email_list"].extend(user_data_res["result"]["emails"])
communishift_groups[v["groupname"]] = group
result["matched_groups"] = json.dumps(communishift_groups)
result["changed"] = True
result["msg"] = "Successfully retrieved groups and their users from fasjson."
result["message"] = "Successfully retrieved groups and their users from fasjson."
except Exception:
raise

View file

@ -1,4 +1,3 @@
---
#- include_tasks: retrieve-communishift-admin-data.yml
- include_tasks: send-tenant-deletion-notifications.yml
- include_tasks: start-tenant-project-cleanup.yml

View file

@ -12,7 +12,11 @@
register: communishift_project_emails_fasjson_response
run_once: true
- name: Check if this project should be deleted
ansible.builtin.set_fact:
communishift_project_emails: "{{ communishift_project_emails_fasjson_response['matched_groups'] | from_json }}"
- name: Debug
debug:
msg: "{{ communishift_project_emails_fasjson_response }}"
msg: "{{ communishift_project_emails }}"
run_once: true

View file

@ -25,10 +25,7 @@
Make sure to reference the project name and please provide a reason for the extention, also please include how long you wish the extention to be
in place for.
from: admin@fedoraproject.org
to:
- D Kirwan <dkirwan+communishift_notification_test_1@redhat.com>
- David K <dkirwan+communishift_notification_test_2@redhat.com>
cc: David Kirwan <dkirwan@redhat.com>
to: "{{ communishift_project_emails[item.value.name]['email_list'] }}"
headers:
- Reply-To=admin@fedoraproject.org
charset: us-ascii