github.com/openshift/installer@v1.4.17/upi/openstack/down-compute-nodes.yaml (about)

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