blob: 199d10dc675267719bc2c739799f85d97c312f5a [file] [log] [blame]
Anton Samoylov17e7c032024-10-14 23:55:18 +04001heat_template_version: queens
2
3parameters:
4
5 k8s_network:
6 type: string
7 k8s_subnet_id:
8 type: string
9 public_net_id:
10 type: string
11 data_network:
12 type: string
13 storage_frontend_network:
14 type: string
15 storage_backend_network:
16 type: string
17 availability_zone:
18 type: string
19 default: nova
20 boot_timeout:
21 type: number
22 description: Boot timeout for instance
23 default: 600
24 image:
25 type: string
26 description: Name of image to use for servers
27 flavor:
28 type: string
29 description: Flavor to use for servers
30 key_name:
31 type: string
32 description: Name of keypair to assign to servers
33 metadata:
34 type: json
35 default: {}
36 hardware_metadata:
37 description: The content of lab metadata.
38 type: string
39 user_data_config:
40 description: This is part of clout-config which denies to mount drive with label ephemeral0 to /mnt
41 type: string
42 default: |
43 #cloud-config
44 #
45 # Don't mount ephemeral0 to /mnt as it's by default
46 mounts:
47 - [ ephemeral0, null ]
48
49resources:
50
51 k8s_network_port:
52 type: OS::Neutron::Port
53 properties:
54 network: { get_param: k8s_network }
55 port_security_enabled: false
56 fixed_ips:
57 - subnet: { get_param: k8s_subnet_id }
58
59 floating_ip_k8s_net:
60 type: OS::Neutron::FloatingIP
61 properties:
62 floating_network_id: { get_param: public_net_id }
63 port_id: { get_resource: k8s_network_port }
64
65 software_config:
66 type: OS::Heat::SoftwareConfig
67 properties:
68 group: ungrouped
69 config:
70 str_replace:
71 template: |
72 #!/bin/bash
73
74 set -x
75
76 /usr/sbin/prepare-metadata.py --metadata-file /usr/share/metadata/lab-metadata.yaml
77
78 HW_METADATA='{}'
79 if [[ -f /usr/share/metadata/ceph.yaml && 'node_metadata' == *"ceph-osd-node"* ]]; then
80 HW_METADATA="{\"ceph\": {\"$(hostname)\": \"$(base64 -w 0 /usr/share/metadata/ceph.yaml)\"}}"
81 ceph_store_drive=$(cat /usr/share/metadata/ceph.yaml | egrep '\- name\: vd?' | awk '{print $3}')
82 if [[ -b /dev/${ceph_store_drive} ]]; then
83 sgdisk --zap-all /dev/${ceph_store_drive}
84 fi
85 fi
Ann Taraday56283e52024-10-25 15:36:20 +020086
87 apt install nfs-common -y
Anton Samoylov17e7c032024-10-14 23:55:18 +040088
89 STATUS="SUCCESS"
90 REASON="The node has been successfully deployed"
91 DATA_BINARY="{\"status\": \"$STATUS\", \"reason\": \"$REASON\", \"data\": $HW_METADATA}"
92 echo "Sending notification to wait condition with data: $HW_METADATA"
93
94 WC_EXIT_CODE=1
95 counter=0
96 while (( ${WC_EXIT_CODE} != 0 && ${counter} < 3 )); do
97 wc_notify -k --data-binary "$DATA_BINARY" && WC_EXIT_CODE=0
98 counter=$((counter + 1))
99 sleep 5
100 done
101
102 if (( ${WC_EXIT_CODE} !=0 ))
103 then
104 echo "Cannot send notification to wait condition with a SUCCESS status"
105 exit 1
106 fi
107 params:
108 wc_notify: { get_attr: [wait_handle, curl_cli] }
109 node_metadata: { get_param: metadata }
110
111 inject_files:
112 type: "OS::Heat::CloudConfig"
113 properties:
114 cloud_config:
115 write_files:
116 - path: /usr/sbin/prepare-metadata.py
117 owner: "root:root"
118 permissions: "0755"
119 content: {get_file: ../../de/heat-templates/scripts/prepare-metadata.py}
120 - path: /usr/share/metadata/lab-metadata.yaml
121 owner: "root:root"
122 permissions: "0644"
123 content: { get_param: hardware_metadata}
124
125 install_config_agent:
126 type: "OS::Heat::MultipartMime"
127 properties:
128 parts:
129 - config: {get_resource: software_config}
130 - config: {get_resource: inject_files}
131 - config: {get_param: user_data_config}
132
133 wait_handle:
134 type: OS::Heat::WaitConditionHandle
135
136 wait_condition:
137 type: OS::Heat::WaitCondition
138 properties:
139 handle: {get_resource: wait_handle}
140 timeout: { get_param: boot_timeout }
141
142 vm_server:
143 type: OS::Nova::Server
144 properties:
145 availability_zone: { get_param: availability_zone }
146 image: { get_param: image }
147 flavor: { get_param: flavor }
148 key_name: { get_param: key_name }
149 networks:
150 - port: { get_resource: k8s_network_port }
151 - network: { get_param : storage_frontend_network }
152 - network: { get_param : storage_backend_network }
153 - network: { get_param : data_network }
154 user_data_format: SOFTWARE_CONFIG
155 user_data: { get_resource: install_config_agent}
156
157outputs:
158 server_public_ip:
159 description: Floating IP address of server in public network
160 value: { get_attr: [ floating_ip_k8s_net, floating_ip_address ] }
161 wc_data:
162 description: Metadata from instance
163 value: { get_attr: [wait_condition, data]}