From c0bf1498de7a2472df30869868402d4256e74edc Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Fri, 18 Dec 2020 13:55:15 +0100 Subject: [PATCH] Handle plays without hosts Not all plays have hosts. Most notable is import. While it would be better to actually parse the imported play, this at least prevents a crash. --- obsah/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/obsah/__init__.py b/obsah/__init__.py index 058b024..b19e497 100755 --- a/obsah/__init__.py +++ b/obsah/__init__.py @@ -99,7 +99,7 @@ def takes_target_parameter(self): with open(self.path) as playbook_file: plays = yaml.safe_load(playbook_file.read()) - return any(self.application_config.target_name() in play['hosts'] for play in plays) + return any(self.application_config.target_name() in play.get('hosts', []) for play in plays) @property def playbook_variables(self):