i need to check more than 100 servers for the snapd package, but I don't like the output at all. I searched all day for different options without luck. Attached is the output of ansible-playbook. Any hints guys?
---
- hosts: centos
become: true
tasks:
- name: Check Hostname
command: /usr/bin/hostname
- name: Check for package if is installed
yum:
list: snapd
register: result
For checking the package version I tried with the following playbook but Ansible doesn't like the syntax:
---
- hosts: test2
become: true
tasks:
- name: Check Hostname
command: /usr/bin/hostname
- name: Check for package if is installed
yum:
list: snapd
register: package_name_version
- name: set package version
set_fact:
package_name_version: "{{ package_name_version.results|selectattr('yumstate','equalto','installed')|map(attribute='version')|list|first }}"
Thanks, Juls
ansible -i <inventory> <target group, lets' say some CentOS systems> -m shell -a "rpm -qa | grep <package name>"
; that would display a list consisting of server name and package version.