-
Notifications
You must be signed in to change notification settings - Fork 0
/
provisioner.tf
48 lines (41 loc) · 1.4 KB
/
provisioner.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
resource "null_resource" "wait_for_ssh" {
depends_on = [
proxmox_virtual_environment_vm.ubuntu_vm
]
# Ensure this task always runs
triggers = {
always_run = "${timestamp()}"
}
connection {
type = "ssh"
user = "ubuntu"
private_key = file("${var.private_key_path}")
host = local.ip_address
agent = false
timeout = "60s"
}
# Waiting for server to accept SSH connections and cloud-init to finish
provisioner "remote-exec" {
inline = [
"echo 'Waiting for cloud-init...'",
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do sleep 1; done"
]
}
}
resource "null_resource" "ansible" {
depends_on = [
null_resource.wait_for_ssh
]
# Ensure this task always runs
triggers = {
always_run = "${timestamp()}"
}
# Resize disks using ansible
provisioner "local-exec" {
command = "ANSIBLE_FORCE_COLOR=1 ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ${local.ip_address}, --user ubuntu --private-key ${var.private_key_path} ${path.module}/playbooks/fix_disk.yml"
}
# Disable cloud-init using ansible
provisioner "local-exec" {
command = "ANSIBLE_FORCE_COLOR=1 ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ${local.ip_address}, --user ubuntu --private-key ${var.private_key_path} ${path.module}/playbooks/disable_cloud-init.yml"
}
}