From d341a283a0ef3e4a19e4885315624b6b24653da9 Mon Sep 17 00:00:00 2001 From: Adrien Date: Sat, 17 Oct 2020 01:53:34 +0200 Subject: [PATCH] full install of k3s is working --- tasks/cluster_k3s.yml | 18 ++++++++++++------ .../etc/systemd/system/k3s.service.env.j2 | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tasks/cluster_k3s.yml b/tasks/cluster_k3s.yml index c46469f..14875eb 100644 --- a/tasks/cluster_k3s.yml +++ b/tasks/cluster_k3s.yml @@ -1,4 +1,10 @@ --- +- name: Install Wireguard + include_role: + name: wireguard +# when: +# - kubernetes_cni == "wireguard" + - name: Check if /usr/local/bin/k3s already existe stat: path: /usr/local/bin/k3s @@ -13,7 +19,7 @@ owner: root mode: 0755 when: - - k3s_bin.stat.exists + - not k3s_bin.stat.exists - ansible_machine == "x86_64" - name: retreive k3s binary for arm64 @@ -24,7 +30,7 @@ owner: root mode: 0755 when: - - k3s_bin.stat.exists + - not k3s_bin.stat.exists - ansible_machine == "arm64" - name: retreive k3s binary for armv6/armv7 @@ -35,7 +41,7 @@ owner: root mode: 0755 when: - - k3s_bin.stat.exists + - not k3s_bin.stat.exists - (ansible_machine == "armv7l") or (ansible_machine == "armv6l") - name: Create tools link @@ -72,14 +78,14 @@ thinpool: kubernetes size: "{{ item.size }}" with_items: - - { name: var_lib_k3s, vg: vg_sys, size: 10g, mount_point: /var/lib/rancher/k3s} + - { name: var_lib_k3s, vg: vg_sys, size: 10g, mount_point: /var/lib/rancher/k3s, mount_opts: "discard"} - name: create file system on containerd lv filesystem: fstype: ext4 dev: "/dev/{{ item.vg }}/{{ item.name }}" with_items: - - { name: var_lib_k3s, vg: vg_sys, size: 10g, mount_point: /var/lib/rancher/k3s} + - { name: var_lib_k3s, vg: vg_sys, size: 10g, mount_point: /var/lib/rancher/k3s, mount_opts: "discard"} - name: mount logical volumes mount: @@ -89,7 +95,7 @@ opts: "{{ item.mount_opts }}" state: mounted with_items: - - { name: var_lib_k3s, vg: vg_sys, size: 10g, mount_point: /var/lib/rancher/k3s} + - { name: var_lib_k3s, vg: vg_sys, size: 10g, mount_point: /var/lib/rancher/k3s, mount_opts: "discard"} - name: Enable k3s on boot service: diff --git a/templates/etc/systemd/system/k3s.service.env.j2 b/templates/etc/systemd/system/k3s.service.env.j2 index 58104e7..980b10e 100644 --- a/templates/etc/systemd/system/k3s.service.env.j2 +++ b/templates/etc/systemd/system/k3s.service.env.j2 @@ -1,3 +1,3 @@ -{% if kubernetes_master|bool %} +{% if not kubernetes_master|bool %} NODE_TOKEN={{ kubernetes_server_token }} {% endif %} \ No newline at end of file