summaryrefslogtreecommitdiff
path: root/roles/kubernetes/net/kubeguard/reset/tasks/main.yml
blob: d24f9eff3878f3d3176b56c8345c567cd0c2c3a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
  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