From 66f654cb6417d0f41f1e5f9a90ef8d9165cccb3b Mon Sep 17 00:00:00 2001 From: kokel Date: Wed, 17 Jan 2018 18:49:49 +0100 Subject: [PATCH] filter ipaddr: add custom delimiter option to ip4_hex(); fix format (#26862) --- lib/ansible/plugins/filter/ipaddr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/plugins/filter/ipaddr.py b/lib/ansible/plugins/filter/ipaddr.py index b23d125253..e27e7c4e3b 100644 --- a/lib/ansible/plugins/filter/ipaddr.py +++ b/lib/ansible/plugins/filter/ipaddr.py @@ -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 ----