From 80feac92f77b92455be6573de731bf4921022dd4 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 23 Jul 2019 23:28:22 +0200 Subject: wip --- terraform/ansible/inventory | 12 ++++-------- terraform/inventory.tmpl | 9 --------- terraform/main.tf | 8 -------- 3 files changed, 4 insertions(+), 25 deletions(-) mode change 100755 => 100644 terraform/ansible/inventory delete mode 100644 terraform/inventory.tmpl (limited to 'terraform') diff --git a/terraform/ansible/inventory b/terraform/ansible/inventory old mode 100755 new mode 100644 index 9c92aff..95f5046 --- 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" -} -- cgit v1.2.3