Skip to content

Commit

Permalink
Merge pull request #344 from redhatci/ztp-minor-refactor
Browse files Browse the repository at this point in the history
ZTP | Create OCP pull secret from hub cluster, refactor of some code
  • Loading branch information
ramperher authored Jun 14, 2024
2 parents 6383ff9 + 2b04b74 commit b6cba4d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
42 changes: 36 additions & 6 deletions roles/configure_ztp_gitops_apps/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,15 @@
replace: "{{ czga_policies_namespace }}"

- name: Add namespace to the policies-app-project.yaml
ansible.builtin.lineinfile:
ansible.builtin.blockinfile:
path: "{{ temp_dir.path }}/ztp/argocd/deployment/policies-app-project.yaml"
line: "{{ item }}"
block: |
{% filter indent(width=2, first=true) %}
- namespace: '{{ czga_policies_namespace }}'
server: '*'
{% endfilter %}
insertafter: destinations.*
loop:
- " - namespace: '{{ czga_policies_namespace }}'"
- " server: '*'"
marker: ""

- name: Replace path in policies-app.yaml
ansible.builtin.replace:
Expand All @@ -133,7 +135,6 @@
line: " allowEmpty: true"
insertafter: selfHeal.*


## Add adaptation due to https://issues.redhat.com/browse/CNF-7840
## based on https://redhat-internal.slack.com/archives/C02EG99MR9C/p1679006883470389?thread_ts=1678887461.410819&cid=C02EG99MR9C
- name: Add ClusterImageSet to the app-project.yaml
Expand Down Expand Up @@ -174,6 +175,35 @@
- merge
definition: "{{ lookup('file', temp_dir.path + '/ztp/argocd/deployment/disable-cluster-proxy-addon.json') | from_json }}"

# Before launching the SiteConfig, provide the OCP pull secret extracted from the hub cluster
# For this, we need to create the cluster namespace in advance
- name: Create the Spoke cluster namespace
community.kubernetes.k8s:
definition:
apiVersion: v1
kind: Namespace
metadata:
name: "{{ czga_clusters_namespace }}"

- name: Save pull-secret in a variable
ansible.builtin.slurp:
src: "{{ temp_dir.path }}/temp-pull-secret.json"
register: _czga_encoded_pull_secret
no_log: true

- name: Create the Spoke cluster pull-secret
community.kubernetes.k8s:
definition:
apiVersion: v1
kind: Secret
metadata:
name: assisted-deployment-pull-secret
namespace: "{{ czga_clusters_namespace }}"
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: "{{ _czga_encoded_pull_secret['content'] }}"
no_log: true

- name: Run the policies and cluster apps
ansible.builtin.shell: |
{{ czga_oc_tool_path }} --kubeconfig="{{ temp_dir.path }}/kubeconfig" apply -k "{{ temp_dir.path }}/ztp/argocd/deployment"
Expand Down
8 changes: 5 additions & 3 deletions roles/gitops_configure_repo/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- gcr_ztp_gitops_repo is defined
- gcr_ztp_gitops_repo | length > 0

- name: Add Git repository SSH key to argoCD
- name: Add ssh_known_hosts to ArgoCD
community.kubernetes.k8s:
api_version: v1
kind: ConfigMap
Expand All @@ -19,9 +19,11 @@
app.kubernetes.io/name: argocd-cm
app.kubernetes.io/part-of: argocd
data:
gcr_ssh_known_hosts: |
ssh_known_hosts: |
{{ gcr_ssh_known_hosts }}
when: gcr_ssh_known_hosts is defined
when:
- gcr_ssh_known_hosts is defined
- gcr_ssh_known_hosts | length > 0
no_log: true

- name: Register key
Expand Down

0 comments on commit b6cba4d

Please sign in to comment.