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.

49 lines
1.6 KiB

  1. provider "exoscale" {}
  2. module "kubernetes" {
  3. source = "./modules/kubernetes-cluster"
  4. prefix = var.prefix
  5. zone = var.zone
  6. machines = var.machines
  7. ssh_public_keys = var.ssh_public_keys
  8. ssh_whitelist = var.ssh_whitelist
  9. api_server_whitelist = var.api_server_whitelist
  10. nodeport_whitelist = var.nodeport_whitelist
  11. }
  12. #
  13. # Generate ansible inventory
  14. #
  15. data "template_file" "inventory" {
  16. template = file("${path.module}/templates/inventory.tpl")
  17. vars = {
  18. connection_strings_master = join("\n", formatlist("%s ansible_user=ubuntu ansible_host=%s ip=%s etcd_member_name=etcd%d",
  19. keys(module.kubernetes.master_ip_addresses),
  20. values(module.kubernetes.master_ip_addresses).*.public_ip,
  21. values(module.kubernetes.master_ip_addresses).*.private_ip,
  22. range(1, length(module.kubernetes.master_ip_addresses) + 1)))
  23. connection_strings_worker = join("\n", formatlist("%s ansible_user=ubuntu ansible_host=%s ip=%s",
  24. keys(module.kubernetes.worker_ip_addresses),
  25. values(module.kubernetes.worker_ip_addresses).*.public_ip,
  26. values(module.kubernetes.worker_ip_addresses).*.private_ip))
  27. list_master = join("\n", keys(module.kubernetes.master_ip_addresses))
  28. list_worker = join("\n", keys(module.kubernetes.worker_ip_addresses))
  29. api_lb_ip_address = module.kubernetes.control_plane_lb_ip_address
  30. }
  31. }
  32. resource "null_resource" "inventories" {
  33. provisioner "local-exec" {
  34. command = "echo '${data.template_file.inventory.rendered}' > ${var.inventory_file}"
  35. }
  36. triggers = {
  37. template = data.template_file.inventory.rendered
  38. }
  39. }