Skip to content

Commit 99d0961

Browse files
authored
Add documentation for module_default (#847)
1 parent bc9fbcb commit 99d0961

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docs/getting_started/how-to-use/modules.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,36 @@ that specify fields that are unique to each tag. Name can be used, but we always
221221
state: "present"
222222
223223
.. warning:: Everything discussed above can be applied to each module, but may need to swap out any arguments for module specific arguments.
224+
225+
Using module default groups
226+
+++++++++++++++++++++++++++++
227+
228+
To avoid having to define the ``netbox_url`` and ``netbox_token`` in each task you can use the module default group feature.
229+
230+
.. code-block:: yaml
231+
232+
---
233+
...
234+
module_defaults:
235+
group/netbox.netbox.netbox:
236+
netbox_url: "http://netbox.local"
237+
netbox_token: "thisIsMyToken"
238+
tasks:
239+
- name: "Example using tags"
240+
netbox.netbox.netbox_device:
241+
data:
242+
name: "Test Device"
243+
tags:
244+
- slug: "my-new-tag1"
245+
- slug: "my-new-tag2"
246+
state: "present"
247+
248+
- name: "Example state: present - Update"
249+
netbox.netbox.netbox_device:
250+
data:
251+
name: "Test Device"
252+
serial: "FXS110011"
253+
state: "present"
254+
255+
.. note::
256+
Module default groups are available from Ansible 2.12.

0 commit comments

Comments
 (0)