You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
774B

  1. ---
  2. - name: reboot
  3. command:
  4. systemd-run --on-active={{reboot_command_after_seconds}}
  5. shutdown -r now "Reboot triggered by Ansible script"
  6. #async: 1
  7. #poll: 0
  8. #ignore_errors: true
  9. when: reboot_command
  10. - name: let server reboot
  11. pause:
  12. seconds: "{{ reboot_pause_seconds }}"
  13. - name: wait for ssh port
  14. wait_for:
  15. host: "{{ ansible_host | default(inventory_hostname) }}"
  16. port: 22
  17. search_regex: OpenSSH
  18. timeout: "{{ reboot_wait_timeout_seconds }}"
  19. vars:
  20. ansible_connection: local
  21. - include_role:
  22. name: ssh_host_key
  23. - name: try to connect to ssh
  24. setup:
  25. - name: check uptime for successful reboot
  26. set_fact:
  27. reboot_uptime: "{{ ansible_uptime_seconds }}"
  28. failed_when: ansible_uptime_seconds > reboot_uptime_max_seconds