From 029ffa806227656bb77393a2626aab84f055b06b Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 24 Jul 2019 13:37:30 +0200 Subject: wip --- terraform/ansible/all.yml | 18 ++++++++++++++---- terraform/ansible/inventory | 1 + terraform/ansible/roles/k3s/templates/k3s.service.j2 | 8 ++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) (limited to 'terraform/ansible') diff --git a/terraform/ansible/all.yml b/terraform/ansible/all.yml index 8ba47b7..636c0d1 100644 --- a/terraform/ansible/all.yml +++ b/terraform/ansible/all.yml @@ -14,8 +14,7 @@ tags: apt-repos become: yes -- hosts: - k8s-master +- hosts: k8s-master tags: k3s, k8s roles: - role: k3s @@ -24,8 +23,7 @@ vars: k3s_role: master -- hosts: - k8s-nodes +- hosts: k8s-nodes tags: k3s, k8s roles: - role: k3s @@ -33,3 +31,15 @@ become: yes vars: k3s_role: node + +- hosts: + - k8s + tags: interfaces + tasks: + - become: yes + copy: + dest: /etc/network/interfaces.d/60-k3s.cfg + content: | + auto ens2.1 + iface ens2.1 inet static + address {{ ansible_host }}/32 diff --git a/terraform/ansible/inventory b/terraform/ansible/inventory index 24bbc2e..880397a 100755 --- a/terraform/ansible/inventory +++ b/terraform/ansible/inventory @@ -16,6 +16,7 @@ $input.k8s_node_names|to_entries|map({(.value):{ {_meta:{ hostvars:([{"k8s-master": $master}]+$nodes|add)}, all:(["k8s-master"] + ($input.k8s_node_names)), + k8s:(["k8s-master"] + ($input.k8s_node_names)), "k8s-nodes":$input.k8s_node_names, } EOF diff --git a/terraform/ansible/roles/k3s/templates/k3s.service.j2 b/terraform/ansible/roles/k3s/templates/k3s.service.j2 index b1c5c54..5c0c559 100644 --- a/terraform/ansible/roles/k3s/templates/k3s.service.j2 +++ b/terraform/ansible/roles/k3s/templates/k3s.service.j2 @@ -5,10 +5,14 @@ After=network.target {% if k3s_role == 'master' %} ExecStartPre=-/sbin/modprobe br_netfilter ExecStartPre=-/sbin/modprobe overlay -ExecStart=/usr/local/bin/k3s server +ExecStart=/usr/local/bin/k3s server \ + --node-ip {{ ansible_host }} {% else %} # TODO: this should use private_ip -ExecStart=/usr/local/bin/k3s agent --server https://{{ hostvars['k8s-master']['ansible_host'] }}:6443 --token {{ hostvars['k8s-master']['node_token'] }} +ExecStart=/usr/local/bin/k3s agent \ + --server https://{{ hostvars['k8s-master']['ansible_host'] }}:6443 \ + --token {{ hostvars['k8s-master']['node_token'] }} \ + --node-ip {{ ansible_host }} {% endif %} KillMode=process Delegate=yes -- cgit v1.2.3