semaphore-test/test.yml
2024-08-27 04:52:13 +00:00

34 lines
1016 B
YAML

---
- name: Test connectivity and gather system information
hosts: all
become: false
tasks:
- name: Update all servers (Debian/Ubuntu)
apt:
upgrade: dist
update_cache: yes
when: ansible_facts['os_family'] == "Debian"
- name: Make sure Zypper is installed (Debian/Ubuntu)
apt:
name: zypper
state: present
when: ansible_facts['os_family'] == "Debian"
- name: See if a reboot is needed for Ubuntu/Debian pct
shell: "needs-restarting -r > /dev/null; echo $?"
register: needsRestartingDebian
changed_when: false
when: ansible_facts['os_family'] == "Debian"
- name: Debug needsRestartingDebian
debug:
msg: "Reboot needed: {{ needsRestartingDebian.stdout }}"
when: ansible_facts['os_family'] == "Debian"
- name: Reboot the server if necessary (Debian/Ubuntu)
reboot:
reboot_timeout: 600
when: ansible_facts['os_family'] == "Debian" and needsRestartingDebian.stdout == "1"