community.general.random_mac (8.5.0) — filter

Generate a random MAC address

Authors: unknown

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Generates random networking interfaces MAC addresses for a given prefix.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Random MAC given a prefix
  ansible.builtin.debug:
    msg: "{{ '52:54:00' | community.general.random_mac }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    # => '52:54:00:ef:1c:03'

- name: With a seed
  ansible.builtin.debug:
    msg: "{{ '52:54:00' | community.general.random_mac(seed=inventory_hostname) }}"

Inputs

    
seed:
    description:
    - A randomization seed to initialize the process, used to get repeatable results.
    - If no seed is provided, a system random source such as C(/dev/urandom) is used.
    required: false
    type: string

_input:
    description: A string prefix to use as a basis for the random MAC generated.
    required: true
    type: string

Outputs

_value:
  description: The generated MAC.
  type: string