-
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
Plugin development documentation requires updates which address handling Unsafe value wrappers #83255
Comments
Files identified in the description: None If these files are incorrect, please update the |
Can you explain more about how you are using the data? If you are using the JSON and YAML encoders included with ansible, then it should be handled for you. Ultimately since we are inverting the trust model, and unsafe won't really be marked as such, we're not recommending any specific general work arounds. The goal is that the devs shouldn't need to concern themselves. |
I have a callback plugin which captures some values from tasks which are completed and serializes those values as YAML for passing to another tool. The specifics of my use case seem unimportant aside from the fact that I'm using the API as described and provided to add this feature and the datatype proxy wrappers as implemented in 2.14.14 (and later?) provide additional obstructions to passing the data to other non-ansible consumers.
Maybe I'm missing where this is spelled out in the documentation. Where are the encoders which are included with ansible that are meant to be used by plugin developers? in 2.14.14 I found that in the devel branch I see that And in either case, even if the documentation had guided me to those ansible provided modules AND the YAML version did work for my case, which it doesn't, I would still have no such guidance for using some other arbitrary serialization library.
I'm glad to hear that the plan is for this not to be a concern for myself as a developer, but it currently is a concern and I've neither found any guidance in the documentation that clears up how this is currently meant to be handled in the release as provided in the current RedHat release. AFAICT my code, which calls the |
>>> import yaml
>>> from ansible.utils.unsafe_proxy import AnsibleUnsafeText
>>> from ansible.parsing.yaml.dumper import AnsibleDumper
>>> yaml.dump({'foo': AnsibleUnsafeText('bar')}, Dumper=AnsibleDumper)
'foo: bar\n' |
Cool, so now you've given an example for YAML, which I truly appreciate, but there is still no real pointer in the documentation that would have directed me to this, nor is there a general solution for serialization beyond YAML and JSON. |
Summary
Since the changes introduced in #82293 it is unclear how plugin developers are meant to intentionally access the the raw value/types which are wrapped in various
AnsibleUnsafe
proxy wrappers. The current ansible code calls a private method_strip_unsafe
against various proxy objects, but that same method is marked for deprecation in the 2.17 release.The documentation would benefit from a clear explanation as to why the unsafe proxy types are used along with some examples of how such objects can be worked with in code paths which require the concrete underlying types. For example, the current developer documentation could demonstrate passing some
AnsibleUnsafe
wrapped values which have been captured in a callback plugin'sv2_runner_on_ok
method to an external JSON/YAML/Protobuf based API.Issue Type
Documentation Report
Component Name
devel/docs/docsite/rst/dev_guide/developing_plugins.rst
Ansible Version
Configuration
OS / Environment
Redhat Enterprise Linux 9.4
Additional Information
Without the documentation guidance as requested I fear that the overall quality of plugins will degrade as various plugin developers reach for a wide range of arcane solutions which may be unnecessary or become broken again in a future release when the next code/logic changes in the proxy wrappers happens.
Code of Conduct
The text was updated successfully, but these errors were encountered: