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

     1  # Required Python packages:
     2  #
     3  # ansible
     4  # openstackclient
     5  # openstacksdk
     6  # netaddr
     7  
     8  - ansible.builtin.import_playbook: common.yaml
     9  
    10  - hosts: all
    11    gather_facts: no
    12  
    13    tasks:
    14    - name: 'Create the Compute ports'
    15      openstack.cloud.port:
    16        name: "{{ item.1 }}-{{ item.0 }}"
    17        network: "{{ os_network }}"
    18        security_groups:
    19        - "{{ os_sg_worker }}"
    20        allowed_address_pairs:
    21        - ip_address: "{{ os_ingressVIP }}"
    22      with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"
    23      register: ports
    24      when: os_subnet6_range is not defined
    25  
    26    - name: 'Create the dualstack Compute ports'
    27      openstack.cloud.port:
    28        name: "{{ item.1 }}-{{ item.0 }}"
    29        network: "{{ os_network }}"
    30        security_groups:
    31        - "{{ os_sg_worker }}"
    32        allowed_address_pairs:
    33        - ip_address: "{{ os_ingressVIP }}"
    34        - ip_address: "{{ os_ingressVIP6 }}"
    35      with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"
    36      register: ports
    37      when: os_subnet6_range is defined
    38  
    39    - name: 'Set Compute ports tag'
    40      ansible.builtin.command:
    41        cmd: "openstack port set --tag {{ cluster_id_tag }} {{ item.1 }}-{{ item.0 }}"
    42      with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"
    43  
    44    - name: 'List the Server groups'
    45      ansible.builtin.command:
    46        # os-compute-api-version 2.15 or higher is required for the 'soft-anti-affinity' policy
    47        cmd: "openstack --os-compute-api-version=2.15 server group list -f json -c ID -c Name"
    48      register: server_group_list
    49  
    50    - name: 'Parse the Server group ID from existing'
    51      ansible.builtin.set_fact:
    52        server_group_id: "{{ (server_group_list.stdout | from_json | json_query(list_query) | first).ID }}"
    53      vars:
    54        list_query: "[?Name=='{{ os_compute_server_group_name }}']"
    55      when:
    56      - "os_compute_server_group_name|string in server_group_list.stdout"
    57  
    58    - name: 'Create the Compute server group'
    59      ansible.builtin.command:
    60        # os-compute-api-version 2.15 or higher is required for the 'soft-anti-affinity' policy
    61        cmd: "openstack --os-compute-api-version=2.15 server group create -f json -c id --policy=soft-anti-affinity {{ os_compute_server_group_name }}"
    62      register: server_group_created
    63      when:
    64      - server_group_id is not defined
    65  
    66    - name: 'Parse the Server group ID from creation'
    67      ansible.builtin.set_fact:
    68        server_group_id: "{{ (server_group_created.stdout | from_json).id }}"
    69      when:
    70      - server_group_id is not defined
    71  
    72    - name: 'Create the Compute servers'
    73      openstack.cloud.server:
    74        name: "{{ item.1 }}-{{ item.0 }}"
    75        image: "{{ os_image_rhcos }}"
    76        flavor: "{{ os_flavor_worker }}"
    77        auto_ip: no
    78        userdata: "{{ lookup('file', 'worker.ign') | string }}"
    79        nics:
    80        - port-name: "{{ os_port_worker }}-{{ item.0 }}"
    81        scheduler_hints:
    82          group: "{{ server_group_id }}"
    83        meta: "{{ cluster_id_tag }}"
    84      with_indexed_items: "{{ [os_compute_server_name] * os_compute_nodes_number }}"