Note
This filter plugin is part of the community.general collection (version 10.7.3).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general.
To use it in a playbook, specify: community.general.random_mac.
This describes the input of the filter, the value before | community.general.random_mac.
Parameter | Comments |
|---|---|
Input string / required | A string prefix to use as a basis for the random MAC generated. |
This describes keyword parameters of the filter. These are the values key1=value1, key2=value2 and so on in the following example: input | community.general.random_mac(key1=value1, key2=value2, ...)
Parameter | Comments |
|---|---|
seed string | A randomization seed to initialize the process, used to get repeatable results. If no seed is provided, a system random source such as |
- name: Random MAC given a prefix
ansible.builtin.debug:
msg: "{{ '52:54:00' | community.general.random_mac }}"
# => '52:54:00:ef:1c:03'
- name: With a seed
ansible.builtin.debug:
msg: "{{ '52:54:00' | community.general.random_mac(seed=inventory_hostname) }}"
Key | Description |
|---|---|
Return value string | The generated MAC. Returned: success |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/random_mac_filter.html