Skip to content

Latest commit

 

History

History
148 lines (114 loc) · 4.13 KB

ansible.utils.macaddr_filter.rst

File metadata and controls

148 lines (114 loc) · 4.13 KB

ansible.utils.macaddr

macaddr / MAC address filters

Version added: 2.5.0

  • 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.
Parameter Choices/Defaults Configuration Comments
query
string
Default:
""
query string. Example. cisco,linux,unix etc
value
string / required
HW/MAC address.

#### 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"
# }

Common return values are documented here, the following are the fields unique to this filter:

Key Returned Description
data
string
mac/Hw address



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.