Trouble with simple ansible.builtin.reboot

Feel a little silly even having to post this but I can’t get the ansible.builtin.reboot working. It reboots the target no problem, and I’m able to log back in via ssh within 5-10 seconds but the play always fails with:

“msg: Timed out waiting for last boot time check” no matter how long I wait.

ansible [core 2.15.9]

I’ve isolated the task to a single reboot operation like this:

---
- name: Reboot Ubuntu system
  hosts: vps-sandbox01
  gather_facts: false
  become: true

  tasks:
    - name: Reboot the system
      ansible.builtin.reboot:
        reboot_timeout: 30
      ignore_errors: true

Should this work? My other playbooks do updates, running commands that require elevated privileges, etc so I fairly certain my setup is correct. I’m using a non-standard ssh port and an ssh key for my user “ansible”, all directly defined in the /etc/ansible/hosts file:

vps-sandbox01 ansible_host=111.111.111.111 ansible_user=ansible ansible_port=12345 ansible_ssh_private_key_file=/home/jojo/.ssh/ansible/id_ed25519.key

I’m at a loss. When i use -vvv I’m seeing some things that seem odd to me, this is repeated until the connection is closed (when the play reports back failed I guess):

No connection to reset: No ControlPath specified for "-O" command
ansible.builtin.reboot: attempting to get system boot time
<111.111.111.111> ESTABLISH SSH CONNECTION FOR USER: ansible
<111.111.111.111> SSH: EXEC ssh -o StrictHostKeyChecking=accept-new -o Port=12345 -o 'IdentityFile="/home/jojo/.ssh/ansible/id_ed25519.key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ansible"' -o ConnectTimeout=10 -tt 111.111.111.111 '/bin/sh -c '"'"'sudo -H -S -n  -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-tolopbdpehfcyipeyhwqkwahklprjpud ; cat /proc/sys/kernel/random/boot_id'"'"'"'"'"'"'"'"' && sleep 0'"'"''
<111.111.111.111> (255, b'', b'ssh: connect to host 111.111.111.111 port 12345: No route to host\r\n')

Any ideas where I’m going wrong?

Well, it ended up being that particular host. I switched to another host and reboot worked exactly as one would expect… :man_facepalming:

That particular host uses openvz virtualization and I’ve had weird issues with it before, most of my hosts use kvm. I should have checked that before posting but I guess I was too far in the weeds.

1 Like