blob: ae2593c94bb0993f7d03ceba7115815fa77066fe [file] [log] [blame]
Mohammed Naser336caf42022-03-11 17:56:45 -05001# Copyright (c) 2022 VEXXHOST, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15heat_template_version: 2016-10-14
16
17parameters:
18 name:
19 type: string
20
21 index:
22 type: number
23
24 image:
25 type: string
26 default: Ubuntu 20.04.3 LTS (x86_64) [2021-10-04]
27 constraints:
28 - custom_constraint: glance.image
29
30 instance_type:
31 type: string
32 default: v3-standard-4
33 constraints:
34 - custom_constraint: nova.flavor
35
36 internal_network:
37 type: string
38 constraints:
39 - custom_constraint: neutron.network
40
41 key_name:
42 type: string
43 constraints:
44 - custom_constraint: nova.keypair
45
Mohammed Naser336caf42022-03-11 17:56:45 -050046 public_network:
47 type: string
48 default: public
49 constraints:
50 - custom_constraint: neutron.network
51
52 external_network:
53 type: string
54 constraints:
55 - custom_constraint: neutron.network
56
57 extra_volumes_count:
58 type: number
59 default: 0
60
61 extra_volumes_size:
62 type: number
63 default: 0
64
ricolin703b2802022-05-16 02:29:26 +080065 boot_volumes_size:
66 type: number
67 default: 40
68
69 boot_from_volume:
70 type: boolean
71 default: false
72
Mohammed Naser336caf42022-03-11 17:56:45 -050073conditions:
74 has_extra_volumes:
75 not:
76 equals:
77 - get_param: extra_volumes_count
78 - 0
79
ricolin703b2802022-05-16 02:29:26 +080080 is_boot_from_image:
81 equals:
82 - get_param: boot_from_volume
83 - false
84
85 is_boot_from_volume:
86 equals:
87 - get_param: boot_from_volume
88 - true
89
Mohammed Naser336caf42022-03-11 17:56:45 -050090resources:
91 internal_port:
92 type: OS::Neutron::Port
93 properties:
94 network: { get_param: internal_network }
95 port_security_enabled: false
96
97 floating_ip:
98 type: OS::Neutron::FloatingIP
99 properties:
100 floating_network: { get_param: public_network }
101 port_id: { get_resource: internal_port }
102
103 external_port:
104 type: OS::Neutron::Port
105 properties:
106 network: { get_param: external_network }
okozachenko87131922022-04-09 01:04:53 +1000107 port_security_enabled: false
Mohammed Naser336caf42022-03-11 17:56:45 -0500108
ricolin703b2802022-05-16 02:29:26 +0800109 server_boot_from_image:
Mohammed Naser336caf42022-03-11 17:56:45 -0500110 type: OS::Nova::Server
ricolin703b2802022-05-16 02:29:26 +0800111 condition: is_boot_from_image
Mohammed Naser336caf42022-03-11 17:56:45 -0500112 properties:
113 name:
114 yaql:
ricolin1139bb02023-03-21 23:45:40 +0800115 expression: concat($.data.name, str($.data.index + 1)).replace("0", "")
Mohammed Naser336caf42022-03-11 17:56:45 -0500116 data:
117 name: { get_param: name }
118 index: { get_param: index }
119 image: { get_param: image }
120 flavor: { get_param: instance_type }
121 key_name: { get_param: key_name }
Michiel Piscaer97b7fd32022-03-17 12:15:21 +0100122 config_drive: true
Mohammed Naser336caf42022-03-11 17:56:45 -0500123 networks:
124 - port: { get_resource: internal_port }
125 - port: { get_resource: external_port }
126
ricolin703b2802022-05-16 02:29:26 +0800127 server_boot_from_volume:
128 type: OS::Nova::Server
129 condition: is_boot_from_volume
130 properties:
131 name:
132 yaql:
133 expression: concat($.data.name, str($.data.index + 1))
134 data:
135 name: { get_param: name }
136 index: { get_param: index }
137 flavor: { get_param: instance_type }
138 key_name: { get_param: key_name }
139 config_drive: true
140 networks:
141 - port: { get_resource: internal_port }
142 - port: { get_resource: external_port }
143 block_device_mapping_v2:
144 - boot_index: 0
145 volume_id: {get_resource: volume}
146 delete_on_termination: true
147
148 volume:
149 type: OS::Cinder::Volume
150 condition: is_boot_from_volume
151 properties:
152 size: { get_param: boot_volumes_size }
153 image: { get_param: image }
154
Mohammed Naser336caf42022-03-11 17:56:45 -0500155 volumes:
156 type: OS::Heat::ResourceGroup
157 condition: has_extra_volumes
158 properties:
159 count: { get_param: extra_volumes_count }
160 resource_def:
161 type: volume.yaml
162 properties:
ricolin703b2802022-05-16 02:29:26 +0800163 instance_uuid: {if: ["is_boot_from_volume", { get_resource: server_boot_from_volume }, { get_resource: server_boot_from_image } ]}
Mohammed Naser336caf42022-03-11 17:56:45 -0500164 volume_size: { get_param: extra_volumes_size }
165
166outputs:
167 floating_ip_address:
168 value: { get_attr: [floating_ip, floating_ip_address] }