-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprovision_vm.yaml
More file actions
197 lines (176 loc) · 5.99 KB
/
Copy pathprovision_vm.yaml
File metadata and controls
197 lines (176 loc) · 5.99 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
---
version: '2.0'
provision_jupyterhub_vm:
description: >
Provisions a VM on the EOSC EU Node (PSNC) complete with a private network,
subnet, router gateway to PSNC-EXT-PUB1-EDU, and an assigned floating IP.
Assumes a keypair has already been imported into the project.
input:
- instance_name: "JupyterHub"
- instance_description: "JupyterHub VM"
- image_name: "ubuntu-24.04"
- flavor_name: "C1-NVME-16vCPU-64R-100D"
- network_name: "jupyterhub-net"
- subnet_name: "jupyterhub-subnet"
- subnet_cidr: "10.10.40.0/24"
- router_name: "jupyterhub-router"
- external_network_name: "PSNC-EXT-PUB1-EDU"
- keypair_name: "my-keypair"
- dns_nameservers:
- "1.1.1.1"
- "1.0.0.1"
output:
instance_id: <% $.instance_id %>
private_ip: <% $.private_ip %>
floating_ip: <% $.floating_ip %>
tasks:
# ------------------------------------------------------------------
# 1. Resolve resource IDs from human-readable names
# ------------------------------------------------------------------
get_external_network:
description: Look up the external network ID by name.
action: neutron.list_networks
input:
name: <% $.external_network_name %>
publish:
external_network_id: <% task().result.networks[0].id %>
on-success:
- get_image
get_image:
description: Look up the image ID by name.
action: glance.images_list
input:
filters:
name: <% $.image_name %>
publish:
image_id: <% task().result[0].id %>
on-success:
- get_flavor
get_flavor:
description: Look up the flavour ID by name.
action: nova.flavors_find
input:
name: <% $.flavor_name %>
publish:
flavor_id: <% task().result.id %>
on-success:
- create_network
# ------------------------------------------------------------------
# 2. Create private network and subnet
# ------------------------------------------------------------------
create_network:
description: Create the private tenant network.
action: neutron.create_network
input:
body:
network:
name: <% $.network_name %>
admin_state_up: true
publish:
network_id: <% task().result.network.id %>
on-success:
- create_subnet
create_subnet:
description: Create a subnet on the private network with DHCP and DNS.
action: neutron.create_subnet
input:
body:
subnet:
name: <% $.subnet_name %>
network_id: <% $.network_id %>
ip_version: 4
cidr: <% $.subnet_cidr %>
enable_dhcp: true
dns_nameservers: <% $.dns_nameservers %>
publish:
subnet_id: <% task().result.subnet.id %>
on-success:
- create_router
# ------------------------------------------------------------------
# 3. Create router and attach subnet
# ------------------------------------------------------------------
create_router:
description: Create a router with PSNC-EXT-PUB1-EDU as the external gateway.
action: neutron.create_router
input:
body:
router:
name: <% $.router_name %>
admin_state_up: true
external_gateway_info:
network_id: <% $.external_network_id %>
publish:
router_id: <% task().result.router.id %>
on-success:
- add_router_interface
add_router_interface:
description: Attach the private subnet to the router.
action: neutron.add_interface_router
input:
router: <% $.router_id %>
body:
subnet_id: <% $.subnet_id %>
on-success:
- create_instance
# ------------------------------------------------------------------
# 4. Launch the instance
# ------------------------------------------------------------------
create_instance:
description: Launch the VM on the private network.
action: nova.servers_create
input:
name: <% $.instance_name %>
description: <% $.instance_description %>
image: <% $.image_id %>
flavor: <% $.flavor_id %>
key_name: <% $.keypair_name %>
nics:
- net-id: <% $.network_id %>
publish:
instance_id: <% task().result.id %>
on-success:
- wait_for_instance
wait_for_instance:
description: Poll until the instance reaches ACTIVE status.
action: nova.servers_find
input:
id: <% $.instance_id %>
status: ACTIVE
retry:
delay: 10
count: 30
publish:
private_ip: <% task().result.addresses.values().first().first().addr %>
on-success:
- get_instance_port
on-error:
- fail_instance
fail_instance:
description: Fail the workflow explicitly if the instance never reaches ACTIVE.
action: std.fail
input:
msg: "Instance <% $.instance_id %> did not reach ACTIVE within the polling window."
# ------------------------------------------------------------------
# 5. Allocate and associate a floating IP
# ------------------------------------------------------------------
get_instance_port:
description: Find the neutron port associated with the instance on the private network.
action: neutron.list_ports
input:
device_id: <% $.instance_id %>
network_id: <% $.network_id %>
publish:
port_id: <% task().result.ports[0].id %>
on-success:
- allocate_floating_ip
allocate_floating_ip:
description: Allocate a floating IP from the external network pool.
action: neutron.create_floatingip
input:
body:
floatingip:
floating_network_id: <% $.external_network_id %>
port_id: <% $.port_id %>
publish:
floating_ip: <% task().result.floatingip.floating_ip_address %>
floatingip_id: <% task().result.floatingip.id %>