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
|
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
|
become: true
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user