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:
parent
c88ab2cb08
commit
19edfbb42e
6 changed files with 29 additions and 23 deletions
|
@ -35,6 +35,8 @@ br1_nm: 255.255.255.0
|
||||||
collectd_apache: true
|
collectd_apache: true
|
||||||
# communishift project resource overrides
|
# communishift project resource overrides
|
||||||
communishift_projects:
|
communishift_projects:
|
||||||
|
communishift-admins:
|
||||||
|
do_not_delete: true # Marked do not delete 2024-11-25
|
||||||
communishift-eventbot:
|
communishift-eventbot:
|
||||||
name: communishift-eventbot
|
name: communishift-eventbot
|
||||||
communishift-fedora-review-service:
|
communishift-fedora-review-service:
|
||||||
|
|
|
@ -16,6 +16,11 @@
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: communishift_package
|
loop_var: communishift_package
|
||||||
|
|
||||||
|
- name: Communishift Retrieve FASJSON data
|
||||||
|
include_role:
|
||||||
|
name: communishift
|
||||||
|
tasks_from: retrieve-communishift-admin-data
|
||||||
|
|
||||||
- name: Communishift Cluster Cleanup Tasks
|
- name: Communishift Cluster Cleanup Tasks
|
||||||
with_items: "{{ communishift_projects }}"
|
with_items: "{{ communishift_projects }}"
|
||||||
include_role:
|
include_role:
|
||||||
|
|
|
@ -57,26 +57,28 @@ matched_groups:
|
||||||
type: str
|
type: str
|
||||||
returned: always
|
returned: always
|
||||||
sample:
|
sample:
|
||||||
[
|
|
||||||
{
|
{
|
||||||
|
"communishift-yyy": {
|
||||||
"group_name": "communishift-yyy",
|
"group_name": "communishift-yyy",
|
||||||
"group_members": [
|
"group_members": [
|
||||||
{"username": "user1": {"emails": ["user1@gmail.com"]}},
|
{"username": "user1": {"emails": ["user1@gmail.com"]}},
|
||||||
{"username": "user2": {"emails": ["user2@gmail.com"]}},
|
{"username": "user2": {"emails": ["user2@gmail.com"]}},
|
||||||
{"username": "user3": {"emails": ["user3@gmail.com"]}},
|
{"username": "user3": {"emails": ["user3@gmail.com"]}},
|
||||||
{"username": "user4": {"emails": ["user4@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_name": "communishift-abc",
|
||||||
"group_members": [
|
"group_members": [
|
||||||
{"username": "user1": {"emails": ["user1@gmail.com"]}},
|
{"username": "user1": {"emails": ["user1@gmail.com"]}},
|
||||||
{"username": "user3": {"emails": ["user3@gmail.com"]}},
|
{"username": "user3": {"emails": ["user3@gmail.com"]}},
|
||||||
{"username": "user7": {"emails": ["user7@gmail.com"]}},
|
{"username": "user7": {"emails": ["user7@gmail.com"]}},
|
||||||
{"username": "user9": {"emails": ["user9@gmail.com"]}}
|
{"username": "user9": {"emails": ["user9@gmail.com"]}}
|
||||||
]
|
],
|
||||||
|
"email_list": ["user1@gmail.com", "user3@gmail.com", "user7@gmail.com", "user9@gmail.com"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
|
|
||||||
msg:
|
msg:
|
||||||
description: The output message that the module generates.
|
description: The output message that the module generates.
|
||||||
|
@ -159,28 +161,25 @@ def run_module():
|
||||||
groups_response = get_groups(http_client)
|
groups_response = get_groups(http_client)
|
||||||
# print(json.dumps(groups_response))
|
# print(json.dumps(groups_response))
|
||||||
|
|
||||||
communishift_groups = []
|
communishift_groups = {}
|
||||||
regexp = re.compile(r"%s" % (group_name_pattern))
|
regexp = re.compile(r"%s" % (group_name_pattern))
|
||||||
for v in groups_response["result"]:
|
for v in groups_response["result"]:
|
||||||
if regexp.search(v["groupname"]):
|
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"])
|
group_member_res = get_group_members(http_client, v["groupname"])
|
||||||
# print(json.dumps(group_member_res))
|
# print(json.dumps(group_member_res))
|
||||||
|
|
||||||
for v in group_member_res["result"]:
|
for val in group_member_res["result"]:
|
||||||
user_data_res = get_group_member_data(http_client, v["username"])
|
user_data_res = get_group_member_data(http_client, val["username"])
|
||||||
# user_data_res["result"]["emails"] contains {"user1": {"emails": ["user1@gmail.com"]}}
|
u = {"username": val["username"], "emails": user_data_res["result"]["emails"]}
|
||||||
u = {"username": v["username"], "emails": user_data_res["result"]["emails"]}
|
|
||||||
group["groupmembers"].append(u)
|
group["groupmembers"].append(u)
|
||||||
communishift_groups.append(group)
|
group["email_list"].extend(user_data_res["result"]["emails"])
|
||||||
# print(v["groupname"])
|
communishift_groups[v["groupname"]] = group
|
||||||
|
|
||||||
# print(json.dumps(communishift_groups))
|
|
||||||
|
|
||||||
result["matched_groups"] = json.dumps(communishift_groups)
|
result["matched_groups"] = json.dumps(communishift_groups)
|
||||||
result["changed"] = True
|
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:
|
except Exception:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
---
|
---
|
||||||
#- include_tasks: retrieve-communishift-admin-data.yml
|
#- include_tasks: retrieve-communishift-admin-data.yml
|
||||||
- include_tasks: send-tenant-deletion-notifications.yml
|
- include_tasks: send-tenant-deletion-notifications.yml
|
||||||
- include_tasks: start-tenant-project-cleanup.yml
|
|
||||||
|
|
|
@ -12,7 +12,11 @@
|
||||||
register: communishift_project_emails_fasjson_response
|
register: communishift_project_emails_fasjson_response
|
||||||
run_once: true
|
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
|
- name: Debug
|
||||||
debug:
|
debug:
|
||||||
msg: "{{ communishift_project_emails_fasjson_response }}"
|
msg: "{{ communishift_project_emails }}"
|
||||||
run_once: true
|
run_once: true
|
||||||
|
|
|
@ -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
|
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.
|
in place for.
|
||||||
from: admin@fedoraproject.org
|
from: admin@fedoraproject.org
|
||||||
to:
|
to: "{{ communishift_project_emails[item.value.name]['email_list'] }}"
|
||||||
- D Kirwan <dkirwan+communishift_notification_test_1@redhat.com>
|
|
||||||
- David K <dkirwan+communishift_notification_test_2@redhat.com>
|
|
||||||
cc: David Kirwan <dkirwan@redhat.com>
|
|
||||||
headers:
|
headers:
|
||||||
- Reply-To=admin@fedoraproject.org
|
- Reply-To=admin@fedoraproject.org
|
||||||
charset: us-ascii
|
charset: us-ascii
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue