-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
46 lines (42 loc) · 1.12 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
# VMs
resource "hcloud_server" "rancher_mgmt_nodes" {
name = "odroid-compile"
image = "ubuntu-22.04"
server_type = "cx11" # cpx41
location = "nbg1"
ssh_keys = [ "sgaspar@mbsgaspar", "[email protected]" ]
}
resource "local_file" "hosts_cfg" {
content = templatefile(
"${path.module}/inventory.tftpl",
{
user = "root"
nodes = hcloud_server.rancher_mgmt_nodes.*.ipv4_address
}
)
filename = "./inventory.yml"
}
resource "local_file" "setup_sh" {
content = templatefile(
"${path.module}/setup.tftpl",
{
nodes = hcloud_server.rancher_mgmt_nodes.*.ipv4_address
}
)
filename = "./setup.sh"
}
resource "terraform_data" "script" {
depends_on = [
local_file.hosts_cfg,
local_file.setup_sh,
hcloud_server.rancher_mgmt_nodes
]
provisioner "local-exec" {
command = <<EOT
sleep 10
./setup.sh
# ansible-playbook -u root -i inventory.yml ../Ansible/update.yaml
ansible -i inventory.yml all -m ping
EOT
}
}