From 67f284cf96d633a35a4115daf26daae169dd0bb7 Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Sat, 25 Jul 2015 11:28:08 +0200 Subject: [PATCH] Allow notification settings in variables rather than the json file sd_notifications.json (remains as a fallback) --- action_plugins/serverdensity.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/action_plugins/serverdensity.py b/action_plugins/serverdensity.py index fbf2cf5..622d615 100644 --- a/action_plugins/serverdensity.py +++ b/action_plugins/serverdensity.py @@ -332,10 +332,15 @@ class ActionModule(object): def list_notifications(self): if len(self.notifications) == 0: - filename = self.runner.inventory.basedir() + '/sd_notifications.json' - if os.path.exists(filename): - with open(filename, 'r') as content_file: - self.notifications = json.load(content_file) + allgroup = self.runner.inventory.get_group('all') + allvariables = allgroup.get_variables() + if 'sd_notifications' in allvariables: + self.notifications = allvariables.get('sd_notifications') + else: + filename = self.runner.inventory.basedir() + '/sd_notifications.json' + if os.path.exists(filename): + with open(filename, 'r') as content_file: + self.notifications = json.load(content_file) def list_all(self): if self.cache_file_name and os.path.exists(self.cache_file_name): -- GitLab