github.com/openshift/installer@v1.4.17/upi/openstack/control-plane.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 Control Plane ports' 15 openstack.cloud.port: 16 name: "{{ item.1 }}-{{ item.0 }}" 17 network: "{{ os_network }}" 18 security_groups: 19 - "{{ os_sg_master }}" 20 allowed_address_pairs: 21 - ip_address: "{{ os_apiVIP }}" 22 - ip_address: "{{ os_ingressVIP }}" 23 with_indexed_items: "{{ [os_port_master] * os_cp_nodes_number }}" 24 register: ports 25 when: os_subnet6_range is not defined 26 27 - name: 'Create the dualstack Control Plane ports' 28 openstack.cloud.port: 29 name: "{{ item.1 }}-{{ item.0 }}" 30 network: "{{ os_network }}" 31 security_groups: 32 - "{{ os_sg_master }}" 33 allowed_address_pairs: 34 - ip_address: "{{ os_apiVIP }}" 35 - ip_address: "{{ os_apiVIP6 }}" 36 - ip_address: "{{ os_ingressVIP }}" 37 - ip_address: "{{ os_ingressVIP6 }}" 38 with_indexed_items: "{{ [os_port_master] * os_cp_nodes_number }}" 39 register: ports 40 when: os_subnet6_range is defined 41 42 - name: 'Set Control Plane ports tag' 43 ansible.builtin.command: 44 cmd: "openstack port set --tag {{ cluster_id_tag }} {{ item.1 }}-{{ item.0 }}" 45 with_indexed_items: "{{ [os_port_master] * os_cp_nodes_number }}" 46 47 - name: 'List the Server groups' 48 ansible.builtin.command: 49 # os-compute-api-version 2.15 or higher is required for the 'soft-anti-affinity' policy 50 cmd: "openstack --os-compute-api-version=2.15 server group list -f json -c ID -c Name" 51 register: server_group_list 52 53 - name: 'Parse the Server group ID from existing' 54 ansible.builtin.set_fact: 55 server_group_id: "{{ (server_group_list.stdout | from_json | json_query(list_query) | first).ID }}" 56 vars: 57 list_query: "[?Name=='{{ os_cp_server_group_name }}']" 58 when: 59 - "os_cp_server_group_name|string in server_group_list.stdout" 60 61 - name: 'Create the Control Plane server group' 62 ansible.builtin.command: 63 # os-compute-api-version 2.15 or higher is required for the 'soft-anti-affinity' policy 64 cmd: "openstack --os-compute-api-version=2.15 server group create -f json -c id --policy=soft-anti-affinity {{ os_cp_server_group_name }}" 65 register: server_group_created 66 when: 67 - server_group_id is not defined 68 69 - name: 'Parse the Server group ID from creation' 70 ansible.builtin.set_fact: 71 server_group_id: "{{ (server_group_created.stdout | from_json).id }}" 72 when: 73 - server_group_id is not defined 74 75 - name: 'Create the Control Plane servers' 76 openstack.cloud.server: 77 name: "{{ item.1 }}-{{ item.0 }}" 78 image: "{{ os_image_rhcos }}" 79 flavor: "{{ os_flavor_master }}" 80 auto_ip: no 81 # The ignition filename will be concatenated with the Control Plane node 82 # name and its 0-indexed serial number. 83 # In this case, the first node will look for this filename: 84 # "{{ infraID }}-master-0-ignition.json" 85 userdata: "{{ lookup('file', [item.1, item.0, 'ignition.json'] | join('-')) | string }}" 86 nics: 87 - port-name: "{{ os_port_master }}-{{ item.0 }}" 88 scheduler_hints: 89 group: "{{ server_group_id }}" 90 meta: "{{ cluster_id_tag }}" 91 with_indexed_items: "{{ [os_cp_server_name] * os_cp_nodes_number }}"