On Thu, 13 Aug 2020 07:20:51 -0700 (PDT)
Laci <[email protected]> wrote:

> I'm looking for a playbook which would scan all servers and if a particular 
> package (ex: kernel-3.10.0-1062 or nginx-1.12.2-2) is installed would send 
> an email with the hostname.
> Did anyone do something alike?

Collect "pkg_facts" and "intersect" the lists. For example

  vars:
    - pkg_list:
        - linux-image-5.4.0-42-generic
        - nginx-1.12.2
  tasks:
    - package_facts:
    - mail:
        subject: Packages found
        body: "{{ send_pkg_list }}"
      when: send_pkg_list|length > 0
      vars:
        send_pkg_list: "{{ ansible_facts.packages.keys()|
                           intersect(pkg_list) }}"



-- 
Vladimir Botka

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200813170904.52992803%40gmail.com.

Attachment: pgpgziW8Zxw1V.pgp
Description: OpenPGP digital signature

Reply via email to