Last active
August 29, 2015 14:20
-
-
Save rektide/f4bc1f330dc30630fc94 to your computer and use it in GitHub Desktop.
ansible filter module -- arrayitize
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "/opt/ansible-git/bin/ansible-playbook", line 324, in <module> | |
sys.exit(main(sys.argv[1:])) | |
File "/opt/ansible-git/bin/ansible-playbook", line 264, in main | |
pb.run() | |
File "/opt/ansible-git/lib/ansible/playbook/__init__.py", line 310, in run | |
play = Play(self, play_ds, play_basedir, vault_password=self.vault_password) | |
File "/opt/ansible-git/lib/ansible/playbook/play.py", line 124, in __init__ | |
ds = template(basedir, ds, temp_vars) | |
File "/opt/ansible-git/lib/ansible/utils/template.py", line 146, in template | |
d[k] = template(basedir, v, templatevars, lookup_fatal, depth, expand_lists, convert_bare, fail_on_undefined, filter_fatal) | |
File "/opt/ansible-git/lib/ansible/utils/template.py", line 146, in template | |
d[k] = template(basedir, v, templatevars, lookup_fatal, depth, expand_lists, convert_bare, fail_on_undefined, filter_fatal) | |
File "/opt/ansible-git/lib/ansible/utils/template.py", line 127, in template | |
varname = template_from_string(basedir, varname, templatevars, fail_on_undefined) | |
File "/opt/ansible-git/lib/ansible/utils/template.py", line 353, in template_from_string | |
environment.filters.update(_get_filters()) | |
File "/opt/ansible-git/lib/ansible/utils/template.py", line 53, in _get_filters | |
plugins = [ x for x in utils.plugins.filter_loader.all()] | |
File "/opt/ansible-git/lib/ansible/utils/plugins.py", line 233, in all | |
yield getattr(self._module_cache[path], self.class_name)(*args, **kwargs) | |
TypeError: FilterModule() takes exactly 1 argument (0 given) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def arrayitize(*a, **kw): | |
''' Place passed in arguments into an array ''' | |
if len(a) is 1: | |
if type(a[0]) is list: | |
return a | |
elif a[0] is None: | |
return [] | |
val = [] | |
for el in a: | |
val.append(el) | |
return val | |
def FilterModule(object): | |
''' Compfuzor jinja2 filters ''' | |
def filters(self): | |
return { | |
'arrayitize': arrayitize | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment