diff --git a/roles/kubernetes-apps/helm/templates/helm-container.j2 b/roles/kubernetes-apps/helm/templates/helm-container.j2 index 3afb2b2a9dc550f3eddc307ab930facf4327cac9..e760d0056e4dc1be82649cb3f25e1c42421bb9a6 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 7bef942738d0def583beeb37f2c774345d79c19a..11fb62693163bcbda279d31031583a93551a48ba 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 edd91232f5c3e7af39c83c0dfd51303320c8fc47..454bd37e2d9bd2f7f7db8c132bc254901d8899df 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 2abe55ec81c097ff3c7dc52adac246f8b1a74b73..adca631c2f36b7ccd01fc55404d15bcc61cd3fa2 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 4ee1478758f0428cbf12a8a841074a97ef6c705c..f67742c85110643ff54f613e4c6aaea6bbe8b33e 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 56039fb0d6c28e4bcfdee7fb9144c81ac06f49d5..08b9c71a875a2bcc40aa729c9c944a04012f6a5f 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