@ -35,17 +35,18 @@ description:
configuration that are not explicitly defined .
configuration that are not explicitly defined .
extends_documentation_fragment : eos
extends_documentation_fragment : eos
options :
options :
users :
aggregate :
description :
description :
- The set of username objects to be configured on the remote
- The set of username objects to be configured on the remote
Arista EOS device . The list entries can either be the username
Arista EOS device . The list entries can either be the username
or a hash of username and properties . This argument is mutually
or a hash of username and properties . This argument is mutually
exclusive with the C ( username ) argument .
exclusive with the C ( username ) argument .
version_added : " 2.4 "
username :
username :
description :
description :
- The username to be configured on the remote Arista EOS
- The username to be configured on the remote Arista EOS
device . This argument accepts a stringv value and is mutually
device . This argument accepts a stringv value and is mutually
exclusive with the C ( users ) argument .
exclusive with the C ( aggregate ) argument .
Please note that this option is not same as C ( provider username ) .
Please note that this option is not same as C ( provider username ) .
password :
password :
description :
description :
@ -115,7 +116,7 @@ EXAMPLES = """
- name : set multiple users to privilege level 15
- name : set multiple users to privilege level 15
eos_user :
eos_user :
users :
aggregate :
- username : netop
- username : netop
- username : netend
- username : netend
privilege : 15
privilege : 15
@ -263,8 +264,8 @@ def get_param_value(key, item, module):
return value
return value
def map_params_to_obj ( module ) :
def map_params_to_obj ( module ) :
users = module . params [ ' users ' ]
aggregate = module . params [ ' aggregate ' ]
if not users :
if not aggregate :
if not module . params [ ' username ' ] and module . params [ ' purge ' ] :
if not module . params [ ' username ' ] and module . params [ ' purge ' ] :
return list ( )
return list ( )
elif not module . params [ ' username ' ] :
elif not module . params [ ' username ' ] :
@ -273,7 +274,7 @@ def map_params_to_obj(module):
collection = [ { ' username ' : module . params [ ' username ' ] } ]
collection = [ { ' username ' : module . params [ ' username ' ] } ]
else :
else :
collection = list ( )
collection = list ( )
for item in users :
for item in aggregate :
if not isinstance ( item , dict ) :
if not isinstance ( item , dict ) :
collection . append ( { ' username ' : item } )
collection . append ( { ' username ' : item } )
elif all ( u not in item for u in [ ' username ' , ' name ' ] ) :
elif all ( u not in item for u in [ ' username ' , ' name ' ] ) :
@ -315,7 +316,7 @@ def main():
""" main entry point for module execution
""" main entry point for module execution
"""
"""
argument_spec = dict (
argument_spec = dict (
users = dict ( type = ' list ' , aliases = [ ' collection ' ] ) ,
aggregate = dict ( type = ' list ' , aliases = [ ' collection ' , ' users ' ] ) ,
username = dict ( aliases = [ ' name ' ] ) ,
username = dict ( aliases = [ ' name ' ] ) ,
password = dict ( no_log = True ) ,
password = dict ( no_log = True ) ,
@ -332,7 +333,7 @@ def main():
)
)
argument_spec . update ( eos_argument_spec )
argument_spec . update ( eos_argument_spec )
mutually_exclusive = [ ( ' username ' , ' users ' ) ]
mutually_exclusive = [ ( ' username ' , ' aggregate ' ) ]
module = AnsibleModule ( argument_spec = argument_spec ,
module = AnsibleModule ( argument_spec = argument_spec ,
mutually_exclusive = mutually_exclusive ,
mutually_exclusive = mutually_exclusive ,