mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Allow groups to be specified using YAML list syntax for add_host
Fixes #12622
This commit is contained in:
parent
af150ea43a
commit
20754c1094
1 changed files with 10 additions and 1 deletions
|
@ -20,6 +20,8 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
from ansible.compat.six import string_types
|
||||||
|
|
||||||
from ansible.plugins.action import ActionBase
|
from ansible.plugins.action import ActionBase
|
||||||
from ansible.parsing.utils.addresses import parse_address
|
from ansible.parsing.utils.addresses import parse_address
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
|
@ -67,7 +69,14 @@ class ActionModule(ActionBase):
|
||||||
# add it to the group if that was specified
|
# add it to the group if that was specified
|
||||||
new_groups = []
|
new_groups = []
|
||||||
if 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:
|
if group_name not in new_groups:
|
||||||
new_groups.append(group_name.strip())
|
new_groups.append(group_name.strip())
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue