Skip to content

ip4_hex

Collection Note

This module is part of the ansible.utils collection. To install the collection, use:

ansible-galaxy collection install ansible.utils
Added in version 2.5.0.

Synopsis

  • This filter convert IPv4 address to Hexadecimal notation with optional delimiter

Parameters

Parameter Defaults / Choices Comments
arg
str
required
IPv4 address.
delimiter
str
You can provide a single argument to each ip4_hex() filter as delimiter.

Examples

#### examples
# ip4_hex convert IPv4 address to Hexadecimal notation with optional delimiter
- debug:
    msg: "{{ '192.168.1.5' | ansible.utils.ip4_hex }}"

# ip4_hex with delimiter
- debug:
    msg: "{{ '192.168.1.5' | ansible.utils.ip4_hex(':') }}"

# TASK [debug] ************************************************************************************************
# task path: /Users/amhatre/ansible-collections/playbooks/test_ip4_hex.yaml:7
# Loading collection ansible.utils from /Users/amhatre/ansible-collections/collections/ansible_collections/ansible/utils
# ok: [localhost] => {
#     "msg": "c0a80105"
# }
#
# TASK [debug] ************************************************************************************************
# task path: /Users/amhatre/ansible-collections/playbooks/test_ip4_hex.yaml:11
# Loading collection ansible.utils from /Users/amhatre/ansible-collections/collections/ansible_collections/ansible/utils
# ok: [localhost] => {
#     "msg": "c0:a8:01:05"
# }

Return Values

Key Data Type Description Returned
data str Returns IPv4 address to Hexadecimal notation.

Authors

  • Ashwini Mhatre (@amhatre)