New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
win_shutdown #406
Comments
This would probably fit best in a win_powerstate module that combines functionality from community.windows.win_wakeonlan and ansible.windows.win_reboot to offer the states: rebooted, started, stopped. |
Shutdown modules have been discussed numerous times in the past and are typically shot down due to several reasons, including but not limited to:
If you're working with a virtual machine, it is preferred to use modules that interact with the hypervisor (e.g. community.vmware) or cloud (e.g. azure.azcollection) to instruct the platform to power off the VM. This is more "desired state" as you can later query the platform via the same modules to ensure the machine is still down. If you really want to remotely shutdown the machine, I propose using an async https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/shutdown |
As per the above, this isn't something that is idempotent in Ansible and has been mentioned before the simple workaround of calling - name: shutdown host
win_command: shutdown.exe /s /f /t 5
async: 30
poll: 0
# This is dependent on the transport you are using the port may differ for WinRM HTTPS or SSH
- name: wait for
wait_for:
host: '{{ hostvars[inventory_hostname]["ansible_host"] | default(inventory_hostname) }}'
port: 5985
state: stopped
delegate_to: localhost |
SUMMARY
Implement a
win_shutdown
module to shut down a remote system. Another idea is to implement as parameter forwin_reboot
ansible moduleISSUE TYPE
COMPONENT NAME
ansible.windows.win_reboot
ADDITIONAL INFORMATION
None
The text was updated successfully, but these errors were encountered: