diff --git a/roles/kubernetes-apps/helm/templates/helm-container.j2 b/roles/kubernetes-apps/helm/templates/helm-container.j2 index 3afb2b2a9..e760d0056 100644 --- a/roles/kubernetes-apps/helm/templates/helm-container.j2 +++ b/roles/kubernetes-apps/helm/templates/helm-container.j2 @@ -2,7 +2,7 @@ {{ docker_bin_dir }}/docker run --rm \ --net=host \ --name=helm \ - -v /root/.kube:/root/.kube:ro \ + -v {{ ansible_env.HOME | default('/root') }}/.kube:/root/.kube:ro \ -v /etc/ssl:/etc/ssl:ro \ -v {{ helm_home_dir }}:{{ helm_home_dir }}:rw \ {% for dir in ssl_ca_dirs -%} diff --git a/roles/kubernetes/client/tasks/main.yml b/roles/kubernetes/client/tasks/main.yml index 7bef94273..11fb62693 100644 --- a/roles/kubernetes/client/tasks/main.yml +++ b/roles/kubernetes/client/tasks/main.yml @@ -16,16 +16,16 @@ tags: - facts -- name: Create kube config dir +- name: Create kube config dir for current/ansible become user file: - path: "/root/.kube" + path: "{{ ansible_env.HOME | default('/root') }}/.kube" mode: "0700" state: directory -- name: Copy admin kubeconfig to root user home +- name: Copy admin kubeconfig to current/ansible become user home copy: src: "{{ kube_config_dir }}/admin.conf" - dest: "/root/.kube/config" + dest: "{{ ansible_env.HOME | default('/root') }}/.kube/config" remote_src: yes mode: "0600" backup: yes diff --git a/roles/kubernetes/master/handlers/main.yml b/roles/kubernetes/master/handlers/main.yml index edd91232f..454bd37e2 100644 --- a/roles/kubernetes/master/handlers/main.yml +++ b/roles/kubernetes/master/handlers/main.yml @@ -101,7 +101,7 @@ - name: Master | Copy new kubeconfig for root user copy: src: "{{ kube_config_dir }}/admin.conf" - dest: "/root/.kube/config" + dest: "{{ ansible_env.HOME | default('/root') }}/.kube/config" remote_src: yes mode: "0600" backup: yes diff --git a/roles/kubernetes/master/tasks/kubeadm-cleanup-old-certs.yml b/roles/kubernetes/master/tasks/kubeadm-cleanup-old-certs.yml index 2abe55ec8..adca631c2 100644 --- a/roles/kubernetes/master/tasks/kubeadm-cleanup-old-certs.yml +++ b/roles/kubernetes/master/tasks/kubeadm-cleanup-old-certs.yml @@ -13,5 +13,5 @@ - name: kubeadm | Purge old kubeconfig file: - path: /root/.kube/config + path: "{{ ansible_env.HOME | default('/root') }}/.kube/config" state: absent diff --git a/roles/recover_control_plane/master/tasks/main.yml b/roles/recover_control_plane/master/tasks/main.yml index 4ee147875..f67742c85 100644 --- a/roles/recover_control_plane/master/tasks/main.yml +++ b/roles/recover_control_plane/master/tasks/main.yml @@ -2,7 +2,7 @@ - name: Wait for apiserver shell: "{{ bin_dir }}/kubectl get nodes" environment: - - KUBECONFIG: /root/.kube/config + - KUBECONFIG: "{{ ansible_env.HOME | default('/root') }}/.kube/config" register: apiserver_is_ready until: apiserver_is_ready.rc == 0 retries: 6 @@ -12,7 +12,7 @@ - name: Delete old kube-master nodes from cluster shell: "{{ bin_dir }}/kubectl delete node {{ item }}" environment: - - KUBECONFIG: /root/.kube/config + - KUBECONFIG: "{{ ansible_env.HOME | default('/root') }}/.kube/config" with_items: "{{ old_kube_masters.split(',') }}" register: delete_old_kube_masters failed_when: false diff --git a/roles/reset/tasks/main.yml b/roles/reset/tasks/main.yml index 56039fb0d..08b9c71a8 100644 --- a/roles/reset/tasks/main.yml +++ b/roles/reset/tasks/main.yml @@ -172,8 +172,8 @@ with_items: - "{{ kube_config_dir }}" - /var/lib/kubelet - - /root/.kube - - /root/.helm + - "{{ ansible_env.HOME | default('/root') }}/.kube" + - "{{ ansible_env.HOME | default('/root') }}/.helm" - "{{ etcd_data_dir }}" - /var/lib/etcd-events - /etc/ssl/etcd