Update playbooks/update_system.yml
This commit is contained in:
@@ -1,5 +1,25 @@
|
||||
- name: Update and Upgrade Packages
|
||||
- name: Check Host Availability
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
|
||||
tasks:
|
||||
- name: Ping hosts to check availability
|
||||
ansible.builtin.ping:
|
||||
register: ping_result
|
||||
ignore_errors: true
|
||||
|
||||
- name: Add reachable hosts to group
|
||||
ansible.builtin.group_by:
|
||||
key: reachable_hosts
|
||||
when: ping_result is succeeded
|
||||
|
||||
- name: Report offline hosts
|
||||
ansible.builtin.debug:
|
||||
msg: "Host {{ inventory_hostname }} is OFFLINE and will be skipped"
|
||||
when: ping_result is failed
|
||||
|
||||
- name: Update and Upgrade Packages
|
||||
hosts: reachable_hosts
|
||||
become: true
|
||||
gather_facts: true
|
||||
|
||||
@@ -16,7 +36,7 @@
|
||||
name: "*"
|
||||
state: latest
|
||||
update_cache: true
|
||||
when:
|
||||
when:
|
||||
- ansible_os_family == "RedHat"
|
||||
- ansible_pkg_mgr == "dnf"
|
||||
|
||||
@@ -25,6 +45,6 @@
|
||||
name: "*"
|
||||
state: latest
|
||||
update_cache: true
|
||||
when:
|
||||
when:
|
||||
- ansible_os_family == "RedHat"
|
||||
- ansible_pkg_mgr == "yum"
|
||||
Reference in New Issue
Block a user