diff options
author | Tim Way <1091435+timway@users.noreply.github.com> | 2023-04-20 14:01:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-20 15:01:22 -0400 |
commit | 791510ccba5f3a9af3d22f442e9d4d10b1129a00 (patch) | |
tree | 3fc802267c8158f660ca7d8280ece0ba8269584d /docs/docsite | |
parent | ed9cd39d0fa764c2bf51599afef38921aff84b70 (diff) | |
download | ansible-791510ccba5f3a9af3d22f442e9d4d10b1129a00.tar.gz |
Vars Plugin Documentation Improvement (#80470)
Diffstat (limited to 'docs/docsite')
-rw-r--r-- | docs/docsite/rst/dev_guide/developing_plugins.rst | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/docsite/rst/dev_guide/developing_plugins.rst b/docs/docsite/rst/dev_guide/developing_plugins.rst index 25662f018b..e1143cf492 100644 --- a/docs/docsite/rst/dev_guide/developing_plugins.rst +++ b/docs/docsite/rst/dev_guide/developing_plugins.rst @@ -544,6 +544,19 @@ Include the ``vars_plugin_staging`` documentation fragment to allow users to det - vars_plugin_staging ''' +At times a value provided by a vars plugin will contain unsafe values. The utility function `wrap_var` provided by `ansible.utils.unsafe_proxy` should be used to ensure that Ansible handles the variable and value correctly. The use cases for unsafe data is covered in :ref:`unsafe_strings`. + +.. code-block:: python + + from ansible.plugins.vars import BaseVarsPlugin + from ansible.utils.unsafe_proxy import wrap_var + + class VarsPlugin(BaseVarsPlugin): + def get_vars(self, loader, path, entities): + return dict( + something_unsafe=wrap_var("{{ SOMETHING_UNSAFE }}") + ) + For example vars plugins, see the source code for the `vars plugins included with Ansible Core <https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/vars>`_. |