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 ++++++-- terraform/master.tf | 2 +- 4 files changed, 22 insertions(+), 7 deletions(-) (limited to 'terraform') 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 diff --git a/terraform/master.tf b/terraform/master.tf index 0f8a675..8d00e45 100644 --- a/terraform/master.tf +++ b/terraform/master.tf @@ -2,7 +2,7 @@ resource "scaleway_ip" "k8s_master_ip" { } resource "scaleway_server" "k8s_master" { - name = "k8s_master" + name = "k8s-master" image = "${data.scaleway_image.debian.id}" type = "${var.k8s_master_server_type}" public_ip = "${scaleway_ip.k8s_master_ip.ip}" -- cgit v1.2.3