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.

37 lines
1.2 KiB

  1. variable "SSHUser" {
  2. type = "string"
  3. description = "SSH User for VMs."
  4. }
  5. resource "null_resource" "ansible-provision" {
  6. depends_on = ["aws_instance.master","aws_instance.etcd","aws_instance.minion"]
  7. ##Create Master Inventory
  8. provisioner "local-exec" {
  9. command = "echo \"[kube-master]\" > inventory"
  10. }
  11. provisioner "local-exec" {
  12. command = "echo \"${join("\n",formatlist("%s ansible_ssh_user=%s", aws_instance.master.*.private_ip, var.SSHUser))}\" >> inventory"
  13. }
  14. ##Create ETCD Inventory
  15. provisioner "local-exec" {
  16. command = "echo \"\n[etcd]\" >> inventory"
  17. }
  18. provisioner "local-exec" {
  19. command = "echo \"${join("\n",formatlist("%s ansible_ssh_user=%s", aws_instance.etcd.*.private_ip, var.SSHUser))}\" >> inventory"
  20. }
  21. ##Create Nodes Inventory
  22. provisioner "local-exec" {
  23. command = "echo \"\n[kube-node]\" >> inventory"
  24. }
  25. provisioner "local-exec" {
  26. command = "echo \"${join("\n",formatlist("%s ansible_ssh_user=%s", aws_instance.minion.*.private_ip, var.SSHUser))}\" >> inventory"
  27. }
  28. provisioner "local-exec" {
  29. command = "echo \"\n[k8s-cluster:children]\nkube-node\nkube-master\netcd\" >> inventory"
  30. }
  31. }