-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackages.yml
36 lines (30 loc) · 935 Bytes
/
packages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
- name: "Check for packages"
hosts: "{{ hosts | default('localhost') }}"
tasks:
- name: Set command for Redhat
set_fact:
installed_package_cmd: "rpm -qa --qf '%{NAME}\n'"
cron_package_name: "cronie"
when:
ansible_os_family == 'RedHat'
- name: Set command for Debian
set_fact:
installed_package_cmd: "dpkg-query -f '${binary:Package}\n' -W"
cron_package_name: "cron"
when:
ansible_os_family == 'Debian'
- name: Set command for Alpine
set_fact:
installed_package_cmd: "apk info"
cron_package_name: "cronie"
when:
ansible_os_family == 'Alpine'
- name: Gather packages
command: "{{ installed_package_cmd }}"
register: commands
- name: Dump commands
debug:
var: commands
- name: Test for cron
debug:
msg: "cron is {{ 'available' if cron_package_name in commands.stdout_lines else 'not available' }}"