-
Notifications
You must be signed in to change notification settings - Fork 675
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
Add rule warning about use of run_once with strategy: free #1026
Comments
ansible 2.10 does produce runtime warning about use of This behavior makes the I am inclined to consider |
Just for info, providing what ansible 2.9.x shows as far as the warning message: playbook: ---
- hosts: all
strategy: free
gather_facts: false
tasks:
- debug:
msg: "Test"
run_once: True output from
Perhaps the rule should make the following recommendation to the user... this is in the following docs where it states: When used together with “serial”, tasks marked as “run_once” will be run on one host in each serial batch. If it’s crucial that the task is run only once regardless of “serial” mode, use when: inventory_hostname == ansible_play_hosts_all[0] construct. I would be ok with a rule that gives a warning and leaving it up to the individual to make it an error or leave it as warning. However this does not feel like a deprecation issue, but rather just not supported in the specific situation with strategy=free. Btw, this is another rule where it would be beneficial for lint rules to know a bit more about the context (in this case if the task is within a Play where strategy=free). However, that's a separate enhancement. |
If the rule proposed in the OP will be added, I for one would not want see the above construct as a remedy recommendation. It may work in some cases but in many cases (especially with the |
Summary
It would be useful for ansible-lint to have a rule that warns against the use of
run_once
withstrategy: free
. Ansible ignoresrun_once
with the free strategy which means your tasks are run many times, once for each valid inventory host. Ansible itself does warn against this as well but doesn't fail directly. Being able to catch this early would be great.Issue Type
The text was updated successfully, but these errors were encountered: