Initial commit

This commit is contained in:
2026-04-19 00:12:26 +03:00
commit 7772b5cb77
8 changed files with 498 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
---
- name: Distribute kubeconfig to k3s server nodes
hosts: k3s
become: true
tasks:
- name: Create .kube directory
ansible.builtin.file:
path: "~{{ ansible_user }}/.kube"
state: directory
mode: '0755'
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
- name: Copy kubeconfig from local machine to remote host
ansible.builtin.copy:
src: "~/.kube/config"
dest: "~{{ ansible_user }}/.kube/config"
mode: '0600'
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
- name: Set KUBECONFIG in ansible_user profile
ansible.builtin.lineinfile:
path: "~{{ ansible_user }}/.profile"
line: "export KUBECONFIG=~{{ ansible_user }}/.kube/config"
regexp: "^export KUBECONFIG=.*"
create: true
mode: '0644'
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
- name: Verify kubectl works on remote host
ansible.builtin.command: k3s kubectl get nodes
register: nodes_result
changed_when: false
- name: Display cluster nodes
ansible.builtin.debug:
msg: "{{ nodes_result.stdout_lines }}"