1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Inventory: raise error when adding a group that already exists.

The parsers check if a group already exists.
This commit is contained in:
Serge van Ginderachter 2014-03-10 13:06:04 +01:00
parent be58808fe4
commit 188375171e

View file

@ -16,7 +16,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#############################################
import fnmatch
import os
import sys
@ -376,8 +375,11 @@ class Inventory(object):
return vars
def add_group(self, group):
if group.name not in self.groups_list():
self.groups.append(group)
self._groups_list = None # invalidate internal cache
else:
raise errors.AnsibleError("group already in inventory: %s" % group.name)
def list_hosts(self, pattern="all"):