### This is just a sample showing the way of removing apps from a VM using Ansible --- - hosts: all become: yes vars: GOTIFY_IP: xxx #[Your gotify host IP goes here] GOTIFY_PORT: xxx #[Your gotify port goes here] GOTIFY_TOKEN: xxx #[Your app token goes here] tasks: - name: Ansible apt remove crowdsec apt: name: crowdsec state: absent - name: Ansible apt remove zabbix apt: name: zabbix state: absent - name: Ansible apt remove zabbix-agent apt: name: zabbix-agent state: absent - name: Remove dependencies that are no longer required and purge their configuration files ansible.builtin.apt: autoremove: yes purge: true - name: Check if reboot is required stat: path: /var/run/reboot-required register: reboot_required_file - name: Show Output of required reboots debug: msg="{{ reboot_required_file.stat.exists == true }}" - name: Rebooting machine shell: sleep 2 && shutdown -r now "Ansible updates triggered" async: 1 poll: 0 ignore_errors: true when: reboot_required_file.stat.exists - name: Waiting for the machine to come back local_action: wait_for host={{ ansible_host }} state=started port=22 delay=30 become: no when: reboot_required_file.stat.exists - name: notify via Gotify uri: url: 'http://{{ GOTIFY_IP }}:{{ GOTIFY_PORT }}/message?token={{ GOTIFY_TOKEN }}' method: POST body: title: content: APT Packages Update message: content: The remove apps playbook has completed for {{ ansible_host }} and is now updated. A required reboot is {{ reboot_required_file.stat.exists == true }}. priority: content: '5' body_format: form-multipart register: result ...