diff --git a/roles/deploy-env/README.md b/roles/deploy-env/README.md index 2ecb2d6a5..116fff98e 100644 --- a/roles/deploy-env/README.md +++ b/roles/deploy-env/README.md @@ -31,27 +31,29 @@ all: ansible_user: ubuntu ansible_ssh_private_key_file: /home/ubuntu/.ssh/id_rsa ansible_ssh_extra_args: -o StrictHostKeyChecking=no + hosts: + primary: + ansible_host: 10.10.10.10 + node-1: + ansible_host: 10.10.10.11 + node-2: + ansible_host: 10.10.10.12 + node-3: + ansible_host: 10.10.10.13 children: primary: hosts: primary: - ansible_host: 10.10.10.10 k8s_cluster: hosts: node-1: - ansible_host: 10.10.10.11 node-2: - ansible_host: 10.10.10.12 node-3: - ansible_host: 10.10.10.13 k8s_control_plane: hosts: node-1: - ansible_host: 10.10.10.11 k8s_nodes: hosts: node-2: - ansible_host: 10.10.10.12 node-3: - ansible_host: 10.10.10.13 ``` diff --git a/roles/deploy-env/tasks/k8s_client.yaml b/roles/deploy-env/tasks/k8s_client.yaml index faf5f0ac2..9a3b96cc8 100644 --- a/roles/deploy-env/tasks/k8s_client.yaml +++ b/roles/deploy-env/tasks/k8s_client.yaml @@ -19,14 +19,24 @@ pkg: - "kubectl={{ kube_version }}" +- name: Set user home directory + set_fact: + user_home_directory: /home/{{ kubectl.user }} + when: kubectl.user != "root" + +- name: Set root home directory + set_fact: + user_home_directory: /root + when: kubectl.user == "root" + - name: "Setup kubeconfig directory for {{ kubectl.user }} user" shell: | - mkdir -p /home/{{ kubectl.user }}/.kube + mkdir -p {{ user_home_directory }}/.kube - name: "Copy kube_config file for {{ kubectl.user }} user" synchronize: src: /tmp/kube_config - dest: /home/{{ kubectl.user }}/.kube/config + dest: "{{ user_home_directory }}/.kube/config" - name: "Set kubconfig file ownership for {{ kubectl.user }} user" shell: |