summaryrefslogtreecommitdiff
path: root/docs/templates/plugin.rst.j2
blob: e3c07604d6c21d6af694e5de2b5f53f6359d02cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
:source: @{ source }@

.. _@{ module }@:

{% if short_description %}
{%   set title = module + ' - ' + short_description|convert_symbols_to_format %}
{% else %}
{%   set title = module %}
{% endif %}

@{ title }@
@{ '+' * title|length }@

{% if version_added is defined and version_added != '' -%}
.. versionadded:: @{ version_added | default('') }@


{% endif %}


.. contents::
   :local:
   :depth: 2

{# ------------------------------------------
 #
 # Please note: this looks like a core dump
 # but it isn't one.
 #
 --------------------------------------------#}
{% if deprecated is defined -%}


DEPRECATED
----------

{# use unknown here? skip the fields? #}
:Removed in Ansible: version: @{ deprecated['removed_in'] | default('') | string | convert_symbols_to_format }@
:Why: @{ deprecated['why'] | default('') | convert_symbols_to_format }@
:Alternative: @{ deprecated['alternative'] | default('')|  convert_symbols_to_format }@


{% endif %}

Synopsis
--------

{% if description %}

{%   if description is string -%}
* @{ description | convert_symbols_to_format }@
{%   else %}
{%     for desc in description -%}
* @{ desc | convert_symbols_to_format }@
{%     endfor %}
{%   endif %}

{% endif %}

{% if aliases is defined -%}

Aliases: @{ ','.join(aliases) }@


{% endif %}

{% if requirements %}
{%   set req_title = 'Requirements' %}
{%   if plugin_type == 'module' %}
{%     set req_title = req_title + ' (on host that executes module)' %}
{%   endif %}
@{ req_title }@
@{ '-' * req_title|length }@

{%   for req in requirements %}
* @{ req | convert_symbols_to_format }@
{%   endfor %}

{% endif %}

{% if options -%}


Options
-------

.. raw:: html

    <table  border=0 cellpadding=0 class="documentation-table">
        {# Header of the documentation #}
        <tr>
            <th class="head"><div class="cell-border">Parameter</div></th>
            <th class="head"><div class="cell-border">Default</div></th>
            <th class="head"><div class="cell-border">Choices</div></th>
            {% if plugin_type != 'module' %}
                <th class="head"><div class="cell-border">Configuration</div></th>
            {% endif %}
            <th class="head"><div class="cell-border">Comments</div></th>
        </tr>
        {% for key, value in options|dictsort recursive %}
            <tr class="return-value-column">
                {# parameter name with introduced label #}
                <td>
                    <div class="outer-elbow-container">
                        {% for i in range(1, loop.depth) %}
                            <div class="elbow-placeholder">
                            </div>
                        {% endfor %}
                        <div class="elbow-key">
                            <b>@{ key }@</b>
                            {% if value.get('required', False) %}<br/><div style="font-size: small; color: red">required</div>{% endif %}
                            {% if value.version_added %}<br/><div style="font-size: small; color: darkgreen">(added in @{value.version_added}@)</div>{% endif %}
                        </div>
                    <div class="outer-elbow-container">
                </td>
                {# default value #}
                <td><div class="cell-border">{% if value.default %}@{ value.default | html_ify }@{% endif %}</div></td>
                {# choices #}
                <td>
                    <div class="cell-border">
                        {% if value.type == 'bool' %}
                            <ul>
                                <li>yes</li>
                                <li>no</li>
                            </ul>
                        {% else %}
                            {% if value.choices %}
                                <ul>
                                    {% for choice in value.choices %}
                                        <li>@{ choice }@</li>
                                    {% endfor %}
                                </ul>
                            {% endif %}
                        {% endif %}
                    </div>
                </td>
                {# configuration #}
                {% if plugin_type != 'module' %}
                    <td>
                        <div class="cell-border">
                            {% if 'ini' in value %}
                                <div> ini entries:
                                    {% for ini in value.ini %}
                                        <p>[@{ ini.section }@ ]<br>@{ ini.key }@ = @{ value.default | default('VALUE') }@</p>
                                    {% endfor %}
                                </div>
                            {% endif %}
                            {% if 'env' in value %}
                                {% for env in value.env %}
                                    <div>env:@{ env.name }@</div>
                                {% endfor %}
                            {% endif %}
                            {% if 'vars' in value %}
                                {% for myvar in value.vars %}
                                    <div>var: @{ myvar.name }@</div>
                                {% endfor %}
                            {% endif %}
                        </div>
                    </td>
                {% endif %}
                {# description #}
                <td>
                    <div class="cell-border">
                        {% if value.description is string %}
                            <div>@{ value.description | replace('\n', '\n    ') | html_ify }@</div>
                        {% else %}
                            {% for desc in value.description %}
                                <div>@{ desc | replace('\n', '\n    ') | html_ify }@</div>
                            {% endfor %}
                        {% endif %}
                        {% if 'aliases' in value and value.aliases %}
                            </br><div style="font-size: small;">aliases: @{ value.aliases|join(', ') }@</div>
                        {% endif %}
                    </div>
                </td>
            </tr>
            {% if value.suboptions %}
                {% if value.suboptions.items %}
                    @{ loop(value.suboptions.items()) }@
                {% elif value.suboptions[0].items %}
                    @{ loop(value.suboptions[0].items()) }@
                {% endif %}
            {% endif %}
        {% endfor %}
    </table>
    </br>

{% endif %}
{% if notes -%}


Notes
-----

.. note::
{%   for note in notes %}
    - @{ note | convert_symbols_to_format }@
{%   endfor %}


{% endif %}
{% if examples or plainexamples -%}


Examples
--------

.. code-block:: yaml

{%   for example in examples %}
{%     if example['description'] %}@{ example['description'] | indent(4, True) }@{% endif %}
@{ example['code'] | escape | indent(4, True) }@
{%   endfor %}
{%   if plainexamples %}@{ plainexamples | indent(4, True) }@{% endif %}
{% endif %}


{% if returndocs -%}


Return Values
-------------

Common return values are documented :ref:`here <common_return_values>`, the following are the fields unique to this @{ plugin_type }@:

.. raw:: html

    <table border=0 cellpadding=0 class="documentation-table">
        <tr>
            <th class="head"><div class="cell-border">Name</div></th>
            <th class="head"><div class="cell-border">Description</div></th>
            <th class="head"><div class="cell-border">Returned</div></th>
            <th class="head"><div class="cell-border">Type</div></th>
            <th class="head"><div class="cell-border">Sample</div></th>
        </tr>
        {% for key, value in returndocs|dictsort recursive %}
            <tr class="return-value-column">
                <td>
                    <div class="outer-elbow-container">
                        {% for i in range(1, loop.depth) %}
                            <div class="elbow-placeholder">
                            </div>
                        {% endfor %}
                        <div class="elbow-key">
                            <b>@{ key }@</b>
                        </div>
                    </div>
                </td>
                <td>
                    {% if value.description is string %}
                        <div class="cell-border">@{ value.description | replace('\n', '\n    ') | html_ify }@</div>
                    {% else %}
                    {% for desc in value.description %}
                        <div class="cell-border">@{ desc | replace('\n', '\n    ') | html_ify }@</div>
                    {% endfor %}
                    {% endif %}
                </td>
                <td><div class="cell-border">@{ value.returned }@</div></td>
                <td><div class="cell-border">@{ value.type }@</div></td>
                <td><div class="cell-border">@{ value.sample | replace('\n', '\n    ') | html_ify }@</div></td>
            </tr>
            {# ---------------------------------------------------------
             # sadly we cannot blindly iterate through the child dicts,
             # since in some documentations,
             # lists are used instead of dicts. This handles both types
             # ---------------------------------------------------------#}
            {% if value.contains %}
                {% if value.contains.items %}
                    @{ loop(value.contains.items()) }@
                {% elif value.contains[0].items %}
                    @{ loop(value.contains[0].items()) }@
                {% endif %}
            {% endif %}
        {% endfor %}
    </table>
    </br></br>
{% endif %}


{% if author is defined -%}


Author
~~~~~~

{%   for author_name in author %}
* @{ author_name }@
{%   endfor %}


{% endif %}
{% if not deprecated %}
{%   set support = { 'core': 'The Ansible Core Team', 'network': 'The Ansible Network Team', 'certified': 'an Ansible Partner', 'community': 'The Ansible Community', 'curated': 'A Third Party'} %}
{%   set module_states = { 'preview': 'it is not guaranteed to have a backwards compatible interface', 'stableinterface': 'the maintainers for this module guarantee that no backward incompatible interface changes will be made'} %}
{%   if metadata %}
{%     if metadata.status %}


Status
~~~~~~

{%       for cur_state in metadata.status %}
This module is flagged as **@{cur_state}@** which means that @{module_states[cur_state]}@.
{%       endfor %}


{%     endif %}
{%     if metadata.supported_by in ('core', 'network') %}


Maintenance Info
~~~~~~~~~~~~~~~~

For more information about Red Hat's support of this @{ plugin_type }@,
please refer to this `Knowledge Base article <https://access.redhat.com/articles/rhel-top-support-policies/>`_

{%     endif %}
{%   endif %}
{% endif %}

If you notice any issues in this documentation you can `edit this document <https://github.com/ansible/ansible/edit/devel/lib/ansible/modules/@{ source }@?description=%3C!---%20Your%20description%20here%20--%3E%0A%0A+label:%20docsite_pr>`_ to improve it.