--- - name: Pull service facts ansible.builtin.service_facts: - name: 'Remove | Make sure the "old" zabbix-agent service stopped' ansible.builtin.service: name: "zabbix-agent" state: stopped enabled: false become: true when: | ansible_facts.services["zabbix-agent.service"] is defined or ansible_facts.services["zabbix-agent"] is defined - name: "Remove | Package removal" ansible.builtin.package: name: "zabbix-agent" state: absent become: true - name: "Remove | Remove the agent-include-dir" ansible.builtin.file: path: "{{ zabbix_agent_include }}" state: absent become: true