From f6e7381a718cce35ab6ac1b31a1b0f5ef34cb3ef Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Wed, 28 Nov 2012 15:42:09 +0100 Subject: [PATCH] Evaluate only_if in group_by --- lib/ansible/runner/action_plugins/group_by.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/runner/action_plugins/group_by.py b/lib/ansible/runner/action_plugins/group_by.py index d65ec24dd0f..35c39d226ba 100644 --- a/lib/ansible/runner/action_plugins/group_by.py +++ b/lib/ansible/runner/action_plugins/group_by.py @@ -20,7 +20,7 @@ import ansible from ansible.callbacks import vv from ansible.errors import AnsibleError as ae from ansible.runner.return_data import ReturnData -from ansible.utils import parse_kv, template +from ansible.utils import parse_kv, template, check_conditional class ActionModule(object): ''' Create inventory groups based on variables ''' @@ -46,6 +46,8 @@ class ActionModule(object): groups = {} for host in self.runner.host_set: data = inject['hostvars'][host] + if not check_conditional(template(self.runner.basedir, self.runner.conditional, data)): + continue group_name = template(self.runner.basedir, args['key'], data) group_name = group_name.replace(' ','-') if group_name not in groups: