Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all agd user data to gitops bootstrap helm application #8964

Draft
wants to merge 7 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ ocp4_workload_gitops_bootstrap_health_ignore: true
ocp4_workload_gitops_bootstrap_application_wait: true
ocp4_workload_gitops_bootstrap_application_health_retries: 90
ocp4_workload_gitops_bootstrap_application_health_ignore: true

ocp4_workload_gitops_bootstrap_userdata_in_helm_values: true
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
domain: "{{ r_ingress.resources[0].status.domain }}"
apiUrl: "{{ r_infra.resources[0].status.apiServerURL }}"

- name: >
Add all existing agnosticd_user_info.data to
_ocp4_workload_gitops_bootstrap_deployer_values
when: ocp4_workload_gitops_bootstrap_userdata_in_helm_values | default(true) | bool
ansible.builtin.set_fact:
_ocp4_workload_gitops_bootstrap_deployer_values: |
{{ _ocp4_workload_gitops_bootstrap_deployer_values | combine( { "agnosticd_user_data": lookup('agnosticd_user_data', '*') }) }}

- name: print _ocp4_workload_gitops_bootstrap_deployer_values
ansible.builtin.debug:
msg: "{{ _ocp4_workload_gitops_bootstrap_deployer_values | to_yaml }}"
Expand Down Expand Up @@ -51,6 +59,18 @@
ansible.builtin.pause:
seconds: 60

- name: Debug all applications with our label in any namespace
when: ocp4_workload_gitops_bootstrap_application_wait | bool
vars:
query: "[*].{App: metadata.name, Health: status.health.status, Sync: status.sync.status}"
ansible.builtin.debug:
msg: "{{ _all_apps.resources | json_query(query)}}"

#######
####### Begin processing GitOps output
#######

- name: Retrieve configmaps with the demo.redhat.com/userinfo label
- name: Validate all applications with our label in any namespace are healthy and synced
when: ocp4_workload_gitops_bootstrap_application_wait | bool
kubernetes.core.k8s_info:
Expand All @@ -76,8 +96,34 @@
- "demo.redhat.com/userinfo"
register: cm_userinfo

- name: save configmap userinfo in agnosticd_user_info
- name: Add to agnosticd_user_info all data from configmaps except configmap.data.users_json data
agnosticd_user_info:
data: >-
{{ item.data | from_yaml }}
{{ item | dict2items | selectattr('key', 'ne', 'users_json') | items2dict }}
loop: "{{ cm_userinfo.resources | map(attribute='data') }}"

- name: Prepare data_user_json to add to agnosticd_user_info
ansible.builtin.debug:
msg: "Prepare data_user_json to add to agnosticd_user_info"

- name: Merge list of all users_json data from all configmaps that have data.users_json
set_fact:
data_users_json: "{{ data_users_json | default([]) | combine(item.data.users_json | from_json, recursive=True) }}"
loop: "{{ cm_userinfo.resources }}"
when: item.data.users_json is defined

- name: Debug merged data_users_json data
ansible.builtin.debug:
msg: "{{ data_users_json }}"

- name: Add to agnosticd_user_info all configmap.data.users_json configmap data
agnosticd_user_info:
user: "{{ item.key }}"
data:
"{{ item.value }}"
loop: "{{ data_users_json.users | dict2items }}"
when: data_users_json is defined

- name: Debug user_data
ansible.builtin.debug:
msg: "{{ lookup('agnosticd_user_data', '*') }}"
Loading