-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloudinit_config.tf
50 lines (48 loc) · 1.25 KB
/
cloudinit_config.tf
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
# Render a multi-part cloud-init config making use of the part
# above, and other source files
data "cloudinit_config" "config" {
gzip = false
base64_encode = false
# Main cloud-config configuration file.
part {
filename = "init.cfg"
content_type = "text/cloud-config"
content = <<EOF
#cloud-config
packages:
- jq
- unzip
- python3
- python3-pip
- libguestfs-tools
- parted
write_files:
- path: /tmp/data_mover.zip
encoding: b64
content: ${filebase64(data.archive_file.data_mover.output_path)}
- path: /tmp/data_mover.env
content: |
cosEndpoint='${var.cos_endpoint == "null" ? format("https://%s",data.ibm_cos_bucket.cos_bucket.s3_endpoint_direct) : var.cos_endpoint}'
cosAPIKey='${sensitive(var.ibmcloud_api_key)}'
cosInstanceCRN='${data.ibm_cos_bucket.cos_bucket.crn}'
cosBucketName='${var.cos_bucket_name}'
customImageName='${var.custom_image_name}'
iamEndpoint='${var.iam_endpoint_url}'
EOF
}
part {
content_type = "text/x-shellscript"
content = <<EOF
#!/bin/sh -e
rm -rf /data_mover
mkdir /data_mover
cd /data_mover
unzip /tmp/data_mover.zip
cp /tmp/data_mover.env .env
export PYTHONUNBUFFERED=1
pip3 install --no-cache-dir -r requirements.txt
./data_mover.py
./upload.py
EOF
}
}