From 98f0a9210efae32b54070c9775694509dcf47730 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Thu, 7 Feb 2013 08:11:30 +0100 Subject: [PATCH] Raise an error when multiple when_* statements are provided Fixes #1994. --- lib/ansible/playbook/task.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index 3387c24410..99a557b1e3 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -63,6 +63,8 @@ class Task(object): raise errors.AnsibleError("cannot find lookup plugin named %s for usage in with_%s" % (plugin_name, plugin_name)) elif x.startswith("when_"): + if 'when' in ds: + raise errors.AnsibleError("multiple when_* statements specified in task %s" % (ds.get('name', ds['action']))) when_name = x.replace("when_","") ds['when'] = "%s %s" % (when_name, ds[x]) ds.pop(x)