- name: Install Apache2 without apt hosts: localhost connection: local become: true tasks: - name: Install apache2 using command ansible.builtin.command: apt-get install -y apache2 register: apache_install changed_when: "'is already the newest version' not in apache_install.stdout" - name: fail ansible.builtin.command: /bin/false