Ansible task failing with shutdown command on win_command

Viewed 74

I've a playbook to be used to hibernate several machines at once, but if I use it, it will hang on the first host of the list, but will run the command on the first node of the list without problem.

My question is, how can I simply send those commands without waiting for a response from nodes?

Here is the task that I am using:

- name: Hibernate
  win_shell: 'shutdown /h'
1 Answers

If you do not want to wait for the return of a command, you can use asynchronous actions and polling:

If you want to run multiple tasks in a playbook concurrently, use async with poll set to 0. When you set poll: 0, Ansible starts the task and immediately moves on to the next task without waiting for a result. Each async task runs until it either completes, fails or times out (runs longer than its async value). The playbook run ends without checking back on async tasks.

Source: https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html#run-tasks-concurrently-poll-0

So, for your task:

- name: Hibernate
  win_shell: 'shutdown /h'
  async: 45
  poll: 0
Related