ansible/update-vms.yaml

58 lines
1.1 KiB
YAML
Raw Permalink Normal View History

2025-03-16 23:34:04 -06:00
---
- name: Update all VMs
hosts: all
gather_facts: false
strategy: free
become: true
tasks:
- name: Get Package Manager (RPM?)
stat:
path: /usr/bin/dnf
register:
dnf
- name: Get Package Manager (DEB?)
stat:
path: /usr/bin/apt
register:
apt
- name: Get Package Manager (BSD?)
stat:
path: /usr/sbin/pkg
register:
bsd
- name: Get Package Manager (PAC?)
stat:
path: /usr/bin/pacman
register:
pac
- name: Update RPM systems
dnf:
name: "*"
state: latest
update_cache: true
when: dnf.stat.isdir is defined
- name: Update DEB systems
apt:
name: "*"
state: latest
update_cache: yes
when: apt.stat.isdir is defined
- name: Update BSD systems
shell: "pkg update && pkg upgrade -y"
when: bsd.stat.isdir is defined
- name: Update PAC systems
shell: "pacman -Syu --noconfirm"
when: pac.stat.isdir is defined
#- name: Reboot systems (Linux)
#reboot: