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:
parent
be58808fe4
commit
188375171e
1 changed files with 5 additions and 3 deletions
|
@ -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"):
|
||||
|
||||
|
|
Loading…
Reference in a new issue