1
0
Fork 0
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:
linnil1 2019-03-15 01:34:47 +08:00 committed by Nilashish Chakraborty
parent 8c2037aaa9
commit e9816e10bc

View file

@ -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']: