mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 05:12:45 +00:00
Inventory: raise error when adding a group that already exists.
The parsers check if a group already exists.
This commit is contained in:
@@ -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"):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user