-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50f7c81
commit fc70d36
Showing
9 changed files
with
79 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...tall-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-entitled.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
- name: Generate add-icr-cred-to-global-pull-secret command to set global pull secret for entitled registry | ||
set_fact: | ||
_add_icr_cred_globl_pull_secret_command: "{{ lookup('template','add-icr-cred-to-global-pull-secret.j2') }} " | ||
|
||
- include_role: | ||
name: log-deployer-activity | ||
vars: | ||
_p_activity_description: "Set global pull secret for entitled registry" | ||
_p_activity_command: "{{ _add_icr_cred_globl_pull_secret_command }}" | ||
|
||
- name: Set global pull secret for entitled registry, output is in {{ status_dir }}/log/add-icr-cred-to-global-pull-secret.log | ||
shell: | | ||
{{ _add_icr_cred_globl_pull_secret_command }} | tee -a {{ status_dir }}/log/add-icr-cred-to-global-pull-secret.log | ||
when: not cpd_dry_run |
19 changes: 19 additions & 0 deletions
19
...stall-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-private.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- set_fact: | ||
_private_registry_user: "{{ _p_registry_pull_secret.split(':')[0] }}" | ||
_private_registry_pass: "{{ _p_registry_pull_secret.split(':')[1] }}" | ||
|
||
- name: Generate add-cred-to-global-pull-secret command to set global pull secret for private registry {{ _p_registry_url }} | ||
set_fact: | ||
_add_cred_globl_pull_secret_command: "{{ lookup('template','add-cred-to-global-pull-secret.j2') }} " | ||
|
||
- include_role: | ||
name: log-deployer-activity | ||
vars: | ||
_p_activity_description: "Set global pull secret for private registry {{ _p_registry_url }}" | ||
_p_activity_command: "{{ _add_cred_globl_pull_secret_command }}" | ||
|
||
- name: Set global pull secret for private registry {{ _p_registry_url }}, output is in {{ status_dir }}/log/add-cred-to-global-pull-secret.log | ||
shell: | | ||
{{ _add_cred_globl_pull_secret_command }} | tee -a {{ status_dir }}/log/add-cred-to-global-pull-secret.log | ||
when: not cpd_dry_run |
20 changes: 6 additions & 14 deletions
20
automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
--- | ||
- name: Extract the global pull secret | ||
shell: | | ||
oc extract secret/pull-secret -n openshift-config --confirm --to={{ status_dir }}/openshift | ||
- name: Set the global pull secret | ||
shell: | | ||
cat {{ status_dir }}/openshift/.dockerconfigjson | \ | ||
jq --arg registry "{{ _p_registry_url }}" \ | ||
--arg pull_secret $(echo -n "{{ _p_registry_pull_secret }}" | base64 -w0) \ | ||
'.auths += {($registry): {"auth": $pull_secret, "email": "not-used"}}' \ | ||
> {{ status_dir }}/openshift/newdockerconfigjson | ||
oc set data secret/pull-secret -n openshift-config \ | ||
--from-file=.dockerconfigjson={{ status_dir }}/openshift/newdockerconfigjson | ||
- include_tasks: apply-global-pull-secret-entitled.yml | ||
when: (_p_registry_url | default('')) == '' | ||
|
||
- name: Apply pull secret if the Machine Config Operator does not exist | ||
include_tasks: non-mco-apply-pull-secret.yml | ||
- include_tasks: apply-global-pull-secret-private.yml | ||
when: (_p_registry_url | default('')) != '' | ||
|
||
- include_tasks: non-mco-apply-pull-secret.yml | ||
when: not _mco_exists |
30 changes: 29 additions & 1 deletion
30
...s/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/non-mco-apply-pull-secret.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,33 @@ | ||
--- | ||
- set_fact: | ||
_registry_pull_secret: "cp:{{ _p_ibm_cp_entitlement_key }}" | ||
when: (_p_registry_url | default('')) == '' | ||
|
||
- set_fact: | ||
_registry_pull_secret: "{{ _p_registry_pull_secret }}" | ||
when: (_p_registry_url | default('')) != '' | ||
|
||
- include_role: | ||
name: log-deployer-activity | ||
vars: | ||
_p_activity_description: "Set global pull secret for clusters that do not have the Machine Config Operator" | ||
_p_activity_command: "# Global pull secret is applied from secret cloud-pak-node-fix-secrets in namespace kube-system" | ||
|
||
- name: Extract the global pull secret | ||
shell: | | ||
oc extract secret/pull-secret -n openshift-config --confirm --to={{ status_dir }}/openshift | ||
- name: Set the global pull secret | ||
shell: | | ||
cat {{ status_dir }}/openshift/.dockerconfigjson | \ | ||
jq --arg registry "{{ _p_registry_url }}" \ | ||
--arg pull_secret $(echo -n "{{ _registry_pull_secret }}" | base64 -w0) \ | ||
'.auths += {($registry): {"auth": $pull_secret, "email": "not-used"}}' \ | ||
> {{ status_dir }}/openshift/newdockerconfigjson | ||
oc set data secret/pull-secret -n openshift-config \ | ||
--from-file=.dockerconfigjson={{ status_dir }}/openshift/newdockerconfigjson | ||
- name: Add global pull secret to node fix secret | ||
shell: | | ||
oc set data -n kube-system secret/cloud-pak-node-fix-secrets \ | ||
--from-file=newdockerconfigjson={{ status_dir }}/openshift/newdockerconfigjson | ||
--from-file=newdockerconfigjson={{ status_dir }}/openshift/newdockerconfigjson | ||
when: not cpd_dry_run |
3 changes: 3 additions & 0 deletions
3
...tall-cloud-pak/cpfs/cp-ocp-global-pull-secret/templates/add-cred-to-global-pull-secret.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
add-cred-to-global-pull-secret --registry={{ _p_registry_url }} \ | ||
--registry_pull_user={{ _private_registry_user }} \ | ||
--registry_pull_password={{ _private_registry_pass }} |
1 change: 1 addition & 0 deletions
1
...-cloud-pak/cpfs/cp-ocp-global-pull-secret/templates/add-icr-cred-to-global-pull-secret.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add-icr-cred-to-global-pull-secret --entitled_registry_key="{{ _p_ibm_cp_entitlement_key }}" |