Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split install and cleanup tasks for ACM #79

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: ''

Check failure on line 2 in roles/advanced_cluster_management/defaults/main.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint on PR

var-naming[no-role-prefix]

Variables names from within roles should use advanced_cluster_management_ as a prefix. (vars: 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
ansible.builtin.include_tasks: cleanup.yml
when: role_mode == 'cleanup' or role_mode == ''
tags:
- cleanup
Loading