Skip to content

Plugin development documentation requires updates which address handling Unsafe value wrappers #83255

Open
@drawks

Description

@drawks

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's v2_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

$ ansible --version
ansible [core 2.14.14]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/vagrant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/vagrant/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.18 (main, Jan 24 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Configuration

# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = /etc/ansible/ansible.cfg

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

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions