From 32ceaca084f1772083e803b332071aa6e14fef94 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Thu, 16 Apr 2020 12:25:50 +0200 Subject: [PATCH] Allow to update vars --- plays/filter_plugins/filters.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plays/filter_plugins/filters.py b/plays/filter_plugins/filters.py index 2b6fe46..46c4960 100644 --- a/plays/filter_plugins/filters.py +++ b/plays/filter_plugins/filters.py @@ -8,7 +8,10 @@ class FilterModule(object): def filters(self): """Filters list.""" - return {"update_env": self.filter_update_env} + 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.""" @@ -19,3 +22,13 @@ class FilterModule(object): 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