| 123456789101112131415161718192021222324252627282930 |
- ---
- - name: "Gather the package facts ansible.builtin.package_facts"
- hosts: all
- gather_facts: True
- become: true
- tasks:
- - name: Gather the package facts
- package_facts:
- manager: auto
- - name: Print the package facts
- debug:
- var: ansible_facts.packages
- - name: Check whether a package called firewalld is installed
- ansible.builtin.debug:
- msg: "{{ ansible_facts.packages['firewalld'] | length }} versions of firewalld are installed!"
- when: "'firewalld' in ansible_facts.packages"
- - name: Check whether a package called aerhaewrhqwet is installed (True/false)
- ansible.builtin.debug:
- msg: "True"
- when: "'aerhaewrhqwet' in ansible_facts.packages"
- - name: Check whether a package called aerhaewrhqwet is installed (true/False)
- ansible.builtin.debug:
- msg: "False"
- when: "'aerhaewrhqwet' not in ansible_facts.packages"
|