'How Do I Prevent Ansible Skipping My win_shell Task?
I have a win_shell task in Ansible to stop certain processes:
- name: Stop Citrix applications
win_shell: (Get-WmiObject Win32_Process | where-Object commandline -match dev-env).terminate
when ansible_connection=winrm
The same code is in more than one role because sometimes someone starts an application during the deploy which can cause a failure to delete a file as it is in use.
So at critical points it makes sure there are no applications running by killing them.
I understand that Ansible will skip tasks if they don't need to be re-run.
e.g. no need to create a directory if it already exists
However, how can it tell that this powershell command doesn't need to be run again, especially as the same code is in 2 different roles?
Jobs are failing because people are starting applications and Ansible is skipping the task.
How do I make Ansible run the task regardless of what it thinks the state is?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|