Simple terraform+ansible configuration to quickly spin up a development Docker swarm on my homeserver
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
680 B

  1. data "template_file" "inventory" {
  2. template = "${file("files/ansible_hosts.tpl")}"
  3. depends_on = [
  4. "libvirt_domain.domain",
  5. ]
  6. vars = {
  7. managers = "${join("\n", slice(libvirt_domain.domain.*.name, 0, 3))}"
  8. workers = "${join("\n", slice(libvirt_domain.domain.*.name, 3, length(libvirt_domain.domain.*.name)))}"
  9. }
  10. }
  11. resource "null_resource" "ansible" {
  12. triggers = {
  13. template_rendered = "${data.template_file.inventory.rendered}"
  14. }
  15. provisioner "local-exec" {
  16. command = "echo '${data.template_file.inventory.rendered}' > ansible/hosts"
  17. }
  18. provisioner "local-exec" {
  19. command = "cd ansible && ansible-playbook --diff provision.yaml"
  20. }
  21. }