Skip to content

Instantly share code, notes, and snippets.

@fenar
Created March 31, 2023 15:29
Show Gist options
  • Save fenar/7675befd1b3ac71a155fa0bf15c24e7d to your computer and use it in GitHub Desktop.
Save fenar/7675befd1b3ac71a155fa0bf15c24e7d to your computer and use it in GitHub Desktop.
Ansible playbook that can be used to claim a hibernated clusters from RH-ACM
Here is an example Ansible playbook that can be used to claim a hibernated cluster over Red Hat Advanced Cluster Manager (ACM):
---
---
- name: Claim a hibernated cluster on Red Hat ACM
hosts: localhost
gather_facts: no
vars:
acm_username: "acm-admin"
acm_password: "mypassword"
acm_server_url: "https://my-acm-server:port"
cluster_name: "my-hibernated-cluster"
tasks:
- name: Login to ACM
rhacm_login:
username: "{{ acm_username }}"
password: "{{ acm_password }}"
server_url: "{{ acm_server_url }}"
register: acm_login_result
- name: Wait for ACM login to complete
async: 3600
poll: 0
when: acm_login_result.changed
- name: Claim hibernated cluster
rhacm_cluster_claim:
state: claimed
cluster_name: "{{ cluster_name }}"
server_url: "{{ acm_server_url }}"
username: "{{ acm_username }}"
password: "{{ acm_password }}"
register: claim_result
- name: Wait for cluster to be claimed
async: 3600
poll: 0
when: claim_result.changed
- name: Display the result
debug:
var: claim_result
---
This playbook uses the rhacm_login and rhacm_cluster_claim modules provided by the Red Hat Advanced Cluster Management (RHACM) Ansible Collection. It first logs in to the ACM server using the provided username and password, then waits for the login to complete.
After logging in, the playbook claims the hibernated cluster by specifying the cluster_name and setting the state to claimed. It also provides the ACM server URL, username, and password.
Finally, the playbook displays the result of the claim operation using the debug module.
Note that you will need to have the RHACM Ansible Collection installed to use this playbook. You can install it using the following command: ansible-galaxy collection install rhacm.kubernetes. Also, make sure to replace the placeholders for acm_username, acm_password, acm_server_url, and cluster_name with your actual values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment