mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07: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:
parent
5880404151
commit
06b73ff8f1
4 changed files with 102 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue