mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
filter ipaddr: add custom delimiter option to ip4_hex(); fix format (#26862)
This commit is contained in:
parent
529404adc4
commit
66f654cb64
1 changed files with 2 additions and 2 deletions
|
@ -982,10 +982,10 @@ def _need_netaddr(f_name, *args, **kwargs):
|
|||
'installed on the ansible controller' % f_name)
|
||||
|
||||
|
||||
def ip4_hex(arg):
|
||||
def ip4_hex(arg, delimiter=''):
|
||||
''' Convert an IPv4 address to Hexadecimal notation '''
|
||||
numbers = list(map(int, arg.split('.')))
|
||||
return '{:02x}{:02x}{:02x}{:02x}'.format(*numbers)
|
||||
return '{0:02x}{sep}{1:02x}{sep}{2:02x}{sep}{3:02x}'.format(*numbers, sep=delimiter)
|
||||
|
||||
|
||||
# ---- Ansible filters ----
|
||||
|
|
Loading…
Reference in a new issue