diff --git a/changelogs/fragments/75-env-vars-modules.yml b/changelogs/fragments/75-env-vars-modules.yml new file mode 100644 index 00000000..529d9a80 --- /dev/null +++ b/changelogs/fragments/75-env-vars-modules.yml @@ -0,0 +1,2 @@ +minor_changes: + - "Allow modules to declare environment variables (https://github.com/ansible-community/antsibull-docs/pull/75)." diff --git a/src/antsibull_docs/data/docsite/list_of_env_variables.rst.j2 b/src/antsibull_docs/data/docsite/list_of_env_variables.rst.j2 index 6d6f27a0..261791b0 100644 --- a/src/antsibull_docs/data/docsite/list_of_env_variables.rst.j2 +++ b/src/antsibull_docs/data/docsite/list_of_env_variables.rst.j2 @@ -11,7 +11,7 @@ Index of all Collection Environment Variables ============================================= -The following index documents all environment variables declared by plugins in collections. +The following index documents all environment variables declared by plugins and modules in collections. Environment variables used by the ansible-core configuration are documented in :ref:`ansible_configuration_settings`. {# TODO: use label `ansible_configuration_env_vars` once the ansible-core PR is merged #} diff --git a/src/antsibull_docs/data/docsite/macros/parameters.rst.j2 b/src/antsibull_docs/data/docsite/macros/parameters.rst.j2 index 07d05f18..0f837aa5 100644 --- a/src/antsibull_docs/data/docsite/macros/parameters.rst.j2 +++ b/src/antsibull_docs/data/docsite/macros/parameters.rst.j2 @@ -99,12 +99,16 @@ :ansible-option-default-bold:`Default:` :ansible-option-default:`@{ value['default'] | antsibull_to_json | rst_escape(escape_ending_whitespace=true) | indent(6, blank=true) }@` {% endif %} {# Configuration #} -{% if plugin_type != 'module' and plugin_type != 'role' and (value['ini'] or value['env'] or value['vars'] or value['cli']) %} +{% if plugin_type != 'role' and (value['ini'] or value['env'] or value['vars'] or value['cli']) %} .. rst-class:: ansible-option-line :ansible-option-configuration:`Configuration:` +{% if plugin_type == 'module' and value['env'] %} + The below environment variable{% if value['env'] | length > 1 %}s{% endif %} will be used on the host that executes this module. + +{% endif %} {% if value['ini'] %} - INI {% if value['ini'] | length == 1 %}entry{% else %}entries{% endif %}: {% for ini in value['ini'] %} @@ -132,7 +136,7 @@ {% endif %} @{ deprecates_rst(env['deprecated'], collection, 8) }@ {% endfor %} -{% for myvar in value['vars'] %} +{% for myvar in value['vars'] | default([]) %} - Variable: @{ myvar['name'] | rst_escape }@ {% if myvar['version_added'] is still_relevant(collection=myvar['version_added_collection'] or collection) %} @@ -140,7 +144,7 @@ {% endif %} @{ deprecates_rst(myvar['deprecated'], collection, 8) }@ {% endfor %} -{% for kw in value['keyword'] %} +{% for kw in value['keyword'] | default([]) %} - Keyword: @{ kw['name'] | rst_escape }@ {% if kw['version_added'] is still_relevant(collection=kw['version_added_collection'] or collection) %} @@ -148,7 +152,7 @@ {% endif %} @{ deprecates_rst(kw['deprecated'], collection, 8) }@ {% endfor %} -{% for mycli in value['cli'] %} +{% for mycli in value['cli'] | default([]) %} - CLI argument: @{ mycli['option'] | rst_escape }@ {% if mycli['version_added'] is still_relevant(collection=mycli['version_added_collection'] or collection) %} @@ -228,8 +232,9 @@

Default: @{ value['default'] | antsibull_to_json | escape | indent(6, blank=true) }@

{% endif %} {# Configuration #} -{% if plugin_type != 'module' and plugin_type != 'role' and (value['ini'] or value['env'] or value['vars'] or value['cli']) %} +{% if plugin_type != 'role' and (value['ini'] or value['env'] or value['vars'] or value['cli']) %}

Configuration:

+

The below environment variable{% if value['env'] | length > 1 %}s{% endif %} will be used on the host that executes this module.