Simple terraform+ansible configuration to quickly spin up a development Docker swarm on my homeserver
您最多能選擇 25 個主題 主題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字。
 
 

26 行
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"
}
}