mirror of
https://github.com/apricote/home-cloud.git
synced 2026-01-13 21:11:02 +00:00
ansible setup
This commit is contained in:
parent
42ec743a00
commit
2a2d951971
24 changed files with 167 additions and 430 deletions
42
main.tf
42
main.tf
|
|
@ -1,11 +1,37 @@
|
|||
module bitwarden {
|
||||
source = "services/bitwarden"
|
||||
|
||||
location = "${var.hcloud_location}"
|
||||
ssh_key_id = "${hcloud_ssh_key.terraform.id}"
|
||||
bitwarden_admin_email = "${var.admin_email}"
|
||||
resource hcloud_server control {
|
||||
count = 3
|
||||
name = "control${count.index}"
|
||||
image = "ubuntu-18.04"
|
||||
server_type = "cx21"
|
||||
}
|
||||
|
||||
variable admin_email {
|
||||
type = "string"
|
||||
resource hcloud_server compute {
|
||||
count = 3
|
||||
name = "compute${count.index}"
|
||||
image = "ubuntu-18.04"
|
||||
server_type = "cx21"
|
||||
}
|
||||
|
||||
data "template_file" "ansible_inventory" {
|
||||
template = "${file("${path.module}/templates/ansible_inventory.cfg")}"
|
||||
|
||||
depends_on = [
|
||||
"hcloud_server.control",
|
||||
"hcloud_server.compute",
|
||||
]
|
||||
|
||||
vars {
|
||||
control = "${join("\n", hcloud_server.control.*.ipv4_address)}"
|
||||
compute = "${join("\n", hcloud_server.compute.*.ipv4_address)}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "null_resource" "ansible_inventory" {
|
||||
triggers {
|
||||
template_rendered = "${data.template_file.ansible_inventory.rendered}"
|
||||
}
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = "echo '${data.template_file.ansible_inventory.rendered}' > ansible_inventory"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue