Simple terraform+ansible configuration to quickly spin up a development Docker swarm on my homeserver
Je kunt niet meer dan 25 onderwerpen selecteren Onderwerpen moeten beginnen met een letter of nummer, kunnen streepjes bevatten ('-') en kunnen maximaal 35 tekens lang zijn.
 
 

26 regels
680 B

data "template_file" "inventory" {
template = "${file("files/ansible_hosts.tpl")}"
depends_on = [
"libvirt_domain.domain",
]
vars = {
managers = "${join("\n", slice(libvirt_domain.domain.*.name, 0, 3))}"
workers = "${join("\n", slice(libvirt_domain.domain.*.name, 3, length(libvirt_domain.domain.*.name)))}"
}
}
resource "null_resource" "ansible" {
triggers = {
template_rendered = "${data.template_file.inventory.rendered}"
}
provisioner "local-exec" {
command = "echo '${data.template_file.inventory.rendered}' > ansible/hosts"
}
provisioner "local-exec" {
command = "cd ansible && ansible-playbook --diff provision.yaml"
}
}