mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
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:
committed by
Adam Miller
parent
5880404151
commit
06b73ff8f1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user