--- - name: Collect installed packages facts ansible.builtin.package_facts: manager: rpm - name: Assert that package is installed ansible.builtin.assert: that: "'{{ package_name }}' in ansible_facts.packages|list" fail_msg: "{{ package_name }} is not installed" success_msg: "{{ package_name }} is installed"