mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-08 06:13:21 +00:00
Merge pull request #310 from t-woerner/fail_on_duplicate_names
ipa[user,host]: Fail on duplucate names in the users and hosts lists
This commit is contained in:
@@ -799,10 +799,15 @@ def main():
|
||||
server_realm = api_get_realm()
|
||||
|
||||
commands = []
|
||||
host_set = set()
|
||||
|
||||
for host in names:
|
||||
if isinstance(host, dict):
|
||||
name = host.get("name")
|
||||
if name in host_set:
|
||||
ansible_module.fail_json(
|
||||
msg="host '%s' is used more than once" % name)
|
||||
host_set.add(name)
|
||||
description = host.get("description")
|
||||
locality = host.get("locality")
|
||||
location = host.get("location")
|
||||
@@ -1337,6 +1342,8 @@ def main():
|
||||
else:
|
||||
ansible_module.fail_json(msg="Unkown state '%s'" % state)
|
||||
|
||||
del host_set
|
||||
|
||||
# Execute commands
|
||||
|
||||
errors = []
|
||||
|
||||
@@ -958,10 +958,15 @@ def main():
|
||||
# commands
|
||||
|
||||
commands = []
|
||||
user_set = set()
|
||||
|
||||
for user in names:
|
||||
if isinstance(user, dict):
|
||||
name = user.get("name")
|
||||
if name in user_set:
|
||||
ansible_module.fail_json(
|
||||
msg="user '%s' is used more than once" % name)
|
||||
user_set.add(name)
|
||||
# present
|
||||
first = user.get("first")
|
||||
last = user.get("last")
|
||||
@@ -1370,6 +1375,8 @@ def main():
|
||||
else:
|
||||
ansible_module.fail_json(msg="Unkown state '%s'" % state)
|
||||
|
||||
del user_set
|
||||
|
||||
# Execute commands
|
||||
|
||||
errors = []
|
||||
|
||||
Reference in New Issue
Block a user