Skip to content

Commit

Permalink
Install killall,uninstall scripts into k3s_install_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
qlonik committed Jun 16, 2024
1 parent 19c24bd commit cfd4879
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions tasks/ensure_installed_node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
- name: Ensure k3s killall script is present
ansible.builtin.template:
src: k3s-killall.sh.j2
dest: "/usr/local/bin/k3s-killall.sh"
dest: "{{ k3s_install_dir }}/k3s-killall.sh"
mode: 0700
become: "{{ k3s_become }}"
when:
Expand All @@ -95,7 +95,7 @@
- name: Ensure k3s uninstall script is present
ansible.builtin.template:
src: k3s-uninstall.sh.j2
dest: "/usr/local/bin/k3s-uninstall.sh"
dest: "{{ k3s_install_dir }}/k3s-uninstall.sh"
mode: 0700
become: "{{ k3s_become }}"
when:
Expand Down
10 changes: 5 additions & 5 deletions tasks/ensure_uninstalled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@

- name: Check to see if k3s-killall.sh exits
ansible.builtin.stat:
path: /usr/local/bin/k3s-killall.sh
path: "{{ k3s_install_dir }}/k3s-killall.sh"
register: check_k3s_killall_script

- name: Check to see if k3s-uninstall.sh exits
ansible.builtin.stat:
path: /usr/local/bin/k3s-uninstall.sh
path: "{{ k3s_install_dir }}/k3s-uninstall.sh"
register: check_k3s_uninstall_script

- name: Run k3s-killall.sh
ansible.builtin.command:
cmd: /usr/local/bin/k3s-killall.sh
cmd: "{{ k3s_install_dir }}/k3s-killall.sh"
register: k3s_killall
changed_when: k3s_killall.rc == 0
when: check_k3s_killall_script.stat.exists
become: "{{ k3s_become }}"

- name: Run k3s-uninstall.sh
ansible.builtin.command:
cmd: /usr/local/bin/k3s-uninstall.sh
cmd: "{{ k3s_install_dir }}/k3s-uninstall.sh"
args:
removes: /usr/local/bin/k3s-uninstall.sh
removes: "{{ k3s_install_dir }}/k3s-uninstall.sh"
register: k3s_uninstall
changed_when: k3s_uninstall.rc == 0
when: check_k3s_uninstall_script.stat.exists
Expand Down
4 changes: 2 additions & 2 deletions tasks/post_checks_uninstalled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

- name: Check k3s-killall.sh is removed
ansible.builtin.stat:
path: /usr/local/bin/k3s-killall.sh
path: "{{ k3s_install_dir }}/k3s-killall.sh"
register: check_k3s_killall

- name: Fail if k3s-killall.sh script still exists
Expand All @@ -32,7 +32,7 @@

- name: Check k3s-uninstall.sh is removed
ansible.builtin.stat:
path: /usr/local/bin/k3s-uninstall.sh
path: "{{ k3s_install_dir }}/k3s-uninstall.sh"
register: check_k3s_uninstall

- name: Fail if k3s-uninstall.sh script still exists
Expand Down
6 changes: 3 additions & 3 deletions templates/k3s-uninstall.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -x
[ $(id -u) -eq 0 ] || exec sudo $0 $@

/usr/local/bin/k3s-killall.sh
{{ k3s_install_dir }}/k3s-killall.sh

if command -v systemctl; then
systemctl disable k3s
Expand All @@ -17,7 +17,7 @@ rm -f {{ k3s_systemd_unit_dir }}/k3s.service
rm -f {{ k3s_systemd_unit_dir }}/k3s.env

remove_uninstall() {
rm -f /usr/local/bin/k3s-uninstall.sh
rm -f {{ k3s_install_dir }}/k3s-uninstall.sh
}
trap remove_uninstall EXIT

Expand All @@ -38,7 +38,7 @@ rm -rf /run/flannel
rm -rf {{ k3s_runtime_config['data-dir'] | default(k3s_data_dir) }}
rm -rf /var/lib/kubelet
rm -f {{ k3s_install_dir }}/k3s
rm -f /usr/local/bin/k3s-killall.sh
rm -f {{ k3s_install_dir }}/k3s-killall.sh

if type yum >/dev/null 2>&1; then
yum remove -y k3s-selinux
Expand Down

0 comments on commit cfd4879

Please sign in to comment.