mirror of
https://github.com/k3s-io/k3s-ansible.git
synced 2025-12-26 00:22:36 +01:00
Fix issue around using ip addresses in inventory, download and remove agent service properly
Signed-off-by: Derek Nola <derek.nola@suse.com>
This commit is contained in:
@@ -4,10 +4,16 @@
|
|||||||
gather_facts: true
|
gather_facts: true
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: Run K3s Uninstall script
|
- name: Run K3s Uninstall script [server]
|
||||||
|
when: "'server' in group_names"
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: k3s-uninstall.sh
|
cmd: k3s-uninstall.sh
|
||||||
removes: /var/lib/rancher/k3s/*
|
removes: /var/lib/rancher/k3s/*
|
||||||
|
- name: Run K3s Uninstall script [agent]
|
||||||
|
when: "'agent' in group_names"
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: k3s-agent-uninstall.sh
|
||||||
|
removes: /var/lib/rancher/k3s/*
|
||||||
- name: Remove user kubeconfig
|
- name: Remove user kubeconfig
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /home/{{ ansible_user }}/.kube/config
|
path: /home/{{ ansible_user }}/.kube/config
|
||||||
|
|||||||
@@ -8,10 +8,21 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
- name: Download k3s binary
|
- name: Download k3s binary [server]
|
||||||
|
when: "'server' in group_names"
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: /usr/local/bin/k3s-install.sh
|
cmd: /usr/local/bin/k3s-install.sh
|
||||||
environment:
|
environment:
|
||||||
INSTALL_K3S_SKIP_START: "true"
|
INSTALL_K3S_SKIP_START: "true"
|
||||||
INSTALL_K3S_VERSION: "{{ k3s_version }}"
|
INSTALL_K3S_VERSION: "{{ k3s_version }}"
|
||||||
changed_when: true
|
changed_when: true
|
||||||
|
|
||||||
|
- name: Download k3s binary [agent]
|
||||||
|
when: "'agent' in group_names"
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: /usr/local/bin/k3s-install.sh
|
||||||
|
environment:
|
||||||
|
INSTALL_K3S_SKIP_START: "true"
|
||||||
|
INSTALL_K3S_VERSION: "{{ k3s_version }}"
|
||||||
|
INSTALL_K3S_EXEC: "agent"
|
||||||
|
changed_when: true
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Init first server node
|
- name: Init first server node
|
||||||
when: ansible_hostname == groups['server'][0]
|
# Handle both hostname OR ip address being supplied in inventory
|
||||||
|
when: ansible_hostname == groups['server'][0] or groups['server'][0] in ansible_facts['all_ipv4_addresses']
|
||||||
block:
|
block:
|
||||||
- name: Copy K3s service file [Single]
|
- name: Copy K3s service file [Single]
|
||||||
when: groups['server'] | length == 1
|
when: groups['server'] | length == 1
|
||||||
|
|||||||
Reference in New Issue
Block a user