This commit is contained in:
@@ -8,9 +8,9 @@ variable "serverctl_master_count" {
|
||||
}
|
||||
|
||||
resource "hcloud_server" "serverctl_master" {
|
||||
count = var.serverctl_master_count
|
||||
name = "serverctl-master-${count.index}"
|
||||
image = "debian-11"
|
||||
count = var.serverctl_master_count
|
||||
name = "serverctl-master-${count.index}"
|
||||
image = "debian-11"
|
||||
server_type = "cx11"
|
||||
ssh_keys = [
|
||||
var.hcloud_serverctl_ssh_key_id
|
||||
@@ -21,9 +21,9 @@ resource "hcloud_server" "serverctl_master" {
|
||||
inline = ["sudo apt update", "sudo apt install python3 -y", "echo Done!"]
|
||||
|
||||
connection {
|
||||
host = self.ipv4_address
|
||||
type = "ssh"
|
||||
user = "root"
|
||||
host = self.ipv4_address
|
||||
type = "ssh"
|
||||
user = "root"
|
||||
private_key = file(var.pvt_key)
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ resource "null_resource" "configure_serverctl_master" {
|
||||
count = var.serverctl_master_count
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = "ANSIBLE_HOST_KEY_CHECKING=False /usr/bin/ansible-playbook -u root -i '${element(hcloud_server.serverctl_master.*.ipv4_address, 0)},' --private-key ${var.pvt_key} -e 'pub_key=${var.pub_key}' apache-install.yml"
|
||||
command = "ANSIBLE_HOST_KEY_CHECKING=False /usr/bin/ansible-playbook -u root -i '${element(hcloud_server.serverctl_master.*.ipv4_address, 0)},' --private-key ${var.pvt_key} -e 'pub_key=${var.pub_key}' server-install.yml"
|
||||
}
|
||||
|
||||
triggers = {
|
||||
@@ -43,7 +43,16 @@ resource "null_resource" "configure_serverctl_master" {
|
||||
|
||||
output "master_ipv4_addresses" {
|
||||
value = {
|
||||
for serverctl in hcloud_server.serverctl_master:
|
||||
for serverctl in hcloud_server.serverctl_master :
|
||||
serverctl.name => serverctl.ipv4_address
|
||||
}
|
||||
}
|
||||
|
||||
resource "local_file" "hosts_cfg" {
|
||||
content = templatefile("${path.module}/templates/hosts.tpl",
|
||||
{
|
||||
serverctl_masters = hcloud_server.serverctl_master.*.ipv4_address
|
||||
}
|
||||
)
|
||||
filename = "ansible/inventory/hosts.cfg"
|
||||
}
|
||||
|
Reference in New Issue
Block a user