fatal: [
node-js.atlascollege.nl]: FAILED! => {"changed": false, "elapsed": 0, "msg": "Reboot command failed. Error was Failed to set wall message, ignoring: Interactive authentication required.\r\nFailed to call ScheduleShutdown in logind, proceeding with immediate shutdown: Interactive authentication required.\r\nFailed to set wall message, ignoring: Interactive authentication required.\r\nFailed to reboot system via logind: Interactive authentication required.\r\nFailed to open /dev/initctl: Permission denied\r\nFailed to talk to init daemon., Shared connection to
node-js.atlascollege.nl closed.", "rebooted": false, "start": "2021-02-17T15:19:44.622905"}
Hi there list,
I've been using anible to keep our Ubuntu systems up to date and do some minor maintenace like ensuring certain account are in place....
But I fail on rebooting the system when a reboot is required. And this frustrates me. I end up visiting every system to do the reboot manually.
So far I've tried 2 methods to get the system to reboot:
---
- hosts:
node-js.atlascollege.nl tasks:
# - name: Reboot required?
# shell: /etc/update-motd.d/98-reboot-required
# register: reboot_required
#
- name: Reboot when reboot required
reboot:
# when: reboot_required|bool
# - debug: var=reboot_required.stdout_lines
As you can see I had a condition in place to check for a reboot required. But commented that out to take errors there out of the equation.
This playbook fails with the following error:
fatal: [
node-js.atlascollege.nl]: FAILED! => {"changed": false, "elapsed": 0, "msg": "Reboot command failed. Error was Failed to set wall message, ignoring: Interactive authentication required.\r\nFailed to call ScheduleShutdown in logind, proceeding with immediate shutdown: Interactive authentication required.\r\nFailed to set wall message, ignoring: Interactive authentication required.\r\nFailed to reboot system via logind: Interactive authentication required.\r\nFailed to open /dev/initctl: Permission denied\r\nFailed to talk to init daemon., Shared connection to
node-js.atlascollege.nl closed.", "rebooted": false, "start": "2021-02-17T15:19:44.622905"}
I can see it's complaining about interactive authentication. But I'm under the impression that running the playbook with the -K option would solve this.
The second method is running shutdown via the shell.
---
- hosts:
node-js.atlascollege.nl tasks:
- name: Reboot if required
shell: sleep 10 && /sbin/shutdown -r now "Rebooting for updates"
args:
removes: /var/run/reboot-required
async: 300
poll: 0
- name: Wait for system to come online again
wait_for_connection:
delay: 10
timeout: 300
It's a copy paste of something I found on the internet. It does not return an error. Does not reboot the system. But does leave some syslog messages:
Feb 17 15:14:31 node-js python3[20645]: ansible-command Invoked with removes=/var/run/reboot-required _raw_params=sleep 10 && /sbin/shutdown -r now "Rebooting for updates" _uses_shell=True warn=True stdin_add_newline=True strip_empty_ends=True argv=None chdir=None executable=None creates=None stdin=None
Feb 17 15:14:36 node-js ansible-async_wrapper.py: 20644 still running (300)
Feb 17 15:14:41 node-js ansible-async_wrapper.py: 20644 still running (295)
Feb 17 15:14:41 node-js systemd[1]: Started Session 339 of user pkn.
Feb 17 15:14:41 node-js ansible-async_wrapper.py: Module complete (20644)
Feb 17 15:14:42 node-js python3[20748]: ansible-ping Invoked with data=pong
Feb 17 15:14:46 node-js ansible-async_wrapper.py: Done in kid B.
I would verry much like to use the first mentioned method: the build in reboot. But help on either of the method wil be much appreciated :D
Regards
Peter