Skip to content

Commit

Permalink
Split install and cleanup tasks for ACM
Browse files Browse the repository at this point in the history
This is a PoC for splitting out the install and cleanup tasks. This
should be a backward-compatible change. If no role_mode is specified
then the default mode is to just run the assessment as it was before.

Signed-off-by: Brad P. Crochet <[email protected]>
  • Loading branch information
bcrochet committed Nov 14, 2023
1 parent 8e0ece6 commit 2037d8e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 48 deletions.
2 changes: 2 additions & 0 deletions roles/advanced_cluster_management/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
install_mode: ''
17 changes: 17 additions & 0 deletions roles/advanced_cluster_management/tasks/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Clean up operand
kubernetes.core.k8s:
state: absent
api_version: operator.open-cluster-management.io/v1
kind: MultiClusterHub
name: multiclusterhub
namespace: "open-cluster-management"
wait: true
wait_sleep: 30
wait_timeout: 600
- name: Delete open-cluster-management namespace
kubernetes.core.k8s:
name: open-cluster-management
api_version: v1
kind: Namespace
state: absent
33 changes: 33 additions & 0 deletions roles/advanced_cluster_management/tasks/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
- name: Install and report
block:
- name: Create open-cluster-management namespace
kubernetes.core.k8s:
name: open-cluster-management
api_version: v1
kind: Namespace
state: present
- name: Create multiclusterhub CR in target_namespace and wait
kubernetes.core.k8s:
state: present
namespace: "open-cluster-management"
definition:
apiVersion: operator.open-cluster-management.io/v1
kind: MultiClusterHub
metadata:
name: multiclusterhub
spec:
disableHubSelfManagement: true
availabilityConfig: Basic
wait: true
wait_condition:
reason: ComponentsAvailable
status: 'True'
type: Complete
wait_sleep: 30
wait_timeout: 600
register: acm_result
always:
- name: Report result
ansible.builtin.set_fact:
assessment_result: "{{ 'pass' if (acm_result.result.status.phase is defined and acm_result.result.status.phase == 'Running') else 'fail' }}"
59 changes: 11 additions & 48 deletions roles/advanced_cluster_management/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,12 @@
---
- name: Install and report
block:
- name: Create open-cluster-management namespace
kubernetes.core.k8s:
name: open-cluster-management
api_version: v1
kind: Namespace
state: present
- name: Create multiclusterhub CR in target_namespace and wait
kubernetes.core.k8s:
state: present
namespace: "open-cluster-management"
definition:
apiVersion: operator.open-cluster-management.io/v1
kind: MultiClusterHub
metadata:
name: multiclusterhub
spec:
disableHubSelfManagement: true
availabilityConfig: Basic
wait: true
wait_condition:
reason: ComponentsAvailable
status: 'True'
type: Complete
wait_sleep: 30
wait_timeout: 600
register: acm_result
always:
- name: Report result
ansible.builtin.set_fact:
assessment_result: "{{ 'pass' if (acm_result.result.status.phase is defined and acm_result.result.status.phase == 'Running') else 'fail' }}"
- name: Clean up operand
kubernetes.core.k8s:
state: absent
api_version: operator.open-cluster-management.io/v1
kind: MultiClusterHub
name: multiclusterhub
namespace: "open-cluster-management"
wait: true
wait_sleep: 30
wait_timeout: 600
- name: Delete open-cluster-management namespace
kubernetes.core.k8s:
name: open-cluster-management
api_version: v1
kind: Namespace
state: absent
- name: Install and assess operand
ansible.builtin.include_tasks: install.yml
when: role_mode == 'install' or role_mode == ''
tags:
- install

- name: Cleanup operator

Check failure on line 8 in roles/advanced_cluster_management/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint on PR

syntax-check[specific]

this task 'ansible.builint.include_tasks' has extra params, which is only allowed in the following modules: include_role, ansible.legacy.include, ansible.builtin.win_shell, command, include, ansible.builtin.set_fact, set_fact, ansible.builtin.include_vars, raw, ansible.legacy.group_by, ansible.legacy.win_command, include_vars, import_role, ansible.legacy.add_host, ansible.legacy.set_fact, ansible.windows.win_shell, ansible.legacy.shell, ansible.legacy.command, import_tasks, ansible.builtin.raw, ansible.legacy.include_vars, ansible.legacy.meta, win_command, ansible.builtin.import_role, ansible.builtin.import_tasks, ansible.legacy.include_role, ansible.legacy.script, ansible.builtin.win_command, ansible.legacy.win_shell, add_host, ansible.legacy.import_tasks, ansible.builtin.include, meta, ansible.builtin.command, ansible.legacy.import_role, ansible.builtin.include_tasks, win_shell, ansible.builtin.include_role, ansible.builtin.add_host, ansible.builtin.meta, script, ansible.legacy.include_tasks, ansible.windows.win_command, ansible.legacy.raw, shell, ansible.builtin.shell, include_tasks, ansible.builtin.script, group_by, ansible.builtin.group_by
ansible.builint.include_tasks: cleanup.yml
when: role_mode == 'cleanup' or role_mode == ''
tags:
- cleanup

0 comments on commit 2037d8e

Please sign in to comment.