Update deploy-env role to support root user

Change-Id: I4126155eec03677cf29edfb47e80f54ab501705d
This commit is contained in:
Vladimir Kozhukalov 2024-06-13 15:01:47 -05:00
parent bea89e68f2
commit 10583bc269
2 changed files with 21 additions and 9 deletions

View File

@ -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
```

View File

@ -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: |