PyratLabs / ansible-role-k3s

Ansible role for installing k3s as either a standalone server or HA cluster.
BSD 3-Clause "New" or "Revised" License
640 stars 135 forks source link

Flag `--delete-local-data` has been deprecated #159

Closed qLb closed 2 years ago

qLb commented 3 years ago

Summary

Playbook failed to cleanly uninstall v1.22.2+k3s1.

Flag --delete-local-data has been deprecated, This option is deprecated and will be deleted. Use --delete-emptydir-data..

Issue Type

Controller Environment and Configuration

ansible-role-k3s version: v2.11.0

ubuntu@master01:~$ k3s --version
k3s version v1.22.2+k3s1 (10bca343)
go version go1.16.8
qL.b@mars:~$ ansible-playbook --version
ansible-playbook [core 2.11.5]
  ...
  python version = 3.9.6 (default, Jun 30 2021, 10:22:16) [GCC 11.1.0]
  jinja version = 3.0.1

Steps to Reproduce

Install latest k3s (>=v1.22.2+k3s1) and then try to uninstall it using ansible-role-k3s.

qL.b@mars:~$ ansible-playbook -i inventory setup-k3s.yml --become -e 'k3s_state=uninstalled'
#trimmed for clarity
- name: Config K3S
  hosts: k3s_cluster
  remote_user: ubuntu
  become: true
  pre_tasks:
  - name: Setup K3S servers
    ansible.builtin.set_fact:
      k3s_control_node: true
    when: inventory_hostname in ['master']
    ...
  tasks:
  - name: Setup K3S cluster
    include_role:
      name: ansible-role-k3s
    vars:
      k3s_become_for_all: true
      k3s_release_version: v1.22.2+k3s1
      k3s_server:
        ...

Part of config that hits deprecation notice: drain-and-remove-nodes.yml.

    - name: Ensure uninstalled nodes are drained
      ansible.builtin.command:
        cmd: >-
          {{ k3s_install_dir }}/kubectl drain {{ item }}
            --ignore-daemonsets
            --delete-local-data
            --force
      delegate_to: "{{ k3s_control_delegate }}"
      run_once: true
      when:
        - kubectl_get_nodes_result.stdout is defined
        - item in kubectl_get_nodes_result.stdout
        - hostvars[item].k3s_state is defined
        - hostvars[item].k3s_state == 'uninstalled'
      loop: "{{ ansible_play_hosts }}"
      become: "{{ k3s_become_for_kubectl | ternary(true, false, k3s_become_for_all) }}"

Expected Result

ubuntu@master01 clean and clear of previously installed k3s aka master | SUCCESS.

Actual Result

ubuntu@master01 still has k3s installed and running since drain tasks failed and ansible exited with an error: Flag --delete-local-data has been deprecated

Proposed Update

drain-and-remove-nodes.yml.

    - name: Ensure uninstalled nodes are drained
      ansible.builtin.command:
        cmd: >-
          {{ k3s_install_dir }}/kubectl drain {{ item }}
            --ignore-daemonsets
            --delete-emptydir-data
            --force
            ...
xanmanning commented 3 years ago

Should be fixed in v2.11.1

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.