forked from usegalaxy-eu/infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance_dedicated_pavan.tf
49 lines (42 loc) · 1.59 KB
/
instance_dedicated_pavan.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
data "openstack_images_image_v2" "pavan-image" {
name = "Ubuntu 20.04"
}
resource "openstack_compute_instance_v2" "pavan" {
name = "Pavan dedicated VM"
image_id = data.openstack_images_image_v2.pavan-image.id
flavor_name = "c1.c36m100"
key_pair = "cloud2"
security_groups = ["default"]
network {
name = "public"
}
user_data = <<-EOF
#cloud-config
bootcmd:
- test -z "$(blkid /dev/vdb)" && mkfs -t ext4 /dev/vdb
- mkdir -p /scratch
mounts:
- ["/dev/vdb", "/scratch", auto, "defaults,nofail", "0", "2"]
runcmd:
- [ chown, "ubuntu.ubuntu", -R, /scratch ]
package_update: true
package_upgrade: true
users:
- default
ssh_authorized_keys:
- "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC8/9GdD96Xfc0MavIJQEuNSIrOlaBSYkH4s5RyGhNnc8Al7x3hC7KXt/mcqyNoI1JTvrXp23aDpTr67e3Dnrp6Me7z8nyY9oIy5WHOgwG2ra1Ga8oi89MVgXPhtxvcYnk8hVfuPDmhWkgwS5ILH/7V/1hEKHcS0H7Q0pJp8EGCBDFWrxNfUWqJJuVcXb11CMnaSJX/VhD+S4g4rG01lMr696+k8eKs9y2sq9JpuUD1TNN16RYu1uVlVz8nhIPbEBsnFeKV+EYKLcSRQnjDTNjWqZHHM9NMWfK3wGvr5pfla158ZdsYQTmQtcchTsEoB+7eAQaER3XsEtuo8yQj4zbL"
EOF
}
resource "random_id" "pavan-volume_name_unique" {
byte_length = 8
}
resource "openstack_blockstorage_volume_v2" "pavan-vol" {
name = "pavan-data-vol-${random_id.pavan-volume_name_unique.hex}"
volume_type = "default"
description = "Data volume for pavan VM"
size = 500
}
resource "openstack_compute_volume_attach_v2" "pavan-va" {
instance_id = openstack_compute_instance_v2.pavan.id
volume_id = openstack_blockstorage_volume_v2.pavan-vol.id
}