@ -71,9 +71,24 @@ options:
disable_my_meraki :
disable_my_meraki :
description : >
description : >
- Disables the local device status pages ( U [ my . meraki . com ] ( my . meraki . com ) , U [ ap . meraki . com ] ( ap . meraki . com ) , U [ switch . meraki . com ] ( switch . meraki . com ) ,
- Disables the local device status pages ( U [ my . meraki . com ] ( my . meraki . com ) , U [ ap . meraki . com ] ( ap . meraki . com ) , U [ switch . meraki . com ] ( switch . meraki . com ) ,
U [ wired . meraki . com ] ( wired . meraki . com ) )
U [ wired . meraki . com ] ( wired . meraki . com ) ) .
- Mutually exclusive of C ( enable_my_meraki ) .
- Will be deprecated in Ansible 2.13 in favor of C ( enable_my_meraki ) .
type : bool
type : bool
version_added : ' 2.7 '
version_added : ' 2.7 '
enable_my_meraki :
description : >
- Enables the local device status pages ( U [ my . meraki . com ] ( my . meraki . com ) , U [ ap . meraki . com ] ( ap . meraki . com ) , U [ switch . meraki . com ] ( switch . meraki . com ) ,
U [ wired . meraki . com ] ( wired . meraki . com ) ) .
- Ansible 2.7 had this parameter as C ( disable_my_meraki ) .
type : bool
version_added : ' 2.9 '
enable_remote_status_page :
description :
- Enables access to the device status page ( U ( http : / / device LAN IP ) ) .
- Can only be set if C ( enable_my_meraki : ) is set to C ( yes ) .
type : bool
version_added : ' 2.9 '
author :
author :
- Kevin Breit ( @kbreit )
- Kevin Breit ( @kbreit )
@ -81,19 +96,19 @@ extends_documentation_fragment: meraki
'''
'''
EXAMPLES = r '''
EXAMPLES = r '''
- delegate_to : localhost
block :
- name : List all networks associated to the YourOrg organization
- name : List all networks associated to the YourOrg organization
meraki_network :
meraki_network :
auth_key : abc12345
auth_key : abc12345
state : query
state : query
org_name : YourOrg
org_name : YourOrg
delegate_to : localhost
- name : Query network named MyNet in the YourOrg organization
- name : Query network named MyNet in the YourOrg organization
meraki_network :
meraki_network :
auth_key : abc12345
auth_key : abc12345
state : query
state : query
org_name : YourOrg
org_name : YourOrg
net_name : MyNet
net_name : MyNet
delegate_to : localhost
- name : Create network named MyNet in the YourOrg organization
- name : Create network named MyNet in the YourOrg organization
meraki_network :
meraki_network :
auth_key : abc12345
auth_key : abc12345
@ -103,7 +118,6 @@ EXAMPLES = r'''
type : switch
type : switch
timezone : America / Chicago
timezone : America / Chicago
tags : production , chicago
tags : production , chicago
delegate_to : localhost
- name : Create combined network named MyNet in the YourOrg organization
- name : Create combined network named MyNet in the YourOrg organization
meraki_network :
meraki_network :
auth_key : abc12345
auth_key : abc12345
@ -122,7 +136,6 @@ EXAMPLES = r'''
org_name : YourOrg
org_name : YourOrg
net_name : MyNet
net_name : MyNet
enable_vlans : yes
enable_vlans : yes
delegate_to : localhost
'''
'''
RETURN = r '''
RETURN = r '''
@ -166,6 +179,11 @@ data:
returned : success
returned : success
type : bool
type : bool
sample : true
sample : true
disableRemoteStatusPage :
description : Disables access to the device status page .
returned : success
type : bool
sample : true
'''
'''
import os
import os
@ -210,8 +228,10 @@ def main():
timezone = dict ( type = ' str ' ) ,
timezone = dict ( type = ' str ' ) ,
net_name = dict ( type = ' str ' , aliases = [ ' name ' , ' network ' ] ) ,
net_name = dict ( type = ' str ' , aliases = [ ' name ' , ' network ' ] ) ,
state = dict ( type = ' str ' , choices = [ ' present ' , ' query ' , ' absent ' ] , default = ' present ' ) ,
state = dict ( type = ' str ' , choices = [ ' present ' , ' query ' , ' absent ' ] , default = ' present ' ) ,
disable_my_meraki = dict ( type = ' bool ' ) ,
enable_vlans = dict ( type = ' bool ' ) ,
enable_vlans = dict ( type = ' bool ' ) ,
disable_my_meraki = dict ( type = ' bool ' , removed_in_version = 2.13 ) ,
enable_my_meraki = dict ( type = ' bool ' ) ,
enable_remote_status_page = dict ( type = ' bool ' ) ,
)
)
# the AnsibleModule object will be our abstraction working with Ansible
# the AnsibleModule object will be our abstraction working with Ansible
@ -220,6 +240,8 @@ def main():
# supports check mode
# supports check mode
module = AnsibleModule ( argument_spec = argument_spec ,
module = AnsibleModule ( argument_spec = argument_spec ,
supports_check_mode = False ,
supports_check_mode = False ,
mutually_exclusive = [ ( ' disable_my_meraki ' , ' enable_my_meraki ' ) ,
]
)
)
meraki = MerakiModule ( module , function = ' network ' )
meraki = MerakiModule ( module , function = ' network ' )
@ -247,6 +269,8 @@ def main():
if not meraki . params [ ' net_name ' ] and not meraki . params [ ' net_id ' ] :
if not meraki . params [ ' net_name ' ] and not meraki . params [ ' net_id ' ] :
if meraki . params [ ' enable_vlans ' ] :
if meraki . params [ ' enable_vlans ' ] :
meraki . fail_json ( msg = " The parameter ' enable_vlans ' requires ' net_name ' or ' net_id ' to be specified " )
meraki . fail_json ( msg = " The parameter ' enable_vlans ' requires ' net_name ' or ' net_id ' to be specified " )
if meraki . params [ ' enable_my_meraki ' ] is True and meraki . params [ ' enable_remote_status_page ' ] is False :
meraki . fail_json ( msg = ' enable_my_meraki must be true when setting enable_remote_status_page ' )
# if the user is working with this module in only check mode we do not
# if the user is working with this module in only check mode we do not
# want to make any changes to the environment, just return the current
# want to make any changes to the environment, just return the current
@ -265,8 +289,19 @@ def main():
payload [ ' tags ' ] = construct_tags ( meraki . params [ ' tags ' ] )
payload [ ' tags ' ] = construct_tags ( meraki . params [ ' tags ' ] )
if meraki . params [ ' timezone ' ] :
if meraki . params [ ' timezone ' ] :
payload [ ' timeZone ' ] = meraki . params [ ' timezone ' ]
payload [ ' timeZone ' ] = meraki . params [ ' timezone ' ]
if meraki . params [ ' disable_my_meraki ' ] is not None :
if meraki . params [ ' enable_my_meraki ' ] is not None :
if meraki . params [ ' enable_my_meraki ' ] is True :
payload [ ' disableMyMerakiCom ' ] = False
else :
payload [ ' disableMyMerakiCom ' ] = True
elif meraki . params [ ' disable_my_meraki ' ] is not None :
payload [ ' disableMyMerakiCom ' ] = meraki . params [ ' disable_my_meraki ' ]
payload [ ' disableMyMerakiCom ' ] = meraki . params [ ' disable_my_meraki ' ]
if meraki . params [ ' enable_remote_status_page ' ] is not None :
if meraki . params [ ' enable_remote_status_page ' ] is True :
payload [ ' disableRemoteStatusPage ' ] = False
# meraki.fail_json(msg="Debug", payload=payload)
else :
payload [ ' disableRemoteStatusPage ' ] = True
# manipulate or modify the state as needed (this is going to be the
# manipulate or modify the state as needed (this is going to be the
# part where your module will do what it needs to do)
# part where your module will do what it needs to do)