Note
This module is part of ansible-base
and included in all Ansible installations. In most cases, you can use the short module name reboot even without specifying the collections:
keyword. Despite that, we recommend you use the FQCN for easy linking to the module documentation and to avoid conflicting with other collections that may have the same module name.
New in version 2.7: of ansible.builtin
Note
This module has a corresponding action plugin.
Parameter | Choices/Defaults | Comments |
---|---|---|
boot_time_command string added in 2.10 of ansible.builtin | Default: "cat /proc/sys/kernel/random/boot_id" | Command to run that returns a unique string indicating the last time the system was booted. Setting this to a command that has different output each time it is run will cause the task to fail. |
connect_timeout integer | Maximum seconds to wait for a successful connection to the managed hosts before trying again. If unspecified, the default setting for the underlying connection plugin is used. | |
msg string | Default: "Reboot initiated by Ansible" | Message to display to users before reboot. |
post_reboot_delay integer | Default: 0 | Seconds to wait after the reboot command was successful before attempting to validate the system rebooted successfully. This is useful if you want wait for something to settle despite your connection already working. |
pre_reboot_delay integer | Default: 0 | Seconds to wait before reboot. Passed as a parameter to the reboot command. On Linux, macOS and OpenBSD, this is converted to minutes and rounded down. If less than 60, it will be set to 0. On Solaris and FreeBSD, this will be seconds. |
reboot_command string added in 2.11 of ansible.builtin | Default: "[determined based on target OS]" | Command to run that reboots the system, including any parameters passed to the command. Can be an absolute path to the command or just the command name. If an absolute path to the command is not given, search_paths on the target system will be searched to find the absolute path.This will cause pre_reboot_delay , post_reboot_delay , and msg to be ignored. |
reboot_timeout integer | Default: 600 | Maximum seconds to wait for machine to reboot and respond to a test command. This timeout is evaluated separately for both reboot verification and test command success so the maximum execution time for the module is twice this amount. |
search_paths list / elements=string added in 2.8 of ansible.builtin | Default: ["/sbin", "/bin", "/usr/sbin", "/usr/bin", "/usr/local/sbin"] | Paths to search on the remote machine for the shutdown command.
Only these paths will be searched for the shutdown command. PATH is ignored in the remote node when searching for the shutdown command. |
test_command string | Default: "whoami" | Command to run on the rebooted host and expect success from to determine the machine is ready for further tasks. |
Note
PATH
is ignored on the remote node when searching for the shutdown
command. Use search_paths
to specify locations to search if the default paths do not work.See also
The official documentation on the ansible.windows.win_reboot module.
- name: Unconditionally reboot the machine with all defaults reboot: - name: Reboot a slow machine that might have lots of updates to apply reboot: reboot_timeout: 3600 - name: Reboot a machine with shutdown command in unusual place reboot: search_paths: - '/lib/molly-guard' - name: Reboot machine using a custom reboot command reboot: reboot_command: launchctl reboot userspace boot_time_command: uptime | cut -d ' ' -f 5
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
elapsed integer | always | The number of seconds that elapsed waiting for the system to be rebooted. Sample: 23 |
rebooted boolean | always | true if the machine was rebooted Sample: True |
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/collections/ansible/builtin/reboot_module.html