def main(): module_args = dnac_argument_spec module_args.update(dhcp_servers=dict(type='list', required=False), group_name=dict(type='str', default='-1')) module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) # Define Local Variables dhcp_servers = module.params['dhcp_servers'] group_name = module.params['group_name'] # Build the payload dictionary payload = [{ "instanceType": "ip", "namespace": "global", "type": "ip.address", "key": "dhcp.server", "value": dhcp_servers, "groupUuid": "-1" }] # instansiate the dnac class dnac = DnaCenter(module) # obtain the groupUuid and update the payload dictionary group_id = dnac.get_group_id(group_name) # Set the api_path dnac.api_path = 'api/v1/commonsetting/global/' + group_id + '?key=dhcp.server' dnac.process_common_settings(payload, group_id)
def main(): module_args = dnac_argument_spec module_args.update(banner_message=dict(type='str', default='', required=False), group_name=dict(type='str', default='-1'), retain_banner=dict(type='bool', default=True)) module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) # Set Local Variables banner_message = module.params['banner_message'] retain_banner = module.params['retain_banner'] group_name = module.params['group_name'] # state = module.params['state'] # Build the payload dictionary payload = [{ "instanceType": "banner", "namespace": "global", "type": "banner.setting", "key": "device.banner", "value": [{ "bannerMessage": banner_message, "retainExistingBanner": retain_banner }], "groupUuid": "-1" }] # instansiate the dnac class dnac = DnaCenter(module) # obtain the groupUuid and update the payload dictionary group_id = dnac.get_group_id(group_name) # set the retain banner attribute if retain_banner: payload[0]['value'][0]['retainExistingBanner'] = True else: payload[0]['value'][0]['retainExistingBanner'] = False # set the api_path dnac.api_path = 'api/v1/commonsetting/global/' + group_id + \ '?key=device.banner' dnac.process_common_settings(payload, group_id)
def main(): module_args = dnac_argument_spec module_args.update(primary_dns_server=dict(type='str', required=False, default=''), secondary_dns_server=dict(type='str', required=False), domain_name=dict(type='str', required=False, default=''), group_name=dict(type='str', required=False, default='-1')) module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) # Define local variables domain_name = module.params['domain_name'] primary_dns_server = module.params['primary_dns_server'] secondary_dns_server = module.params['secondary_dns_server'] group_name = module.params['group_name'] # Build the payload dictionary payload = [{ "instanceType": "dns", "namespace": "global", "type": "dns.setting", "key": "dns.server", "value": [{ "domainName": domain_name, "primaryIpAddress": primary_dns_server, "secondaryIpAddress": secondary_dns_server }], "groupUuid": "-1", }] # instansiate the dnac class dnac = DnaCenter(module) # obtain the groupUuid and update the payload dictionary group_id = dnac.get_group_id(group_name) # Set the api_path dnac.api_path = 'api/v1/commonsetting/global/' + group_id + '?key=dns.server' dnac.process_common_settings(payload, group_id)
def main(): module_args = dnac_argument_spec module_args.update(group_name=dict(type='str', default='-1', required=False), snmp_servers=dict(type='list', required=False), enable_dnac=dict(type='bool', required=False, default=True)) module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) # Set Local Variables snmp_servers = module.params['snmp_servers'] group_name = module.params['group_name'] enable_dnac = module.params['enable_dnac'] # Build the payload dictionary payload = [{ "instanceType": "snmp", "namespace": "global", "type": "snmp.setting", "key": "snmp.trap.receiver", "value": [{ "ipAddresses": snmp_servers, "configureDnacIP": enable_dnac }], "groupUuid": "-1", }] # instansiate the dnac class dnac = DnaCenter(module) # obtain the groupUuid and update the payload dictionary group_id = dnac.get_group_id(group_name) # Set the api path dnac.api_path = 'api/v1/commonsetting/global/' + group_id + '?key=snmp.trap.receiver' # Process Setting Changes dnac.process_common_settings(payload, group_id)
def main(): module_args = dnac_argument_spec module_args.update(timezone=dict(type='str', default='GMT'), group_name=dict(type='str', default='-1'), location=dict(type='str')) module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) # set local variables group_name = module.params['group_name'] location = module.params['location'] timezone = module.params['timezone'] # Build the payload dictionary payload = [{ "instanceType": "timezone", "instanceUuid": "", "namespace": "global", "type": "timezone.setting", "key": "timezone.site", "value": [""], "groupUuid": "-1" }] # instansiate the dnac class dnac = DnaCenter(module) # obtain the groupUuid and update the payload dictionary group_id = dnac.get_group_id(group_name) # update payload with timezone if location: timezone = dnac.timezone_lookup(location) payload[0].update({'value': [timezone]}) # # check if the configuration is already in the desired state dnac.api_path = 'api/v1/commonsetting/global/' + group_id + '?key=timezone.site' # process common settings dnac.process_common_settings(payload, group_id)
def main(): module_args = dnac_argument_spec module_args.update(netflow_collector=dict(type='str', required=False), netflow_port=dict(type='str', required=False), group_name=dict(type='str', default='-1')) module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) # Define local variables group_name = module.params['group_name'] netflow_collector = module.params['netflow_collector'] netflow_port = module.params['netflow_port'] # Build the payload dictionary payload = [{ "instanceType": "netflow", "namespace": "global", "type": "netflow.setting", "key": "netflow.collector", "value": [{ "ipAddress": netflow_collector, "port": netflow_port }], "groupUuid": "-1" }] # instansiate the dnac class dnac = DnaCenter(module) # obtain the groupUuid and update the payload dictionary group_id = dnac.get_group_id(group_name) # set the api_path dnac.api_path = 'api/v1/commonsetting/global/' + group_id + '?key=netflow.collector' dnac.process_common_settings(payload, group_id)