Thank you Vladimir!

This looks almost good, it finds the package only if no specific version is 
specified.
For example it will find nginx and send email but won't find nginx-1.12.2

On Thursday, August 13, 2020 at 11:09:22 AM UTC-4, Vladimir Botka wrote:
>
> On Thu, 13 Aug 2020 07:20:51 -0700 (PDT) 
> Laci <[email protected] <javascript:>> 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/c90de5b8-7441-46ac-8912-83990d6395dao%40googlegroups.com.

Reply via email to