Skip to content

Commit

Permalink
Merge pull request #462 from redhatci/asc_disconnected
Browse files Browse the repository at this point in the history
ACM - Apply mirroring config to the Agent Service Config
  • Loading branch information
betoredhat authored Oct 15, 2024
2 parents 447fa47 + 01d3063 commit 91025f7
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
50 changes: 50 additions & 0 deletions roles/acm_setup/tasks/get-mirroring-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
- name: "Get current master's MCP"
community.kubernetes.k8s_info:
api_version: machineconfiguration.openshift.io/v1
kind: MachineConfigPool
name: master
register: _acm_setup_master_mcp
no_log: true

- name: "Get current master's Machine Config"
vars:
acm_machine_config: "{{ _acm_setup_master_mcp.resources[0].spec.configuration.name }}"
community.kubernetes.k8s_info:
api_version: machineconfiguration.openshift.io/v1
kind: MachineConfig
name: "{{ acm_machine_config }}"
register: _acm_setup_master_mc
no_log: true

- name: "Get cluster user-ca certificate"
community.kubernetes.k8s_info:
api: v1
kind: ConfigMap
name: "user-ca-bundle"
namespace: openshift-config
register: _acm_setup_user_ca_bundle
no_log: true

- name: "Create a Config map with registry entries and CA bundle"
vars:
acm_user_ca_bundle: "{{ _acm_setup_user_ca_bundle.resources[0].data['ca-bundle.crt'] }}"
registry_config: "{{ (_acm_setup_master_mc | json_query('resources[0].spec.config.storage.files[?path==`/etc/containers/registries.conf`].contents.source'))[0] |
regex_replace('^data:.*;base64,', '') | b64decode }}"
mirror_cm_def: |
apiVersion: v1
kind: ConfigMap
metadata:
name: mirror-registry-config-map
namespace: multicluster-engine
labels:
app: assisted-service
data:
registries.conf: |
{{ registry_config | indent(4) }}
ca-bundle.crt: |
{{ acm_user_ca_bundle | indent(4) }}
community.kubernetes.k8s:
state: present
definition: "{{ mirror_cm_def }}"
...
9 changes: 9 additions & 0 deletions roles/acm_setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@
namespace: multicluster-engine
register: _asg

- name: "Get Hub Cluster mirroring configuration"
ansible.builtin.include_tasks: get-mirroring-config.yml
when:
- hub_disconnected | bool

- name: "Create the Agent Service config"
when: _asg.resources | length == 0
vars:
Expand Down Expand Up @@ -295,6 +300,10 @@
{% if hub_os_images is defined %}
osImages: {{ hub_os_images }}
{% endif %}
{% if hub_disconnected | bool %}
mirrorRegistryRef:
name: mirror-registry-config-map
{% endif %}
community.kubernetes.k8s:
state: present
definition: "{{ agent_def }}"
Expand Down

0 comments on commit 91025f7

Please sign in to comment.