-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
84 lines (70 loc) · 1.89 KB
/
main.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
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
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.35.0"
}
}
}
provider "openstack" {
}
resource "openstack_compute_keypair_v2" "my-cloud-key" {
name = "my-key"
public_key = "${file("${var.ssh_key_file_pub}")}"
}
resource "openstack_compute_instance_v2" "sys" {
name = "${var.instance_name}"
flavor_id = "${var.flavor}"
key_pair = "${openstack_compute_keypair_v2.my-cloud-key.name}"
security_groups = ["${openstack_compute_secgroup_v2.secgroup_1.name}"]
network {
name = "${var.network}"
}
block_device {
uuid = "${var.image}"
source_type = "image"
destination_type = "volume"
volume_size = "${var.volume_size}"
boot_index = 0
delete_on_termination = true
}
}
resource "openstack_networking_floatingip_v2" "myvm_fip" {
pool = "${var.pool}"
}
resource "openstack_compute_floatingip_associate_v2" "myvm_fip" {
floating_ip = openstack_networking_floatingip_v2.myvm_fip.address
instance_id = openstack_compute_instance_v2.sys.id
connection {
type = "ssh"
host = "${openstack_networking_floatingip_v2.myvm_fip.address}"
user = "${var.ssh_user_name}"
private_key = "${file(var.ssh_key_file_private)}"
}
provisioner "local-exec" {
command = "echo ${openstack_networking_floatingip_v2.myvm_fip.address} > instance_ip.txt"
}
provisioner "file" {
source = "./install_docker.sh"
destination = "install_docker.sh"
}
# Install docker
provisioner "remote-exec" {
inline = [
"chmod +x install_docker.sh",
"./install_docker.sh",
]
}
provisioner "file" {
source = "./install_miso.sh"
destination = "install_miso.sh"
}
# Install miso
provisioner "remote-exec" {
inline = [
"chmod +x install_miso.sh",
"./install_miso.sh",
]
}
}