diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index 72447e5..0f7e630 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false diff --git a/.github/workflows/ansible-sanitytest.yml b/.github/workflows/ansible-sanitytest.yml index d2be96f..9c1de6f 100644 --- a/.github/workflows/ansible-sanitytest.yml +++ b/.github/workflows/ansible-sanitytest.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: path: ansible_collections/rhvp/cluster_utils persist-credentials: false diff --git a/.github/workflows/ansible-unittest.yml b/.github/workflows/ansible-unittest.yml index fa9f1fd..2a176ec 100644 --- a/.github/workflows/ansible-unittest.yml +++ b/.github/workflows/ansible-unittest.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: path: ansible_collections/rhvp/cluster_utils persist-credentials: false diff --git a/.github/workflows/jsonschema.yaml b/.github/workflows/jsonschema.yaml index 80a3433..a55b3d8 100644 --- a/.github/workflows/jsonschema.yaml +++ b/.github/workflows/jsonschema.yaml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false diff --git a/.github/workflows/superlinter.yml b/.github/workflows/superlinter.yml index 9492da0..c88cb8c 100644 --- a/.github/workflows/superlinter.yml +++ b/.github/workflows/superlinter.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: # Full git history is needed to get a proper list of changed files within `super-linter` fetch-depth: 0 diff --git a/roles/uninstall_pattern/defaults/main.yml b/roles/uninstall_pattern/defaults/main.yml index 62bd157..a699baf 100644 --- a/roles/uninstall_pattern/defaults/main.yml +++ b/roles/uninstall_pattern/defaults/main.yml @@ -5,3 +5,9 @@ uninstall_wait_timeout: | | default("3600", true) | int }} + +patterns_operator_namespace: >- + {{ + lookup("env", "PATTERNS_OPERATOR_NAMESPACE") + | default("patterns-operator", true) + }} diff --git a/roles/uninstall_pattern/tasks/main.yml b/roles/uninstall_pattern/tasks/main.yml index 6a50b35..5558fa5 100644 --- a/roles/uninstall_pattern/tasks/main.yml +++ b/roles/uninstall_pattern/tasks/main.yml @@ -4,7 +4,7 @@ api_version: gitops.hybrid-cloud-patterns.io/v1alpha1 kind: Pattern name: "{{ pattern_name }}" - namespace: openshift-operators + namespace: "{{ patterns_operator_namespace }}" register: pattern_info - name: Check that the pattern '{{ pattern_name }}' is present on the cluster @@ -15,10 +15,25 @@ can only be run on hub clusters, where the pattern CR and patterns operator are present, in patterns with both hub and spoke components. -- name: Fetch the pods in the openshift-operators namespace +- name: Ensure prune annotation is set on pattern CR + kubernetes.core.k8s: + state: present + api_version: gitops.hybrid-cloud-patterns.io/v1alpha1 + kind: Pattern + name: "{{ pattern_name }}" + namespace: "{{ patterns_operator_namespace }}" + definition: + metadata: + annotations: + patterns.gitops.hybrid-cloud-patterns.io/prune: "true" + when: >- + (pattern_info.resources[0].metadata.annotations | default({})) + .get('patterns.gitops.hybrid-cloud-patterns.io/prune', '') != 'true' + +- name: Fetch the pods in the {{ patterns_operator_namespace }} namespace kubernetes.core.k8s_info: kind: Pod - namespace: openshift-operators + namespace: "{{ patterns_operator_namespace }}" register: pod_list - name: Find the patterns operator controller pod @@ -29,7 +44,7 @@ ansible.builtin.assert: that: patterns_operator_pod_name != '' fail_msg: | - Could not find the patterns operator controller manager pod in the 'openshift-operators' namespace. Please ensure that the patterns + Could not find the patterns operator controller manager pod in the '{{ patterns_operator_namespace }}' namespace. Please ensure that the patterns operator is currently running in your cluster. - name: Print user-friendly uninstall message @@ -40,9 +55,9 @@ only the pattern will be removed, to facilitate easy reinstall of this pattern or other patterns. This command will wait for up to {{ uninstall_wait_timeout }} seconds while the pattern is uninstalled. To view deletion progress, you can check the logs of the '{{ patterns_operator_pod_name }}' pod - pod in the 'openshift-operators' namespace with the command: + pod in the '{{ patterns_operator_namespace }}' namespace with the command: - oc logs -f --tail=50 -n openshift-operators {{ patterns_operator_pod_name }} + oc logs -f --tail=50 -n {{ patterns_operator_namespace }} {{ patterns_operator_pod_name }} - name: Delete pattern from cluster kubernetes.core.k8s: @@ -50,6 +65,6 @@ api_version: gitops.hybrid-cloud-patterns.io/v1alpha1 kind: Pattern name: "{{ pattern_name }}" - namespace: openshift-operators + namespace: "{{ patterns_operator_namespace }}" wait: true wait_timeout: "{{ uninstall_wait_timeout }}"