-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Meta: end_host in Block being triggered despite tags/when statement #68655
Comments
Files identified in the description: If these files are incorrect, please update the |
There is a pull request to allow using tags on meta tasks: #67508
If you have further questions please stop by IRC or the mailing list:
|
@mkrizek before you close it, can you confirm that #41313 is appropriate, considering this isn't necessarily specific to the meta/when issue, but rather that this is inside of a block statement, and somehow the block is being partially triggered, even though it itself has a when statement? Essentially, the meta and the pause/prompt are inside of a block section, which itself has a tag/when statement. And yet, despite the meta being inside of a block, which should only be followed upon tag/when condition match, it's still happening? If the block itself doesn't happen, should tasks contained within the block, even if it is a meta statement? I just want to confirm with you that this is the correct behavior? |
Also, is there a better solution for ending a host that this meta: end_host, at the moment, given this logic I need? Open to suggestions, though this seemed to be the one that documentation suggested. Thank you for your patience, and to the entire team for such a wonderful piece of software. Ansible saves so much time. |
Sorry, I misread.
So only tags is the issue here which is handled in the PR I linked. |
In the case that meta: end_host does support when, then there is an actual bug here. The when statement conditions are not being satisfied, and yet meta: end_host is still being triggered. That's provable in that the pause/prompt isn't triggered, but the meta: end_host is, tags or no tags. Thoughts? |
My example says otherwise. Can you provide a simple reproducer that I can copy and run on my machine? Thank you! |
- hosts: h1, h2
gather_facts: no
tasks:
- debug:
msg: should run on both
- block:
- debug:
msg: should not run on either host
- pause:
seconds: 5
prompt: "ansible"
- meta: end_host
when: False
- debug:
msg: should run on both
|
SUMMARY
We have several tasks in our role that perform some checking, and if a specific set of conditions are met, ends the run for that host, via meta: end_host.
We place these tasks inside of a block section. We also have the block statement being part of tags, and the block section also has a when: statement that must match several conditions. While this has tended to work, I have two of these blocks that are always getting triggered. At first glance, this seemed similar to #64558, but the addition of blocks with when statements guided me to open a separate issue. If it is that the root cause is the same, then please feel to merge the issues.
Example playbook below.
ISSUE TYPE
COMPONENT NAME
meta
when
tags
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
macOS 10.14.6. Target device Windows Server 2016 (though confirmed on Linux target)
Confirmed against physical server across VPN, and local system. Confirmed against local Virtualbox VM. Confirmed against Vagrant.
STEPS TO REPRODUCE
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES; export PYTHONHTTPSVERIFY=0; ansible-playbook -i inventory/hosts -u ansible-control-user -k -l 127.0.0.1 main.yml --tags 'imy-first-tag' -e "someextravariable=content"
EXPECTED RESULTS
I expect that when the conditions are met, the play will end for the host. When the conditions are not met, the play will continue for the host.
ACTUAL RESULTS
When the conditions are met, the play ends for the host. When the conditions are not met, the play ends for the host. However, the pause/prompt does NOT appear, only the end_host is triggered. Similarly, it does not appear with -vvvvv, only a message about:
META: ending play for 127.0.0.1
The text was updated successfully, but these errors were encountered: