Terraform resources for a Kubernetes lab
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

64 lines
1.8 KiB

- name: Stop the OpenShift cluster
hosts: localhost
gather_facts: no
become: no
vars:
lb: '{{ nodes | selectattr("role", "eq", "lb") | first }}'
storage: '{{ nodes | selectattr("role", "eq", "storage") | first }}'
workers: '{{ nodes | selectattr("role", "eq", "worker") | list }}'
masters: '{{ nodes | selectattr("role", "eq", "master") | list }}'
tasks:
- name: Stop the workers
community.libvirt.virt:
name: '{{ item.name }}'
state: shutdown
uri: '{{ lookup("env", "LIBVIRT_DEFAULT_URI") }}'
loop: '{{ workers }}'
loop_control:
label: "{{ item.name }}"
- name: Wait for the workers to shutdown
community.libvirt.virt:
name: '{{ item.name }}'
command: info
uri: '{{ lookup("env", "LIBVIRT_DEFAULT_URI") }}'
register: vm
until: "vm[item.name].state == 'shutdown'"
retries: 48
delay: 5
loop: '{{ workers }}'
loop_control:
label: "{{ item.name }}"
- name: Stop the masters
community.libvirt.virt:
name: '{{ item.name }}'
state: shutdown
uri: '{{ lookup("env", "LIBVIRT_DEFAULT_URI") }}'
loop: '{{ masters }}'
loop_control:
label: "{{ item.name }}"
- name: Wait for the masters to shutdown
community.libvirt.virt:
name: '{{ item.name }}'
command: info
uri: '{{ lookup("env", "LIBVIRT_DEFAULT_URI") }}'
register: vm
until: "vm[item.name].state == 'shutdown'"
retries: 48
delay: 5
loop: '{{ masters }}'
loop_control:
label: "{{ item.name }}"
- name: Stop the remaining nodes
community.libvirt.virt:
name: '{{ item.name }}'
state: shutdown
uri: '{{ lookup("env", "LIBVIRT_DEFAULT_URI") }}'
loop:
- '{{ lb }}'
- '{{ storage }}'
loop_control:
label: "{{ item.name }}"