.. _ansible.utils.macaddr_filter: ********************* ansible.utils.macaddr ********************* **macaddr / MAC address filters** Version added: 2.5.0 .. contents:: :local: :depth: 1 Synopsis -------- - This filter check if string is a MAC address and filter it - You can use the macaddr() filter to check if a given string is a MAC address or convert it between various formats. Parameters ---------- .. raw:: html
Parameter Choices/Defaults Configuration Comments
query
string
Default:
""
query string. Example. cisco,linux,unix etc
value
string / required
HW/MAC address.

Examples -------- .. code-block:: yaml #### examples - name: Check if given string is a MAC address debug: msg: "{{ '1a:2b:3c:4d:5e:6f' | ansible.utils.macaddr }}" - name: Convert MAC address to Cisco format debug: msg: "{{ '1a:2b:3c:4d:5e:6f' | ansible.utils.macaddr('cisco') }}" # TASK [Check if given string is a MAC address] *************************************************************** # ok: [localhost] => { # "msg": "1a:2b:3c:4d:5e:6f" # } # # TASK [Convert MAC address to Cisco format] ****************************************************************** # ok: [localhost] => { # "msg": "1a2b.3c4d.5e6f" # } Return Values ------------- Common return values are documented `here `_, the following are the fields unique to this filter: .. raw:: html
Key Returned Description
data
string
mac/Hw address



Status ------ Authors ~~~~~~~ - Ashwini Mhatre (@amhatre) .. hint:: Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.