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