|
6 | 6 | - name: "update-pull-secret-dev : Set new secret content" |
7 | 7 | vars: |
8 | 8 | artifactoryAuthB64: "{{ artifactory_auth | b64encode }}" |
| 9 | + content: |
| 10 | + - "{\"auths\":{\"{{ fvt_image_registry }}\":{\"username\":\"{{ artifactory_username }}\",\"password\":\"{{ artifactory_token }}\",\"email\":\"{{ artifactory_username }}\",\"auth\":\"{{ artifactoryAuthB64 }}\"}" |
| 11 | + - "}" |
| 12 | + - "}" |
9 | 13 | 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('') }}" |
17 | 15 | no_log: true |
18 | 16 |
|
19 | 17 | # 1.2 Find the existing secret, and we are going to modify it rather than replace |
|
38 | 36 | no_log: true |
39 | 37 |
|
40 | 38 | # 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" |
42 | 40 | set_fact: |
43 | | - new_secret_string: '{{ secret_string | combine( new_secret_dev, recursive=True) }}' |
| 41 | + new_secret_dev_dict: "{{ new_secret_dev | from_json }}" |
44 | 42 | no_log: true |
45 | 43 |
|
| 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 | + |
46 | 65 | # 1.4. Overwrite the secret |
47 | 66 | - name: "update-pull-secret-dev : Update new pull-secret" |
48 | 67 | kubernetes.core.k8s: |
| 68 | + state: present |
| 69 | + force: true |
49 | 70 | definition: |
50 | 71 | apiVersion: v1 |
51 | 72 | kind: Secret |
|
0 commit comments