From ac06da81fbf302c12b235ddde0a5fae93bba20f4 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 20 Jun 2020 03:35:08 +0200 Subject: kubernetes: move kubeguard/reset to kubeadm/reset --- common/kubernetes-cluster-cleanup.yml | 2 -- roles/kubernetes/kubeadm/reset/handlers/main.yml | 4 ++++ roles/kubernetes/kubeadm/reset/tasks/main.yml | 3 +++ .../kubeadm/reset/tasks/net_kubeguard.yml | 26 ++++++++++++++++++++++ .../net/kubeguard/reset/handlers/main.yml | 4 ---- .../kubernetes/net/kubeguard/reset/tasks/main.yml | 26 ---------------------- 6 files changed, 33 insertions(+), 32 deletions(-) create mode 100644 roles/kubernetes/kubeadm/reset/handlers/main.yml create mode 100644 roles/kubernetes/kubeadm/reset/tasks/net_kubeguard.yml delete mode 100644 roles/kubernetes/net/kubeguard/reset/handlers/main.yml delete mode 100644 roles/kubernetes/net/kubeguard/reset/tasks/main.yml diff --git a/common/kubernetes-cluster-cleanup.yml b/common/kubernetes-cluster-cleanup.yml index d56940ee..7c10d17c 100644 --- a/common/kubernetes-cluster-cleanup.yml +++ b/common/kubernetes-cluster-cleanup.yml @@ -38,5 +38,3 @@ hosts: _kubernetes_nodes_remove_ roles: - role: kubernetes/kubeadm/reset - - role: kubernetes/net/kubeguard/reset - when: hostvars[groups['_kubernetes_primary_master_'][0]].kubernetes_network_plugin == 'kubeguard' diff --git a/roles/kubernetes/kubeadm/reset/handlers/main.yml b/roles/kubernetes/kubeadm/reset/handlers/main.yml new file mode 100644 index 00000000..bb7fde2b --- /dev/null +++ b/roles/kubernetes/kubeadm/reset/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: reload systemd + systemd: + daemon_reload: yes diff --git a/roles/kubernetes/kubeadm/reset/tasks/main.yml b/roles/kubernetes/kubeadm/reset/tasks/main.yml index 57a3faf4..cf9c125d 100644 --- a/roles/kubernetes/kubeadm/reset/tasks/main.yml +++ b/roles/kubernetes/kubeadm/reset/tasks/main.yml @@ -30,3 +30,6 @@ file: path: "{{ item.path }}" state: absent + +- name: extra-cleanup for kubeguard network plugin + import_tasks: net_kubeguard.yml diff --git a/roles/kubernetes/kubeadm/reset/tasks/net_kubeguard.yml b/roles/kubernetes/kubeadm/reset/tasks/net_kubeguard.yml new file mode 100644 index 00000000..03b3f205 --- /dev/null +++ b/roles/kubernetes/kubeadm/reset/tasks/net_kubeguard.yml @@ -0,0 +1,26 @@ +--- +- name: check if kubeguard interface service unit exists + stat: + path: /etc/systemd/system/kubeguard-interfaces.service + register: kubeguard_interface_unit + +- name: bring down kubeguard interface + when: kubeguard_interface_unit.stat.exists + systemd: + name: kubeguard-interfaces.service + state: stopped + +- name: gather list of all kubeguard related service units + find: + path: /etc/systemd/system/ + patterns: + - "kubeguard-peer-*.service" + - kubeguard-interfaces.service + register: kubeguard_units_installed + +- name: remove all kubeguard related files and directories + loop: "{{ kubeguard_units_installed.files | map(attribute='path') | list | flatten | union(['/var/lib/kubeguard']) }}" + file: + path: "{{ item }}" + state: absent + notify: reload systemd diff --git a/roles/kubernetes/net/kubeguard/reset/handlers/main.yml b/roles/kubernetes/net/kubeguard/reset/handlers/main.yml deleted file mode 100644 index bb7fde2b..00000000 --- a/roles/kubernetes/net/kubeguard/reset/handlers/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- name: reload systemd - systemd: - daemon_reload: yes diff --git a/roles/kubernetes/net/kubeguard/reset/tasks/main.yml b/roles/kubernetes/net/kubeguard/reset/tasks/main.yml deleted file mode 100644 index d24f9eff..00000000 --- a/roles/kubernetes/net/kubeguard/reset/tasks/main.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -- name: check if kubeguard interface service unit exists - stat: - path: /etc/systemd/system/kubeguard-interfaces.service - register: kubeguard_interface_unit - -- name: bring down kubeguard interface - systemd: - name: kubeguard-interfaces.service - state: stopped - when: kubeguard_interface_unit.stat.exists - -- name: gather list of all kubeguard related service units - find: - path: /etc/systemd/system/ - patterns: - - "kubeguard-peer-*.service" - - kubeguard-interfaces.service - register: kubeguard_units_installed - -- name: remove all kubeguard related files and directories - loop: "{{ kubeguard_units_installed.files | map(attribute='path') | list | flatten | union(['/var/lib/kubeguard']) }}" - file: - path: "{{ item }}" - state: absent - notify: reload systemd -- cgit v1.2.3