Add APT update playbook

This commit is contained in:
alex-local
2025-09-10 11:04:49 +02:00
parent 24234478bb
commit bb34c1b177

28
apt-update.yml Normal file
View File

@@ -0,0 +1,28 @@
---
- name: APT Update Playbook
hosts: all
become: yes
gather_facts: yes
tasks:
- name: Update apt package cache
ansible.builtin.apt:
update_cache: yes
cache_valid_time: 3600
register: apt_update_result
when: ansible_os_family == "Debian"
- name: Display update result for Debian/Ubuntu systems
ansible.builtin.debug:
msg: "APT cache updated successfully on {{ inventory_hostname }}"
when: ansible_os_family == "Debian" and apt_update_result is succeeded
- name: Skip non-Debian systems
ansible.builtin.debug:
msg: "Skipping {{ inventory_hostname }} - not a Debian/Ubuntu system ({{ ansible_os_family }})"
when: ansible_os_family != "Debian"
- name: Display failure message
ansible.builtin.debug:
msg: "APT update failed on {{ inventory_hostname }}"
when: ansible_os_family == "Debian" and apt_update_result is failed