I'm simply wanting to create a playbook that will shutdown a windows
computer. I've got my ansible server talking to my windows and can ping it,
but my playbook gives the below error when trying to run. Any ideas?
Playbook:
---
- hosts: winhost
tasks:
- command: shutdown -f -s now
OUTPUT/ERRORS:
sudo ansible-playbook shutdownwindows.yml
PLAY [winhost]
*********************************************************************************************************************************************************
TASK [Gathering Facts]
*************************************************************************************************************************************************
ok: [192.168.2.22]
TASK [win_command]
*****************************************************************************************************************************************************
fatal: [192.168.2.22]: FAILED! => {"changed": true, "cmd": "shutdown -s -f
+1", "delta": "0:00:00.306690", "end": "2020-05-12 08:38:57.644823", "msg":
"non-zero return code", "rc": 1, "start": "2020-05-12 08:38:57.338133",
"stderr": "", "stderr_lines": [], "stdout": "Usage: shutdown [/i | /l | /s
| /sg | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/soft] [/fw] [/f]\n
[/m \\\\computer][/t xxx][/d [p|u:]xx:yy [/c \"comment\"]]\n\n No args
Display help. This is the same as typing /?.\n /? Display
help. This is the same as not typing any options.\n /i Display
the graphical user interface (GUI).\n This must be the first
option.\n /l Log off. This cannot be used with /m or /d
options.\n /s Shutdown the computer.\n /sg Shutdown
the computer. On the next boot,\n restart any registered
applications.\n /r Full shutdown and restart the computer.\n
/g Full shutdown and restart the computer. After the system is\n
rebooted, restart any registered applications.\n /a
Abort a system shutdown.\n This can only be used during the
time-out period.\n Combine with /fw to clear any pending
boots to firmware.\n /p Turn off the local computer with no
time-out or warning.\n Can be used with /d and /f options.\n
/h Hibernate the local computer.\n Can be used with
the /f option.\n /hybrid Performs a shutdown of the computer and
prepares it for fast startup.\n Must be used with /s
option.\n /fw Combine with a shutdown option to cause the next
boot to go to the\n firmware user interface.\n /e
Document the reason for an unexpected shutdown of a computer.\n /o
Go to the advanced boot options menu and restart the computer.\n
Must be used with /r option.\n /m \\\\computer Specify the target
computer.\n /t xxx Set the time-out period before shutdown to xxx
seconds.\n The valid range is 0-315360000 (10 years), with a
default of 30.\n If the timeout period is greater than 0, the
/f parameter is\n implied.\n /c \"comment\" Comment on the
reason for the restart or shutdown.\n Maximum of 512
characters allowed.\n /f Force running applications to close
without forewarning users.\n The /f parameter is implied when
a value greater than 0 is\n specified for the /t
parameter.\n /d [p|u:]xx:yy Provide the reason for the restart or
shutdown.\n p indicates that the restart or shutdown is
planned.\n u indicates that the reason is user defined.\n
If neither p nor u is specified the restart or shutdown is\n
unplanned.\n xx is the major reason number
(positive integer less than 256).\n yy is the minor reason
number (positive integer less than 65536).\n\nReasons on this computer:\n(E
= Expected U = Unexpected P = planned, C = customer
defined)\nType\tMajor\tMinor\tTitle\n\n U \t0\t0\tOther (Unplanned)\nE
\t0\t0\tOther (Unplanned)\nE P \t0\t0\tOther (Planned)\n U \t0\t5\tOther
Failure: System Unresponsive\nE \t1\t1\tHardware: Maintenance
(Unplanned)\nE P \t1\t1\tHardware: Maintenance (Planned)\nE
\t1\t2\tHardware: Installation (Unplanned)\nE P \t1\t2\tHardware:
Installation (Planned)\nE \t2\t2\tOperating System: Recovery
(Unplanned)\nE P \t2\t2\tOperating System: Recovery (Planned)\n P
\t2\t3\tOperating System: Upgrade (Planned)\nE \t2\t4\tOperating System:
Reconfiguration (Unplanned)\nE P \t2\t4\tOperating System: Reconfiguration
(Planned)\n P \t2\t16\tOperating System: Service pack (Planned)\n
\t2\t17\tOperating System: Hot fix (Unplanned)\n P \t2\t17\tOperating
System: Hot fix (Planned)\n \t2\t18\tOperating System: Security fix
(Unplanned)\n P \t2\t18\tOperating System: Security fix (Planned)\nE
\t4\t1\tApplication: Maintenance (Unplanned)\nE P \t4\t1\tApplication:
Maintenance (Planned)\nE P \t4\t2\tApplication: Installation (Planned)\nE
\t4\t5\tApplication: Unresponsive\nE \t4\t6\tApplication: Unstable\n U
\t5\t15\tSystem Failure: Stop error\n U \t5\t19\tSecurity issue
(Unplanned)\nE \t5\t19\tSecurity issue (Unplanned)\nE P \t5\t19\tSecurity
issue (Planned)\nE \t5\t20\tLoss of network connectivity (Unplanned)\n U
\t6\t11\tPower Failure: Cord Unplugged\n U \t6\t12\tPower Failure:
Environment\n P \t7\t0\tLegacy API shutdown\n", "stdout_lines": ["Usage:
shutdown [/i | /l | /s | /sg | /r | /g | /a | /p | /h | /e | /o] [/hybrid]
[/soft] [/fw] [/f]", " [/m \\\\computer][/t xxx][/d [p|u:]xx:yy [/c
\"comment\"]]", "", " No args Display help. This is the same as
typing /?.", " /? Display help. This is the same as not typing
any options.", " /i Display the graphical user interface
(GUI).", " This must be the first option.", " /l
Log off. This cannot be used with /m or /d options.", " /s
Shutdown the computer.", " /sg Shutdown the computer. On the
next boot,", " restart any registered applications.", "
/r Full shutdown and restart the computer.", " /g Full
shutdown and restart the computer. After the system is", "
rebooted, restart any registered applications.", " /a Abort a
system shutdown.", " This can only be used during the
time-out period.", " Combine with /fw to clear any pending
boots to firmware.", " /p Turn off the local computer with no
time-out or warning.", " Can be used with /d and /f
options.", " /h Hibernate the local computer.", "
Can be used with the /f option.", " /hybrid Performs a shutdown of
the computer and prepares it for fast startup.", " Must be
used with /s option.", " /fw Combine with a shutdown option to
cause the next boot to go to the", " firmware user
interface.", " /e Document the reason for an unexpected shutdown
of a computer.", " /o Go to the advanced boot options menu and
restart the computer.", " Must be used with /r option.", "
/m \\\\computer Specify the target computer.", " /t xxx Set the
time-out period before shutdown to xxx seconds.", " The valid
range is 0-315360000 (10 years), with a default of 30.", " If
the timeout period is greater than 0, the /f parameter is", "
implied.", " /c \"comment\" Comment on the reason for the restart or
shutdown.", " Maximum of 512 characters allowed.", " /f
Force running applications to close without forewarning users.", "
The /f parameter is implied when a value greater than 0 is", "
specified for the /t parameter.", " /d [p|u:]xx:yy Provide
the reason for the restart or shutdown.", " p indicates that
the restart or shutdown is planned.", " u indicates that the
reason is user defined.", " If neither p nor u is specified
the restart or shutdown is", " unplanned.", "
xx is the major reason number (positive integer less than 256).", "
yy is the minor reason number (positive integer less than 65536).",
"", "Reasons on this computer:", "(E = Expected U = Unexpected P = planned,
C = customer defined)", "Type\tMajor\tMinor\tTitle", "", " U \t0\t0\tOther
(Unplanned)", "E \t0\t0\tOther (Unplanned)", "E P \t0\t0\tOther
(Planned)", " U \t0\t5\tOther Failure: System Unresponsive", "E
\t1\t1\tHardware: Maintenance (Unplanned)", "E P \t1\t1\tHardware:
Maintenance (Planned)", "E \t1\t2\tHardware: Installation (Unplanned)",
"E P \t1\t2\tHardware: Installation (Planned)", "E \t2\t2\tOperating
System: Recovery (Unplanned)", "E P \t2\t2\tOperating System: Recovery
(Planned)", " P \t2\t3\tOperating System: Upgrade (Planned)", "E
\t2\t4\tOperating System: Reconfiguration (Unplanned)", "E P
\t2\t4\tOperating System: Reconfiguration (Planned)", " P
\t2\t16\tOperating System: Service pack (Planned)", " \t2\t17\tOperating
System: Hot fix (Unplanned)", " P \t2\t17\tOperating System: Hot fix
(Planned)", " \t2\t18\tOperating System: Security fix (Unplanned)", " P
\t2\t18\tOperating System: Security fix (Planned)", "E
\t4\t1\tApplication: Maintenance (Unplanned)", "E P \t4\t1\tApplication:
Maintenance (Planned)", "E P \t4\t2\tApplication: Installation (Planned)",
"E \t4\t5\tApplication: Unresponsive", "E \t4\t6\tApplication:
Unstable", " U \t5\t15\tSystem Failure: Stop error", " U
\t5\t19\tSecurity issue (Unplanned)", "E \t5\t19\tSecurity issue
(Unplanned)", "E P \t5\t19\tSecurity issue (Planned)", "E \t5\t20\tLoss
of network connectivity (Unplanned)", " U \t6\t11\tPower Failure: Cord
Unplugged", " U \t6\t12\tPower Failure: Environment", " P \t7\t0\tLegacy
API shutdown"]}
to retry, use: --limit @/etc/ansible/shutdownwindows.retry
PLAY RECAP
*************************************************************************************************************************************************************
192.168.2.22 : ok=1 changed=0 unreachable=0 failed=1
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/fc680b8b-8ede-4604-979e-17c1b2ead022%40googlegroups.com.