-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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 properly with become #75692
Comments
Files identified in the description:
If these files are incorrect, please update the |
I am not sure if this is something that we want to address yet but potential POC fix might be: diff --git a/lib/ansible/playbook/base.py b/lib/ansible/playbook/base.py
index 564ce0cd3a5..4842b8ce91b 100644
--- a/lib/ansible/playbook/base.py
+++ b/lib/ansible/playbook/base.py
@@ -652,6 +652,13 @@ class FieldAttributeBase(with_metaclass(BaseMeta, object)):
# if this evaluated to the omit value, set the value back to
# the default specified in the FieldAttribute and move on
if omit_value is not None and value == omit_value:
+ if attribute.inherit:
+ setattr(self, name, Sentinel)
+ try:
+ setattr(self, name, self._get_parent_attribute(name))
+ except AttributeError:
+ # PlayContext, the value will be set in TE via PC.set_task_and_variable_override
+ pass
+ continue
if callable(attribute.default):
setattr(self, name, attribute.default())
else: EDIT: diff updated |
The bug is due to 'omit' forcing the keyword to it's default value (none/false), not it's inherited value (yes/true). |
ensure we use context/inheritance when calculating value, using default only when context is unavailable. fixes ansible#75692
* omit keyword should reset to context ensure we use context/inheritance when calculating value, using default only when context is unavailable. fixes #75692
* omit keyword should reset to context ensure we use context/inheritance when calculating value, using default only when context is unavailable. fixes ansible#75692 (cherry picked from commit 9650ddb)
* omit keyword should reset to context ensure we use context/inheritance when calculating value, using default only when context is unavailable. fixes ansible#75692 (cherry picked from commit 9650ddb)
* omit keyword should reset to context ensure we use context/inheritance when calculating value, using default only when context is unavailable. fixes ansible#75692 (cherry picked from commit 9650ddb)
* omit keyword should reset to context (#78917) * omit keyword should reset to context ensure we use context/inheritance when calculating value, using default only when context is unavailable. fixes #75692 (cherry picked from commit 9650ddb) * fixes to FA inheritance (#78990) finalized applies to all field attributes fix getting parent value also remove unused/needed extend/prepend signature moar testing (cherry picked from commit ff6e4da) * setup role needs it's own info
Summary
omit
does not seem to work properly with become.Issue Type
Bug Report
Component Name
become
Ansible Version
Configuration
$ ansible-config dump --only-changed
OS / Environment
Fedora 34
Steps to Reproduce
Expected Results
USER=root in both cases
Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: