Skip to content

Instantly share code, notes, and snippets.

@bcoca
Created November 1, 2019 15:53
Show Gist options
  • Save bcoca/b96d17b54a6555df636875beaa5d8f69 to your computer and use it in GitHub Desktop.
Save bcoca/b96d17b54a6555df636875beaa5d8f69 to your computer and use it in GitHub Desktop.
diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py
index b53c8d8034..d0b408b68b 100644
--- a/lib/ansible/plugins/filter/core.py
+++ b/lib/ansible/plugins/filter/core.py
@@ -574,6 +574,14 @@ def random_mac(value, seed=None):
rnd = ('%x' % v)[:remain]
return value + re.sub(r'(..)', r':\1', rnd)
+def join_with_string(list_value, join_string):
+
+ return join_string.join(list_value)
+
+def path_join(list_value):
+
+ return os.path.join(list_value)
+
class FilterModule(object):
''' Ansible core jinja2 filters '''
@@ -612,6 +620,7 @@ class FilterModule(object):
'win_basename': partial(unicode_wrap, ntpath.basename),
'win_dirname': partial(unicode_wrap, ntpath.dirname),
'win_splitdrive': partial(unicode_wrap, ntpath.splitdrive),
+ 'path_join': path_join,
# file glob
'fileglob': fileglob,
@@ -666,6 +675,7 @@ class FilterModule(object):
'dict2items': dict_to_list_of_dict_key_value_elements,
'items2dict': list_of_dict_key_value_elements_to_dict,
'subelements': subelements,
+ 'join': join_with_string,
# Misc
'random_mac': random_mac,
lines 1-48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment