-
Notifications
You must be signed in to change notification settings - Fork 5
/
create_headnode.yml
96 lines (81 loc) · 2.97 KB
/
create_headnode.yml
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
85
86
87
88
89
90
91
92
93
94
95
96
---
- hosts: localhost
gather_facts: false
vars_files:
- vars/main.yml
tasks:
- name: Create cluster private network
os_network:
name: "{{ cluster_network_name }}"
state: present
- name: Create subnet for cluster network
os_subnet:
name: "{{ cluster_network_name }}"
network_name: "{{ cluster_network_name }}"
cidr: "{{ cluster_network_cidr }}"
allocation_pool_start: "{{ cluster_network_allocation_pool_start }}"
allocation_pool_end: "{{ cluster_network_allocation_pool_end }}"
dns_nameservers: "{{ cluster_network_dns_servers }}"
state: present
- name: Create a router to connect cluster network to internet
os_router:
name: "{{ cluster_network_router }}"
admin_state_up: true
network: "public"
interfaces:
- "{{ cluster_network_name }}"
state: present
- name: Create security group for the cluster
openstack.cloud.security_group:
name: "{{ cluster_security_group }}"
description: "Security Group for {{ cluster_name }}"
state: present
- name: Add security group access rule to allow ssh
openstack.cloud.security_group_rule:
security_group: "{{ cluster_security_group }}"
port_range_min: 22
port_range_max: 22
protocol: tcp
remote_ip_prefix: "{{ cluster_network_ssh_access }}"
state: present
- name: Add security group access rule to allow access within group
openstack.cloud.security_group_rule:
security_group: "{{ cluster_security_group }}"
protocol: any
remote_group: "{{ cluster_security_group }}"
state: present
- name: Add ssh keypair
os_keypair:
name: "{{ keypair_name }}"
public_key_file: "{{ ssh_public_keyfile }}"
state: present
- name: Create boot volume for head node
os_volume:
name: "{{ head_node_volume }}"
image: "{{ image_name }}"
bootable: true
size: "{{ head_node_disk_size_gb }}"
state: present
- name: Launch cluster head node instance
os_server:
name: "{{ head_node_name }}"
boot_volume: "{{ head_node_volume }}"
flavor: "{{ head_node_flavor }}"
key_name: "{{ keypair_name }}"
network: "{{ cluster_network_name }}"
auto_ip: true
security_groups: "{{ cluster_security_group }}"
state: present
- name: Add head node to inventory
import_tasks: tasks/add_headnode_inventory.yml
- debug:
msg: "{{ cluster_name }} head node is launched at {{ hostvars['localhost'].headnode.openstack_servers[0].accessIPv4 }}"
- hosts: headnode
gather_facts: false
vars_files:
- ./vars/main.yml
tasks:
- name: wait for head node to boot and become reachable
wait_for_connection:
- debug:
msg: "{{ cluster_name }} head node is up at {{ hostvars['localhost'].headnode.openstack_servers[0].accessIPv4 }}."