Trying to reboot an Ubuntu system

57 views
Skip to first unread message

Peter Kaagman

unread,
Feb 17, 2021, 10:51:04 AM2/17/21
to Ansible Project
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

Stefan Hornburg (Racke)

unread,
Feb 17, 2021, 11:08:36 AM2/17/21
to ansible...@googlegroups.com
I don't see "become: yes" in your playbook, so it looks like Ansible simply tries to reboot as regular user.

Regards
Racke
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/8a76f774-e7c0-4679-9418-d9bfbafddd02n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/8a76f774-e7c0-4679-9418-d9bfbafddd02n%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

OpenPGP_signature

Peter Kaagman

unread,
Feb 19, 2021, 4:28:38 AM2/19/21
to Ansible Project
Thanks Racke... that indeed did the trick.
Kinda assumed the -K runtime option took care of that... was wrong :D

Op woensdag 17 februari 2021 om 17:08:36 UTC+1 schreef brae...@gmail.com:
Reply all
Reply to author
Forward
0 new messages