forked from playingfield/clusterlust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkube-config.yml
executable file
·61 lines (54 loc) · 1.74 KB
/
kube-config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env ansible-playbook
---
- name: Kube config on controller
hosts: kube_control_plane
tags: [kube_config]
gather_facts: true
vars:
local_user: semaphore
tasks:
- name: Create local config dirs
delegate_to: controller
become: true
ansible.builtin.file:
path: "~{{ local_user }}/.kube"
owner: "{{ local_user }}"
state: directory
mode: '0700'
- name: Fetch kube config from master
when: inventory_hostname in groups['kube_control_plane']
become: true
ansible.builtin.fetch:
src: /etc/kubernetes/admin.conf
dest: "~{{ local_user }}/.kube/config"
owner: "{{ local_user }}"
mode: '0600'
flat: true
- name: Configure k8s master
delegate_to: controller
become: true
ansible.builtin.lineinfile:
path: "~{{ local_user }}/.kube/config"
regexp: ' server.*6443$'
line: " server: https://{{ groups['kube_control_plane'][0] }}:6443"
state: present
mode: '0600'
- name: Create local config dirs
delegate_to: controller
become: true
ansible.builtin.file:
path: "~{{ cluster_admin | default('root') }}/.kube"
owner: "{{ cluster_admin | default('root') }}"
group: "{{ cluster_admin_group | default('root') }}"
state: directory
mode: '0700'
- name: Copy kube config to cluster
delegate_to: controller
become: true
ansible.builtin.copy:
remote_src: true
src: "~{{ local_user }}/.kube/config"
dest: "~{{ cluster_admin | default('root') }}/.kube/"
owner: "{{ cluster_admin | default('root') }}"
group: "{{ cluster_admin_group | default('root') }}"
mode: '0600'