Use single filter for filters
This commit is contained in:
parent
46c86bdb0e
commit
3a5540df5f
21
plays/filter_plugins/filters.py
Normal file
21
plays/filter_plugins/filters.py
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Custom filters for use in playbooks."""
|
||||
|
||||
|
||||
class FilterModule(object):
|
||||
"""Custom Ansible filter plugins."""
|
||||
|
||||
def filters(self):
|
||||
"""Filters list."""
|
||||
return {"update_env": self.filter_update_env}
|
||||
|
||||
def filter_update_env(self, config, new_env):
|
||||
"""Update the config.env dictionary with new keys."""
|
||||
if "env" not in config:
|
||||
return config
|
||||
|
||||
for key, val in new_env.items():
|
||||
config["env"][key] = val
|
||||
|
||||
return config
|
@ -1,16 +0,0 @@
|
||||
"""Update config.env filter."""
|
||||
|
||||
|
||||
def filter_update_env(config, env):
|
||||
if config.get("env", False) is False:
|
||||
return config
|
||||
|
||||
for key, val in env:
|
||||
config["env"][key] = val
|
||||
|
||||
return config
|
||||
|
||||
|
||||
class FilterModule(object):
|
||||
def filters(self):
|
||||
return {"update_env": filter_update_env}
|
Reference in New Issue
Block a user