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
omit does not work in task environment #25678
Comments
Yeah, |
Current documentation states: |
In Id9c4f11b3536e7f9d510f5ef8e6d82a82a96adac we implemented a failed_when condition to ignore the state of the service stop task when `galera_ignore_cluster_state=true` is passed through. Unfortunately, the omit filter does not work in a task context [1], resulting in the task always failing because the omit placeholder string is evaluated as true. This makes the task always fail when running an upgrade. In this patch we change the task flow to evaluate whether a service exists, and if it does then to stop it - otherwise skip that task. This should cater for the rolling replacement use-case and will work in every other situation too. [1] ansible/ansible#25678 Change-Id: Ib26c807057b9114e02ad32c759a5028555788363
You can use something like environment: '{{ env|default(omit, true) }}'
vars:
maybe_env:
FOO: "foo"
BAR: '{{ some_variable | default(omit) }}'
env: '{{ dict(maybe_env|dictsort|rejectattr("1", "eq", omit)) }}' Or compressed: environment: '{{ dict(env|dictsort|rejectattr("1", "eq", omit))|default(omit, true) }}'
vars:
env:
FOO: "foo"
BAR: '{{ some_variable | default(omit) }}' as a workaround |
We discussed this in backlog today and don't plan on implementing the feature since there are workarounds. We may revisit in the future once data tagging is possible. |
ISSUE TYPE
COMPONENT NAME
task
environment
argument (all modules, not specific to a any module)ANSIBLE VERSION
CONFIGURATION
Nothing relevant
OS / ENVIRONMENT
Ubuntu 16.04
SUMMARY
Using the 'some_var | default(omit)' construct in the context of environment values does not work as expected.
If this is not expected to work, the docs should be clearer on this topic, and this bug report should be considered a wishlist item that this construct should be made to work.
STEPS TO REPRODUCE
EXPECTED RESULTS
I expected result.stdout to be entirely empty.
ACTUAL RESULTS
The environment variable was set:
The text was updated successfully, but these errors were encountered: