--- - name: Gather the package facts package_facts: manager: auto - name: "[OpenRC] Disable and stop service: hostapd" service: name: hostapd enabled: no state: stopped when: - ansible_service_mgr == "openrc" - name: "[systemd] Disable and stop service: hostapd" systemd: name: hostapd enabled: no state: stopped when: - ansible_service_mgr == "systemd" - "'hostapd' in ansible_facts.packages" - name: "[Alpine] Remove package: hostapd" apk: name: hostapd state: absent when: - ansible_distribution == "Alpine" - name: "[Archlinux] Remove package: hostapd" pacman: name: hostapd state: absent when: - ansible_distribution == "Archlinux" - name: "Remove directory: /etc/hostapd" file: path: /etc/hostapd state: absent