diff options
Diffstat (limited to 'terraform')
-rw-r--r--[-rwxr-xr-x] | terraform/ansible/inventory | 12 | ||||
-rw-r--r-- | terraform/inventory.tmpl | 9 | ||||
-rw-r--r-- | terraform/main.tf | 8 |
3 files changed, 4 insertions, 25 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)))) }' diff --git a/terraform/inventory.tmpl b/terraform/inventory.tmpl deleted file mode 100644 index c4b3938..0000000 --- a/terraform/inventory.tmpl +++ /dev/null @@ -1,9 +0,0 @@ -k8s-master ansible_host=${master} -%{ for index, ip in nodes ~} -k8s-node${index} ansible_host=${ip} -%{ endfor ~} - -[k8s-nodes] -%{ for index, ip in nodes ~} -k8s-node${index} -%{ endfor ~} diff --git a/terraform/main.tf b/terraform/main.tf index a71227c..9ad90ff 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -31,11 +31,3 @@ resource "scaleway_ssh_key" "trygvis_conflatorio" { resource "scaleway_ssh_key" "trygvis_arius-v4" { key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL3UZyrbXX7WMHqcZCRspkoSIfB6egrbOxXPf1zyZkAw trygvis@arius-v4" } - -resource "local_file" "inventory" { - content = templatefile("inventory.tmpl", { - master=scaleway_server.k8s_master.public_ip, - nodes=scaleway_server.k8s_node.*.public_ip - }) - filename = "ansible/inventory" -} |