Update py renderer documentation with information on user-provided context

Update the `py` renderer's documentation to include information on how user-provided context data is typically presented.
This commit is contained in:
Clay Sweetser 2023-03-14 15:15:14 -04:00 committed by Gareth J. Greenaway
parent 4fc4450bf0
commit e8e033a8f7

View file

@ -46,8 +46,23 @@ execution functions, grains, pillar, etc. They are:
``/srv/salt/foo/bar/baz.sls``, then ``__sls__`` in that file will be
``foo.bar.baz``.
When writing a reactor SLS file the global context ``data`` (same as context ``{{ data }}``
for states written with Jinja + YAML) is available. The following YAML + Jinja state declaration:
When used in a scenario where additional user-provided context data is supplied
(such as with :mod:`file.managed <salt.states.file.managed>`), the additional
data will typically be injected into the script as one or more global
variables:
.. code-block:: jinja
/etc/http/conf/http.conf:
file.managed:
- source: salt://apache/generate_http_conf.py
- template: py
- context:
# Will be injected as the global variable "site_name".
site_name: {{ site_name }}
When writing a reactor SLS file the global context ``data`` (same as context
``{{ data }}`` for states written with Jinja + YAML) is available. The
following YAML + Jinja state declaration:
.. code-block:: jinja