forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
down-compute-nodes.yaml
44 lines (37 loc) · 1.47 KB
/
down-compute-nodes.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Required Python packages:
#
# ansible
# openstackclient
# openstacksdk
- ansible.builtin.import_playbook: common.yaml
- hosts: all
gather_facts: no
tasks:
- name: 'Remove the Compute servers'
openstack.cloud.server:
name: "{{ item.1 }}-{{ item.0 }}"
state: absent
with_indexed_items: "{{ [os_compute_server_name] * os_compute_nodes_number }}"
- name: 'List the Server groups'
ansible.builtin.command:
# os-compute-api-version 2.15 or higher is required for the 'soft-anti-affinity' policy
cmd: "openstack --os-compute-api-version=2.15 server group list -f json -c ID -c Name"
register: server_group_list
- name: 'Parse the Server group ID from existing'
ansible.builtin.set_fact:
server_group_id: "{{ (server_group_list.stdout | from_json | json_query(list_query) | first).ID }}"
vars:
list_query: "[?Name=='{{ os_compute_server_group_name }}']"
when:
- "os_compute_server_group_name|string in server_group_list.stdout"
- name: 'Remove the Compute server group'
ansible.builtin.command:
# os-compute-api-version 2.15 or higher is required for the 'soft-anti-affinity' policy
cmd: "openstack --os-compute-api-version=2.15 server group delete {{ server_group_id }}"
when:
- server_group_id is defined
- name: 'Remove the Compute ports'
openstack.cloud.port:
name: "{{ item.1 }}-{{ item.0 }}"
state: absent
with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"