-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator_inventory_konvoy1x.sh
61 lines (57 loc) · 1.47 KB
/
generator_inventory_konvoy1x.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh env
j=0
for i in $(terraform output -json Control_Plane_Nodes_IP_Addresses | tr -d "[]\""); do export CONTROLPLANE$j=$i;j=$((j+1));done
k=0
for i in $(terraform output -json Worker_Nodes_IP_Addresses | tr -d "[]\""); do export WORKER$k=$i;k=$((k+1));done
cat <<EOF > inventory.yaml
control-plane:
hosts:
$CONTROLPLANE0:
node_pool: control-plane
ansible_host: "cp0"
ansible_port: "22"
$CONTROLPLANE1:
node_pool: control-plane
ansible_host: "cp1"
ansible_port: "22"
$CONTROLPLANE2:
node_pool: control-plane
ansible_host: "cp2"
ansible_port: "22"
node:
hosts:
$WORKER0:
node_pool: worker
ansible_host: "w0"
ansible_port: "22"
$WORKER1:
node_pool: worker
ansible_host: "w1"
ansible_port: "22"
$WORKER2:
node_pool: worker
ansible_host: "w2"
ansible_port: "22"
$WORKER3:
node_pool: worker
ansible_host: "w3"
ansible_port: "22"
all:
vars:
ansible_port: 22
ansible_ssh_private_key_file: "~/.ssh/id_rsa"
ansible_user: "root"
control_plane_endpoint: ""
order: sorted
version: v1beta1
EOF
envsubst < inventory.yaml
cat <<EOF >> /etc/hosts
$CONTROLPLANE0 $TF_VAR_cluster_name-cp0 cp0
$CONTROLPLANE1 $TF_VAR_cluster_name-cp1 cp1
$CONTROLPLANE2 $TF_VAR_cluster_name-cp2 cp2
$WORKER0 $TF_VAR_cluster_name-w0 w0
$WORKER1 $TF_VAR_cluster_name-w1 w1
$WORKER2 $TF_VAR_cluster_name-w2 w2
$WORKER3 $TF_VAR_cluster_name-w3 w3
EOF