Skip to content

Commit 3d2c182

Browse files
[patch] Revert due to dict key issue
1 parent 67f5823 commit 3d2c182

File tree

2 files changed

+60
-18
lines changed

2 files changed

+60
-18
lines changed

ibm/mas_devops/roles/ocp_idms/tasks/update-pull-secret-dev.yml

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
- name: "update-pull-secret-dev : Set new secret content"
77
vars:
88
artifactoryAuthB64: "{{ artifactory_auth | b64encode }}"
9+
content:
10+
- "{\"auths\":{\"{{ fvt_image_registry }}\":{\"username\":\"{{ artifactory_username }}\",\"password\":\"{{ artifactory_token }}\",\"email\":\"{{ artifactory_username }}\",\"auth\":\"{{ artifactoryAuthB64 }}\"}"
11+
- "}"
12+
- "}"
913
set_fact:
10-
new_secret_dev:
11-
auths:
12-
"{{ fvt_image_registry }}":
13-
username: "{{ artifactory_username }}"
14-
password: "{{ artifactory_token }}"
15-
email: "{{ artifactory_username }}"
16-
auth: "{{ artifactoryAuthB64 }}"
14+
new_secret_dev: "{{ content | join('') }}"
1715
no_log: true
1816

1917
# 1.2 Find the existing secret, and we are going to modify it rather than replace
@@ -38,14 +36,37 @@
3836
no_log: true
3937

4038
# 1.3 Append our new credentials to the secret
41-
- name: "update-pull-secret-dev : Combine new secret content"
39+
- name: "update-pull-secret-dev : Convert new secret to dict"
4240
set_fact:
43-
new_secret_string: '{{ secret_string | combine( new_secret_dev, recursive=True) }}'
41+
new_secret_dev_dict: "{{ new_secret_dev | from_json }}"
4442
no_log: true
4543

44+
- name: "update-pull-secret-dev : Debug registry URL"
45+
debug:
46+
msg: "Adding credentials for registry: {{ fvt_image_registry }}"
47+
48+
- name: "update-pull-secret-dev : Debug existing auths count"
49+
debug:
50+
msg: "Existing auths count: {{ secret_string.auths | length }}"
51+
52+
- name: "update-pull-secret-dev : Debug new auths count"
53+
debug:
54+
msg: "New auths count: {{ new_secret_dev_dict.auths | length }}"
55+
56+
- name: "update-pull-secret-dev : Merge secrets"
57+
set_fact:
58+
new_secret_string: "{{ secret_string | combine(new_secret_dev_dict, recursive=True, list_merge='append') }}"
59+
no_log: true
60+
61+
- name: "update-pull-secret-dev : Debug merged auths count"
62+
debug:
63+
msg: "Merged auths count: {{ new_secret_string.auths | length }}"
64+
4665
# 1.4. Overwrite the secret
4766
- name: "update-pull-secret-dev : Update new pull-secret"
4867
kubernetes.core.k8s:
68+
state: present
69+
force: true
4970
definition:
5071
apiVersion: v1
5172
kind: Secret

ibm/mas_devops/roles/ocp_idms/tasks/update-pull-secret.yml

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
- name: "update-pull-secret : Set new secret content"
77
vars:
88
registryAuthB64: "{{ registry_auth | b64encode }}"
9+
content:
10+
- "{\"auths\":{\"{{ registry_private_url }}\":{\"username\":\"{{ registry_username }}\",\"password\":\"{{ registry_password }}\",\"email\":\"{{ registry_username }}\",\"auth\":\"{{ registryAuthB64 }}\"}"
11+
- "}"
12+
- "}"
913
set_fact:
10-
new_secret:
11-
auths:
12-
"{{ registry_private_url }}":
13-
username: "{{ registry_username }}"
14-
password: "{{ registry_password }}"
15-
email: "{{ registry_username }}"
16-
auth: "{{ registryAuthB64 }}"
14+
new_secret: "{{ content | join('') }}"
1715
no_log: true
1816

1917
# 1.2 Find the existing secret, and we are going to modify it rather than replace
@@ -38,14 +36,37 @@
3836
no_log: true
3937

4038
# 1.3 Append our new credentials to the secret
41-
- name: "update-pull-secret : Combine new secret content"
39+
- name: "update-pull-secret : Convert new secret to dict"
4240
set_fact:
43-
new_secret_string: '{{ secret_string | combine(new_secret, recursive=True) }}'
41+
new_secret_dict: "{{ new_secret | from_json }}"
4442
no_log: true
4543

44+
- name: "update-pull-secret : Debug registry URL"
45+
debug:
46+
msg: "Adding credentials for registry: {{ registry_private_url }}"
47+
48+
- name: "update-pull-secret : Debug existing auths count"
49+
debug:
50+
msg: "Existing auths count: {{ secret_string.auths | length }}"
51+
52+
- name: "update-pull-secret : Debug new auths count"
53+
debug:
54+
msg: "New auths count: {{ new_secret_dict.auths | length }}"
55+
56+
- name: "update-pull-secret : Merge secrets"
57+
set_fact:
58+
new_secret_string: "{{ secret_string | combine(new_secret_dict, recursive=True, list_merge='append') }}"
59+
no_log: true
60+
61+
- name: "update-pull-secret : Debug merged auths count"
62+
debug:
63+
msg: "Merged auths count: {{ new_secret_string.auths | length }}"
64+
4665
# 1.4. Overwrite the secret
4766
- name: "update-pull-secret : Update new pull-secret"
4867
kubernetes.core.k8s:
68+
state: present
69+
force: true
4970
definition:
5071
apiVersion: v1
5172
kind: Secret

0 commit comments

Comments
 (0)