This repository has been archived on 2020-05-07. You can view files and clone it, but cannot push or open issues or pull requests.
dokku-ansible-deploy/plays/filter_plugins/filters.py

35 lines
871 B
Python

#!/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,
"update_vars": self.filter_update_vars,
}
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
def filter_update_vars(self, config, new_vars):
"""Update the config.vars dictionary with new keys."""
if "vars" not in config:
return config
for key, val in new_vars.items():
config["vars"][key] = val
return config