2018-07-11 01:12:29 +02:00
|
|
|
---
|
2018-07-23 22:13:55 +02:00
|
|
|
- name: make sure win output dir exists
|
|
|
|
win_file:
|
|
|
|
path: "{{win_output_dir}}"
|
|
|
|
state: directory
|
|
|
|
|
2018-07-11 01:12:29 +02:00
|
|
|
- name: reboot with defaults
|
|
|
|
win_reboot:
|
|
|
|
|
2018-12-11 17:05:10 +01:00
|
|
|
- name: test with negative values for delays
|
|
|
|
win_reboot:
|
|
|
|
post_reboot_delay: -0.5
|
|
|
|
pre_reboot_delay: -61
|
|
|
|
|
2018-07-11 01:12:29 +02:00
|
|
|
- name: schedule a reboot for sometime in the future
|
|
|
|
win_command: shutdown.exe /r /t 599
|
|
|
|
|
|
|
|
- name: reboot with a shutdown already scheduled
|
|
|
|
win_reboot:
|
|
|
|
|
|
|
|
# test a reboot that reboots again during the test_command phase
|
|
|
|
- name: create test file
|
|
|
|
win_file:
|
|
|
|
path: '{{win_output_dir}}\win_reboot_test'
|
|
|
|
state: touch
|
|
|
|
|
|
|
|
- name: reboot with secondary reboot stage
|
|
|
|
win_reboot:
|
2019-04-17 00:38:42 +02:00
|
|
|
test_command: '{{ lookup("template", "post_reboot.ps1") }}'
|
2018-07-11 01:12:29 +02:00
|
|
|
|
2018-12-11 17:05:10 +01:00
|
|
|
- name: reboot with test command that fails
|
|
|
|
win_reboot:
|
|
|
|
test_command: 'FAIL'
|
|
|
|
reboot_timeout: 120
|
|
|
|
register: reboot_fail_test
|
|
|
|
failed_when: "reboot_fail_test.msg != 'Timed out waiting for post-reboot test command (timeout=120)'"
|
|
|
|
|
2019-04-17 00:38:42 +02:00
|
|
|
- name: remove SeRemoteShutdownPrivilege
|
|
|
|
win_user_right:
|
|
|
|
name: SeRemoteShutdownPrivilege
|
|
|
|
users: []
|
|
|
|
action: set
|
|
|
|
register: removed_shutdown_privilege
|
2018-07-11 01:12:29 +02:00
|
|
|
|
|
|
|
- block:
|
2019-04-17 00:38:42 +02:00
|
|
|
- name: try and reboot without required privilege
|
|
|
|
win_reboot:
|
|
|
|
register: fail_privilege
|
|
|
|
failed_when:
|
|
|
|
- "'Reboot command failed, error was:' not in fail_privilege.msg"
|
|
|
|
- "'Access is denied.(5)' not in fail_privilege.msg"
|
2018-07-11 01:12:29 +02:00
|
|
|
|
|
|
|
always:
|
2019-04-17 00:38:42 +02:00
|
|
|
- name: reset the SeRemoteShutdownPrivilege
|
|
|
|
win_user_right:
|
|
|
|
name: SeRemoteShutdownPrivilege
|
|
|
|
users: '{{ removed_shutdown_privilege.removed }}'
|
|
|
|
action: add
|
2018-08-30 15:40:36 +02:00
|
|
|
|
|
|
|
- name: Use invalid parameter
|
|
|
|
reboot:
|
|
|
|
foo: bar
|
2018-12-11 17:05:10 +01:00
|
|
|
ignore_errors: true
|
2018-08-30 15:40:36 +02:00
|
|
|
register: invalid_parameter
|
|
|
|
|
|
|
|
- name: Ensure task fails with error
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- invalid_parameter is failed
|
|
|
|
- "invalid_parameter.msg == 'Invalid options for reboot: foo'"
|