-
Notifications
You must be signed in to change notification settings - Fork 23.9k
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
[WIP] Show deprecation message when using top-level fact vars #41811
base: devel
Are you sure you want to change the base?
Conversation
Test playbook:
Test template:
Output:
|
5c36101
to
66c634e
Compare
72edf59
to
d303be9
Compare
e864008
to
e10f93c
Compare
We don't necessarily need to do it now, but the way I'd originally played with this was updating AnsibleUnsafeX and UnsafeProxy as a more generic "tagged data" wrapper that we could use for various purposes later (eg tracking vars sourced from vault and preventing their display), and wiring it back into the JSON ser/deser stuff so that modules could apply tags as well. My original purpose for this was deprecating return values from modules and firing warnings when they were "touched" by J2 later, which of course implies that the wrappers can be created/preserved inside the modules. Anyway, this doesn't preclude us from doing that later, so I'm +1 for some form of this. |
A more generic "tagged data" wrapper does seem a logical extension of this PR. I already added a |
As a side note, I have a reconfirmed the inability of proxying Edit: I was able to make this work through horrible hacks that involve looking at the calling function and trying to guess if it's part of the JSON encoder. Edit 2: It seems the actual problem with overriding the JSON parser's encoding of certain types is that it will use its own handling for objects that subclass |
e10f93c
to
60041bc
Compare
8c668ca
to
bec8e36
Compare
Aside of given that change - name: (WARN) fact bare variable
debug: var=ansible_hostname
- name: fact via ansible_facts
debug: var=ansible_facts.hostname just as is would make all folks rewriting all - name: Add subnode-0 to inventory
add_host:
name: quux
groups: quxes
ansible_host: qux
ansible_fqdn: baz
ansible_user: bar
ansible_private_key_file: foo Will that qux host be accessible via |
It should not change anything when using |
SUMMARY
Show deprecation message when using top-level fact vars
ISSUE TYPE
COMPONENT NAME
fact vars
ANSIBLE VERSION
ADDITIONAL INFORMATION
A few minor caveats: the deprecation warning doesn't show for something like
debug: var=ansible_processor_count
but does fordebug: var=ansible_processor_count+0
. This appears to be becauseansible.template.AnsibleContext.resolve_or_missing()
isn't being called for "simple" integer values like it is for string/dict/list values. This also does not support showing a warning for boolean values, because Python makes it almost impossible to create abool
-like object that works properly in all cases.