30 lines
1 KiB
YAML
Executable file
30 lines
1 KiB
YAML
Executable file
#!/usr/bin/env ansible-playbook
|
|
---
|
|
# Check if a reboot is required by the installation of some packages (ie kernel)
|
|
- hosts: localhost
|
|
tasks:
|
|
- name: Make sure local file exist but is empty # weird hack, I know
|
|
copy:
|
|
dest: /tmp/ansible_dump_reboot_needed.txt
|
|
content: ""
|
|
force: true
|
|
|
|
- hosts: all,!unifi,!escalope.adm.auro.re,!loki.adm.auro.re,!viviane.adm.auro.re,!vpn-ovh.adm.auro.re
|
|
tasks:
|
|
# Register the output of the file /var/run/reboot-required.pkgs
|
|
- name: Register if boot is required
|
|
shell: if [ -e /var/run/reboot-required.pkgs ]; then cat /var/run/reboot-required.pkgs; fi
|
|
register: result
|
|
|
|
- name: DEBUG
|
|
debug:
|
|
msg: "{{ ansible_facts['nodename'] }} : {{ result.stdout }}"
|
|
when: result.stdout != ""
|
|
|
|
# Add info line by line
|
|
- name: Dump all info into the local file
|
|
delegate_to: localhost
|
|
lineinfile:
|
|
path: /tmp/ansible_dump_reboot_needed.txt
|
|
line: "{{ ansible_facts['nodename'] }} : {{ result.stdout }}"
|
|
when: result.stdout != ""
|