Skip to content

Commit 1902e6d

Browse files
committed
Fixes for db2 secret creation
1 parent 2a5636b commit 1902e6d

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

ibm/mas_devops/roles/db2/tasks/install/main.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,19 @@
140140
set_fact:
141141
new_secret: "{{ content | join('') }}"
142142

143-
# Note: We use "new_secret | to_json | string" to avoid older versions of Ansible creating invalid json representation containing single quotes
143+
# Note: We use "new_secret | to_json " because older versions of Ansible create
144+
# invalid json representations containing single quotes
145+
# However, in newer versions of Ansible to_json returns an object, which can't be passed to b64encode
146+
- name: "Generate docker secret (old Ansible versions)"
147+
when: ansible_version.full is version_compare(2.20, '<')
148+
set_fact:
149+
dockerconfigjsonB64: "{{ new_secret | to_json | b64encode }}"
150+
151+
- name: "Generate docker secret (new Ansible versions)"
152+
when: ansible_version.full is version_compare(2.20, '>=')
153+
set_fact:
154+
dockerconfigjsonB64: "{{ new_secret | b64encode }}"
155+
144156
- name: "Generate 'ibm-registry' secret"
145157
no_log: true
146158
kubernetes.core.k8s:
@@ -152,7 +164,7 @@
152164
name: ibm-registry
153165
namespace: "{{ db2_namespace }}"
154166
data:
155-
.dockerconfigjson: "{{ new_secret | to_json | string | b64encode }}"
167+
.dockerconfigjson: "{{ dockerconfigjsonB64 }}"
156168
register: secretUpdateResult
157169

158170
- name: "Delete old db2 subscription, operand request and csv from {{ ibm_common_services_namespace }}"

ibm/mas_devops/roles/db2/tasks/install/setup_norootsquash.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,22 @@
1515
set_fact:
1616
new_secret: "{{ content | join('') }}"
1717

18+
1819
# 2. Generate 'ibm-registry' secret
1920
# -----------------------------------------------------------------------------
21+
# Note: We use "new_secret | to_json " because older versions of Ansible create
22+
# invalid json representations containing single quotes
23+
# However, in newer versions of Ansible to_json returns an object, which can't be passed to b64encode
24+
- name: "Generate docker secret (old Ansible versions)"
25+
when: ansible_version.full is version_compare(2.20, '<')
26+
set_fact:
27+
dockerconfigjsonB64: "{{ new_secret | to_json | b64encode }}"
28+
29+
- name: "Generate docker secret (new Ansible versions)"
30+
when: ansible_version.full is version_compare(2.20, '>=')
31+
set_fact:
32+
dockerconfigjsonB64: "{{ new_secret | b64encode }}"
33+
2034
- name: "Generate 'ibm-registry' secret"
2135
kubernetes.core.k8s:
2236
definition:
@@ -27,15 +41,17 @@
2741
name: ibm-registry
2842
namespace: kube-system
2943
data:
30-
.dockerconfigjson: "{{ new_secret | b64encode }}"
44+
.dockerconfigjson: "{{ dockerconfigjsonB64 }}"
3145
register: secretUpdateResult
3246

47+
3348
# 3. Create DaemonSet
3449
# -----------------------------------------------------------------------------
3550
- name: Create 'norootsquash' DaemonSet
3651
kubernetes.core.k8s:
3752
template: "templates/norootsquash_daemonset.yml.j2"
3853

54+
3955
# 4. Wait for 'norootsquash' DaemonSet to be running
4056
# -----------------------------------------------------------------------------
4157
- name: "Wait for 'norootsquash' DaemonSet to be running on all nodes"

0 commit comments

Comments
 (0)