From 20754c10948a10ffc0f7fc2f167a16cd5577713b Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Sat, 18 Jun 2016 07:46:45 -0500 Subject: [PATCH] Allow groups to be specified using YAML list syntax for add_host Fixes #12622 --- lib/ansible/plugins/action/add_host.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/action/add_host.py b/lib/ansible/plugins/action/add_host.py index b3aec20437e..369be10ef41 100644 --- a/lib/ansible/plugins/action/add_host.py +++ b/lib/ansible/plugins/action/add_host.py @@ -20,6 +20,8 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +from ansible.compat.six import string_types + from ansible.plugins.action import ActionBase from ansible.parsing.utils.addresses import parse_address from ansible.errors import AnsibleError @@ -67,7 +69,14 @@ class ActionModule(ActionBase): # add it to the group if that was specified new_groups = [] if groups: - for group_name in groups.split(","): + if isinstance(groups, list): + group_list = groups + elif isinstance(groups, string_types): + group_list = groups.split(",") + else: + raise AnsibleError("Groups must be specfied as a list.", obj=self._task) + + for group_name in group_list: if group_name not in new_groups: new_groups.append(group_name.strip())