forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compute-nodes.yaml
84 lines (74 loc) · 2.91 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Required Python packages:
#
# ansible
# openstackclient
# openstacksdk
# netaddr
- ansible.builtin.import_playbook: common.yaml
- hosts: all
gather_facts: no
tasks:
- name: 'Create the Compute ports'
openstack.cloud.port:
name: "{{ item.1 }}-{{ item.0 }}"
network: "{{ os_network }}"
security_groups:
- "{{ os_sg_worker }}"
allowed_address_pairs:
- ip_address: "{{ os_ingressVIP }}"
with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"
register: ports
when: os_subnet6 is not defined
- name: 'Create the dualstack Compute ports'
openstack.cloud.port:
name: "{{ item.1 }}-{{ item.0 }}"
network: "{{ os_network }}"
security_groups:
- "{{ os_sg_worker }}"
allowed_address_pairs:
- ip_address: "{{ os_ingressVIP }}"
- ip_address: "{{ os_ingressVIP6 }}"
with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"
register: ports
when: os_subnet6 is defined
- name: 'Set Compute ports tag'
ansible.builtin.command:
cmd: "openstack port set --tag {{ cluster_id_tag }} {{ item.1 }}-{{ item.0 }}"
with_indexed_items: "{{ [os_port_worker] * 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: 'Create 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 create -f json -c id --policy=soft-anti-affinity {{ os_compute_server_group_name }}"
register: server_group_created
when:
- server_group_id is not defined
- name: 'Parse the Server group ID from creation'
ansible.builtin.set_fact:
server_group_id: "{{ (server_group_created.stdout | from_json).id }}"
when:
- server_group_id is not defined
- name: 'Create the Compute servers'
openstack.cloud.server:
name: "{{ item.1 }}-{{ item.0 }}"
image: "{{ os_image_rhcos }}"
flavor: "{{ os_flavor_worker }}"
auto_ip: no
userdata: "{{ lookup('file', 'worker.ign') | string }}"
nics:
- port-name: "{{ os_port_worker }}-{{ item.0 }}"
scheduler_hints:
group: "{{ server_group_id }}"
meta: "{{ cluster_id_tag }}"
with_indexed_items: "{{ [os_compute_server_name] * os_compute_nodes_number }}"