Add random_mac string filter (#39775)

Add new filter to generate random MAC addresses from
string prefix. See docs/docsite/rst/user_guide/playbooks_filters.rst
for more detailed infos.
This commit is contained in:
Olivier Bourdon 2018-06-21 22:56:54 +02:00 committed by Adam Miller
commit 06b73ff8f1
4 changed files with 102 additions and 2 deletions

View file

@ -243,6 +243,22 @@ An example of using this filter with ``loop``::
key: "{{ lookup('file', item.1) }}"
loop: "{{ users|subelements('authorized') }}"
.. _random_mac_filter:
Random Mac Address Filter
`````````````````````````
.. versionadded:: 2.6
This filter can be used to generate a random MAC address from a string prefix.
To get a random MAC address from a string prefix starting with '52:54:00'::
"{{ '52:54:00'|random_mac }}"
# => '52:54:00:ef:1c:03'
Note that if anything is wrong with the prefix string, the filter will issue an error.
.. _random_filter:
Random Number Filter