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):
self.groups.append(group)
self._groups_list = None # invalidate internal cache
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"):