From ca9702f65b0014e04f0a9bbead83bf562ee972c3 Mon Sep 17 00:00:00 2001 From: Julien DOCHE Date: Mon, 17 Feb 2020 20:49:01 +0100 Subject: [PATCH 1/2] contrib/ansible: Fix home is not necessarily in /home Signed-off-by: Julien DOCHE --- roles/k3s/master/tasks/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/k3s/master/tasks/main.yml b/roles/k3s/master/tasks/main.yml index a20cc71..da55306 100644 --- a/roles/k3s/master/tasks/main.yml +++ b/roles/k3s/master/tasks/main.yml @@ -46,20 +46,20 @@ - name: Create directory .kube file: - path: /home/{{ ansible_user }}/.kube + path: ~{{ ansible_user }}/.kube state: directory owner: "{{ ansible_user }}" - name: Copy config file to user home directory copy: src: /etc/rancher/k3s/k3s.yaml - dest: /home/{{ ansible_user }}/.kube/config + dest: ~{{ ansible_user }}/.kube/config remote_src: yes owner: "{{ ansible_user }}" - name: Replace https://localhost:6443 by https://master-pi:6443 replace: - path: /home/{{ ansible_user }}/.kube/config + path: ~{{ ansible_user }}/.kube/config regexp: 'https://localhost:6443' replace: 'https://{{master_ip}}:6443' From 7f68b7f3cdb6a7c90dc5b7005945fd828712a15c Mon Sep 17 00:00:00 2001 From: Julien DOCHE Date: Mon, 17 Feb 2020 20:55:12 +0100 Subject: [PATCH 2/2] contrib/ansible: Use kubectl to set the server url in conf Sometimes https://127.0.0.1:6443 can be written in the conf, the regexp does not account for that. Signed-off-by: Julien DOCHE --- roles/k3s/master/tasks/main.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/roles/k3s/master/tasks/main.yml b/roles/k3s/master/tasks/main.yml index da55306..f2e05c1 100644 --- a/roles/k3s/master/tasks/main.yml +++ b/roles/k3s/master/tasks/main.yml @@ -58,10 +58,9 @@ owner: "{{ ansible_user }}" - name: Replace https://localhost:6443 by https://master-pi:6443 - replace: - path: ~{{ ansible_user }}/.kube/config - regexp: 'https://localhost:6443' - replace: 'https://{{master_ip}}:6443' + command: k3s kubectl config set-cluster default + --server=https://{{ master_ip }}:6443 + --kubeconfig ~{{ ansible_user }}/.kube/config - name: Create kubectl symlink file: