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.
 
 
 
 
 
 

55 lines
918 B

  1. resource "libvirt_domain" "domain" {
  2. count = var.node_count
  3. name = "swarm-${count.index + 1}"
  4. vcpu = var.node_vcpu
  5. memory = var.node_memory
  6. disk {
  7. volume_id = libvirt_volume.root[count.index].id
  8. }
  9. cloudinit = libvirt_cloudinit_disk.cidata[count.index].id
  10. console {
  11. type = "pty"
  12. target_port = "0"
  13. target_type = "serial"
  14. }
  15. console {
  16. type = "pty"
  17. target_type = "virtio"
  18. target_port = "1"
  19. }
  20. network_interface {
  21. bridge = "br0"
  22. }
  23. provisioner "remote-exec" {
  24. inline = [
  25. "cloud-init status --wait",
  26. "sudo shutdown -r +0"
  27. ]
  28. connection {
  29. type = "ssh"
  30. user = "deploy"
  31. host = "swarm-${count.index + 1}"
  32. }
  33. }
  34. provisioner "remote-exec" {
  35. inline = [
  36. "echo 'ready'",
  37. ]
  38. connection {
  39. type = "ssh"
  40. user = "deploy"
  41. host = "swarm-${count.index + 1}"
  42. }
  43. }
  44. }