|
53 | 53 | spec: |
54 | 54 | imageDigestMirrors: "{{ cifmw_openshift_setup_digest_mirrors }}" |
55 | 55 |
|
| 56 | +- name: Add catalog registry credentials to cluster pull-secret |
| 57 | + when: |
| 58 | + - cifmw_catalog_manifest is defined |
| 59 | + - cifmw_catalog_manifest | length > 0 |
| 60 | + - cifmw_openshift_setup_catalog_registry_credentials is defined |
| 61 | + no_log: true |
| 62 | + block: |
| 63 | + - name: Get current cluster pull-secret |
| 64 | + kubernetes.core.k8s_info: |
| 65 | + kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
| 66 | + api_key: "{{ cifmw_openshift_token | default(omit) }}" |
| 67 | + context: "{{ cifmw_openshift_context | default(omit) }}" |
| 68 | + kind: Secret |
| 69 | + name: pull-secret |
| 70 | + namespace: openshift-config |
| 71 | + register: _cluster_pull_secret |
| 72 | + |
| 73 | + - name: Merge catalog registry auth into cluster pull-secret |
| 74 | + vars: |
| 75 | + _current_auths: >- |
| 76 | + {{ |
| 77 | + (_cluster_pull_secret.resources[0].data['.dockerconfigjson'] |
| 78 | + | b64decode | from_json).auths |
| 79 | + }} |
| 80 | + _catalog_auth: |
| 81 | + "{{ cifmw_openshift_setup_catalog_registry_credentials.registry }}": |
| 82 | + auth: >- |
| 83 | + {{ |
| 84 | + (cifmw_openshift_setup_catalog_registry_credentials.username ~ ':' |
| 85 | + ~ cifmw_openshift_setup_catalog_registry_credentials.password) |
| 86 | + | b64encode |
| 87 | + }} |
| 88 | + _merged: |
| 89 | + auths: "{{ _current_auths | combine(_catalog_auth) }}" |
| 90 | + kubernetes.core.k8s: |
| 91 | + kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
| 92 | + api_key: "{{ cifmw_openshift_token | default(omit) }}" |
| 93 | + context: "{{ cifmw_openshift_context | default(omit) }}" |
| 94 | + state: present |
| 95 | + definition: |
| 96 | + apiVersion: v1 |
| 97 | + kind: Secret |
| 98 | + metadata: |
| 99 | + name: pull-secret |
| 100 | + namespace: openshift-config |
| 101 | + type: kubernetes.io/dockerconfigjson |
| 102 | + data: |
| 103 | + .dockerconfigjson: "{{ _merged | to_json | b64encode }}" |
| 104 | + |
| 105 | +- name: Create CatalogSource for OpenStack operators |
| 106 | + when: |
| 107 | + - cifmw_catalog_manifest is defined |
| 108 | + - cifmw_catalog_manifest | length > 0 |
| 109 | + kubernetes.core.k8s: |
| 110 | + kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
| 111 | + api_key: "{{ cifmw_openshift_token | default(omit)}}" |
| 112 | + context: "{{ cifmw_openshift_context | default(omit)}}" |
| 113 | + definition: "{{ cifmw_catalog_manifest }}" |
| 114 | + |
56 | 115 | # If both ImageDigestMirrorSet and ImageTagMirrorSet are applied to the registries, |
57 | 116 | # ITMS acts as a fallback for tag-based pulls, while IDMS provides the primary |
58 | 117 | # secure source for digests |
|
0 commit comments