Hi, I´ve got some issues with the a terraform script. I create a datacenter, two lans and two servers. Both servers are connected to a private lan (lan2) and one of the servers is connected to the public lan as well.
resource "profitbricks_datacenter" "main" {
name = "xx_test"
location = "de/fra"
description = "Cusomer Data Center"
}
//Public Lan
resource "profitbricks_lan" "lan1" {
datacenter_id = "${profitbricks_datacenter.main.id}"
public = true
}
//Private Lan
resource "profitbricks_lan" "lan2" {
datacenter_id = "${profitbricks_datacenter.main.id}"
public = false
}
resource "profitbricks_server" "salt-master" {
name = "salt-master"
datacenter_id = "${profitbricks_datacenter.main.id}"
cores = 1
ram = 2048
availability_zone = "AUTO"
cpu_family = "AMD_OPTERON"
volume {
name = "system"
image_name = "${var.ubuntu}"
size = 30
disk_type = "HDD"
ssh_key_path = ["${var.public_key_path}"]
image_password = "XXXXXXXX"
}
nic {
lan = "${profitbricks_lan.lan1.id}"
dhcp = true
firewall_active = true
firewall {
protocol = "TCP"
name = "SSH"
port_range_start = 22
port_range_end = 22
}
}
provisioner "remote-exec" {
inline = [
# install salt-master
"curl -L https://bootstrap.saltstack.com -o install_salt.sh",
"sudo sh install_salt.sh -M",
]
connection {
type = "ssh"
private_key = "${file("${var.private_key_path}")}"
user = "root"
timeout = "4m"
}
}
}
resource "profitbricks_server" "salt-minion" {
name = "salt-minion"
datacenter_id = "${profitbricks_datacenter.main.id}"
cores = 1
ram = 2048
availability_zone = "AUTO"
cpu_family = "AMD_OPTERON"
volume {
name = "system"
image_name = "${var.ubuntu}"
size = 30
disk_type = "HDD"
ssh_key_path = ["${var.public_key_path}"]
image_password = "XXXXXXXX"
}
nic {
lan = "${profitbricks_lan.lan2.id}"
dhcp = true
}
provisioner "remote-exec" {
inline = [
# install salt-master
"curl -L https://bootstrap.saltstack.com -o install_salt.sh",
"sudo sh install_salt.sh",
]
connection {
type = "ssh"
private_key = "${file("${var.private_key_path}")}"
user = "root"
timeout = "4m"
}
}
}
resource "profitbricks_nic" "master_nic" {
datacenter_id = "${profitbricks_datacenter.main.id}"
server_id = "${profitbricks_server.salt-master.id}"
lan = "${profitbricks_lan.lan2.id}"
dhcp = true
}
Wenn I start the script for the first time, it works fine until the creation of the second server. I get the error:
Error applying plan:
2 error(s) occurred:
* profitbricks_server.salt-minion: Resource 'profitbricks_lan.lan2' does not have attribute 'id' for variable 'profitbricks_lan.lan2.id'
* profitbricks_nic.master_nic: Resource 'profitbricks_lan.lan2' does not have attribute 'id' for variable 'profitbricks_lan.lan2.id'
But the output said:
profitbricks_lan.lan2: Creation complete
profitbricks_lan.lan1: Creation complete (ID: 2)
Starting the script again without deleting the datacenter: The second run creates lan2 (again?) now with an id
profitbricks_lan.lan2: Creation complete (ID: 3)
The secons server is created as well, but the remote_exec provisioner is not able to connect to the server, After a lot of tries
profitbricks_server.salt-minion (remote-exec): Host: 10.14.106.12
profitbricks_server.salt-minion (remote-exec): User: root
profitbricks_server.salt-minion (remote-exec): Password: true
profitbricks_server.salt-minion (remote-exec): Private key: true
profitbricks_server.salt-minion (remote-exec): SSH Agent: false
I get:
profitbricks_server.salt-minion: Still creating... (6m10s elapsed)
Error applying plan:
1 error(s) occurred:
* profitbricks_server.salt-minion: 1 error(s) occurred:
* timeout
Could you provide any hint? Cheers, Uli
BTW: How can I get the IP-Address of the first server (salt-master) in the private lan, when I create the secons one? Assmne some ${profitbricks_server.salt-master.xxx}