mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
junos_user add condition when user = root (#53111)
* junos_user add condition when user = root * Modify the failure message. Thanks NilashishC.
This commit is contained in:
parent
8c2037aaa9
commit
e9816e10bc
1 changed files with 10 additions and 4 deletions
|
@ -202,11 +202,16 @@ def map_obj_to_ele(module, want):
|
|||
else:
|
||||
operation = 'merge'
|
||||
|
||||
user = SubElement(login, 'user', {'operation': operation})
|
||||
|
||||
SubElement(user, 'name').text = item['name']
|
||||
if item['name'] != 'root':
|
||||
user = SubElement(login, 'user', {'operation': operation})
|
||||
SubElement(user, 'name').text = item['name']
|
||||
else:
|
||||
user = auth = SubElement(element, 'root-authentication', {'operation': operation})
|
||||
|
||||
if operation == 'merge':
|
||||
if item['name'] == 'root' and (not item['active'] or item['role'] or item['full_name']):
|
||||
module.fail_json(msg="'root' account cannot be deactivated or be assigned a role and a full name")
|
||||
|
||||
if item['active']:
|
||||
user.set('active', 'active')
|
||||
else:
|
||||
|
@ -219,7 +224,8 @@ def map_obj_to_ele(module, want):
|
|||
SubElement(user, 'full-name').text = item['full_name']
|
||||
|
||||
if item.get('sshkey'):
|
||||
auth = SubElement(user, 'authentication')
|
||||
if 'auth' not in locals():
|
||||
auth = SubElement(user, 'authentication')
|
||||
if 'ssh-rsa' in item['sshkey']:
|
||||
ssh_rsa = SubElement(auth, 'ssh-rsa')
|
||||
elif 'ssh-dss' in item['sshkey']:
|
||||
|
|
Loading…
Reference in a new issue