aboutsummaryrefslogtreecommitdiff
path: root/terraform/ansible
diff options
context:
space:
mode:
Diffstat (limited to 'terraform/ansible')
-rw-r--r--[-rwxr-xr-x]terraform/ansible/inventory12
1 files changed, 4 insertions, 8 deletions
diff --git a/terraform/ansible/inventory b/terraform/ansible/inventory
index 9c92aff..95f5046 100755..100644
--- a/terraform/ansible/inventory
+++ b/terraform/ansible/inventory
@@ -1,9 +1,5 @@
-k8s-master ansible_host=51.158.110.170
-k8s-node0 ansible_host=51.15.201.150
-k8s-node1 ansible_host=163.172.174.68
-k8s-node2 ansible_host=51.158.96.79
+#!/bin/bash
-[k8s-nodes]
-k8s-node0
-k8s-node1
-k8s-node2
+set -euo pipefail
+
+(cd .. && terraform output -json) | jq 'to_entries|map({(.key|tostring):.value.value})|add as $input | $input.k8s_node_ips|to_entries|map({("k8s-node"+(.key|tostring)):{ansible_host:.value}})|add + {"k8s-master":{ansible_host:$input.k8s_master_ip}}|{_meta:{hostvars:.}, all:(["k8s-master"] + ($input.k8s_node_ips|to_entries|map("k8s-node"+(.key|tostring)))) }'