aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/testbed-setup/ansible/roles/cleanup/tasks/remove_package.yaml
blob: 8f5ec8fefe1f11d8714988399ca6477b528cde65 (plain)
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
27
28
29
30
31
---
# file: roles/cleanup/tasks/remove_package.yaml

- name: Remove package - Fix corrupted apt
  shell: 'dpkg --configure -a'
  when: >
    ansible_distribution == 'Ubuntu'
  tags: remove-package

- name: Remove package - Check if {{ package }} is installed
  shell: >
    "dpkg-query -W -f='${Status}' {{ package }} | grep 'install ok installed'"
  register: package_is_installed
  failed_when: no
  changed_when: no
  when: >
    ansible_distribution == 'Ubuntu'
  tags: remove-package

- name: Remove package - {{ package }}
  apt:
    name: '{{ package }}'
    force: yes
    purge: yes
    state: absent
  when: >
    package is defined and
    package != '' and
    package_is_installed.rc == 0 and
    ansible_distribution|lower == 'ubuntu'
  tags: remove-package