def main(): """ main entry point for module execution """ element_spec = dict( prefix=dict(type='str'), mask=dict(type='str'), next_hop=dict(type='str'), admin_distance=dict(type='int'), state=dict(default='present', choices=['present', 'absent']), check_running_config=dict(default=False, type='bool', fallback=(env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG'])) ) required_one_of = [['aggregate', 'prefix']] required_together = [['prefix', 'next_hop']] mutually_exclusive = [['aggregate', 'prefix']] aggregate_spec = deepcopy(element_spec) aggregate_spec['prefix'] = dict(required=True) remove_default_spec(aggregate_spec) argument_spec = dict( aggregate=dict(type='list', elements='dict', options=aggregate_spec, required_together=required_together), purge=dict(default=False, type='bool') ) argument_spec.update(element_spec) module = AnsibleModule(argument_spec=argument_spec, required_one_of=required_one_of, required_together=required_together, mutually_exclusive=mutually_exclusive, supports_check_mode=True) if not HAS_IPADDRESS: module.fail_json(msg="ipaddress python package is required") warnings = list() result = {'changed': False} if warnings: result['warnings'] = warnings want = map_params_to_obj(module) have = [] if module.params['check_running_config'] is True or module.params['purge'] is True: have = map_config_to_obj(module) commands = map_obj_to_commands(want, have, module) result['commands'] = commands if commands: if not module.check_mode: load_config(module, commands) result['changed'] = True module.exit_json(**result)
def main(): element_spec = dict(group=dict(type='int'), name=dict(type='str'), mode=dict(choices=['dynamic', 'static']), members=dict(type='list'), state=dict(default='present', choices=['present', 'absent']), check_running_config=dict( default=False, type='bool', fallback=(env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG']))) aggregate_spec = deepcopy(element_spec) aggregate_spec['group'] = dict(required=True, type='int') required_one_of = [['group', 'aggregate']] required_together = [['name', 'group']] mutually_exclusive = [['group', 'aggregate']] remove_default_spec(aggregate_spec) argument_spec = dict(aggregate=dict(type='list', elements='dict', options=aggregate_spec, required_together=required_together), purge=dict(default=False, type='bool')) argument_spec.update(element_spec) module = AnsibleModule(argument_spec=argument_spec, required_one_of=required_one_of, required_together=required_together, mutually_exclusive=mutually_exclusive, supports_check_mode=True) warnings = list() result = {'changed': False} if warnings: result['warnings'] = warnings want = map_params_to_obj(module) if module.params['check_running_config'] is False: have = {} else: have = map_config_to_obj(module) commands = map_obj_to_commands((want, have), module) result["commands"] = commands if commands: if not module.check_mode: load_config(module, commands) result['changed'] = True module.exit_json(**result)
def main(): """ Main entry point for Ansible module execution """ server_spec = dict(type=dict(choices=['radius', 'tacacs']), hostname=dict(), auth_port_type=dict(choices=['auth-port']), auth_port_num=dict(), acct_port_num=dict(), acct_type=dict(choices=[ 'accounting-only', 'authentication-only', 'authorization-only', 'default' ]), auth_key=dict(no_log=True), auth_key_type=dict( type='list', choices=['dot1x', 'mac-auth', 'web-auth'])) argument_spec = dict(hostname=dict(), domain_name=dict(type='list'), domain_search=dict(type='list'), name_servers=dict(type='list'), aaa_servers=dict(type='list', elements='dict', options=server_spec), state=dict(choices=['present', 'absent'], default='present'), check_running_config=dict( default=False, type='bool', fallback=(env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG']))) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) result = {'changed': False} warnings = list() result['warnings'] = warnings want = map_params_to_obj(module) have = map_config_to_obj(module) commands = map_obj_to_commands(want, have, module) result['commands'] = commands if commands: if not module.check_mode: load_config(module, commands) result['changed'] = True module.exit_json(**result)
def main(): """entry point for module execution """ argument_spec = dict(banner=dict(required=True, choices=['motd', 'exec', 'incoming']), text=dict(), enterkey=dict(type='bool'), state=dict(default='present', choices=['present', 'absent']), check_running_config=dict( default=False, type='bool', fallback=(env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG']))) required_one_of = [['text', 'enterkey', 'state']] module = AnsibleModule(argument_spec=argument_spec, required_one_of=required_one_of, supports_check_mode=True) warnings = list() results = {'changed': False} want = map_params_to_obj(module) have = map_config_to_obj(module) commands = map_obj_to_commands((want, have), module) results['commands'] = commands if commands: if not module.check_mode: response = load_config(module, commands) results['changed'] = True module.exit_json(**results)
def main(): """ main entry point for module execution """ source_spec = dict( source_mac_address=dict(type='str'), source_mask=dict(type='str'), any=dict(type='bool', default='no') ) destination_spec = dict( destination_mac_address=dict(type='str'), destination_mask=dict(type='str'), any=dict(type='bool', default='no') ) rule_spec = dict( rule_type=dict(type='str', choices=['deny', 'permit'], required=True), source=dict(type='dict', options=source_spec, required=True), destination=dict(type='dict', options=destination_spec, required=True), log=dict(type='bool', default='no'), mirror=dict(type='bool', default='no'), ether_type=dict(type='str'), state=dict(type='str', default='present', choices=['present', 'absent']) ) argument_spec = dict( acl_name=dict(type='str', required=True), accounting=dict(type='str', choices=['enable', 'disable']), rule=dict(type='list', elements='dict', options=rule_spec), state=dict(type='str', default='present', choices=['present', 'absent']) ) required_one_of = [['acl_name', 'rule', 'state']] module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, required_one_of=required_one_of) warnings = list() results = {'changed': False} acl_name = module.params["acl_name"] accounting = module.params["accounting"] rule = module.params["rule"] state = module.params["state"] if warnings: results['warnings'] = warnings commands = build_command(module, acl_name, accounting, rule, state) results['commands'] = commands if commands: if not module.check_mode: response = load_config(module, commands) results['changed'] = True module.exit_json(**results)
def main(): """ main entry point for module execution """ interfaces_spec = dict( name=dict(type='list'), state=dict(choices=['present', 'absent', 'enabled', 'disabled'])) argument_spec = dict( interfaces=dict(type='list', elements='dict', options=interfaces_spec), state=dict(choices=['present', 'absent', 'enabled', 'disabled']), check_running_config=dict( default=False, type='bool', fallback=(env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG']))) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() result = {'changed': False} if warnings: result['warnings'] = warnings commands = [] state = module.params['state'] if state == 'absent': commands.append('no lldp run') elif state == 'present': commands.append('lldp run') if module.params.get('interfaces'): map_obj_to_commands(module, commands) result['commands'] = commands if commands: if not module.check_mode: load_config(module, commands) result['changed'] = True module.exit_json(**result)
def main(): """ main entry point for module execution """ element_spec = dict( dest=dict(type='str', choices=[ 'on', 'host', 'console', 'buffered', 'persistence', 'rfc5424' ]), name=dict(type='str'), udp_port=dict(), level=dict(type='list', choices=[ 'alerts', 'critical', 'debugging', 'emergencies', 'errors', 'informational', 'notifications', 'warnings' ]), facility=dict(type='str', choices=[ 'auth', 'cron', 'daemon', 'kern', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7', 'user', 'lpr', 'mail', 'news', 'syslog', 'sys9', 'sys10', 'sys11', 'sys12', 'sys13', 'sys14', 'user', 'uucp' ]), state=dict(default='present', choices=['present', 'absent']), check_running_config=dict( default=False, type='bool', fallback=(env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG']))) aggregate_spec = deepcopy(element_spec) remove_default_spec(aggregate_spec) argument_spec = dict(aggregate=dict(type='list', elements='dict', options=aggregate_spec), ) argument_spec.update(element_spec) required_if = [('dest', 'host', ['name']), ('dest', 'buffered', ['level'])] module = AnsibleModule(argument_spec=argument_spec, required_if=required_if, supports_check_mode=True) result = {'changed': False} warnings = list() if warnings: result['warnings'] = warnings want = map_params_to_obj(module, required_if=required_if) have = map_config_to_obj(module) result['want'] = want result['have'] = have commands = map_obj_to_commands((want, have)) result['commands'] = commands if commands: if not module.check_mode: load_config(module, commands) result['changed'] = True module.exit_json(**result)
def main(): """ main entry point for module execution """ input_spec = dict(port=dict(type='str'), lag=dict(type='str'), average_rate=dict(type='int', required=True), burst_size=dict(type='int'), state=dict(default='present', choices=['present', 'absent'])) output_spec = dict(port=dict(type='str'), priority_queue=dict(type='int'), value=dict(type='int', required=True), lag=dict(type='str'), state=dict(default='present', choices=['present', 'absent'])) broadcast_spec = dict(port=dict(type='str', required=True), kbps=dict(type='int', required=True), log=dict(type='bool')) unknown_unicast_spec = dict(port=dict(type='str', required=True), kbps=dict(type='int', required=True), log=dict(type='bool')) multicast_spec = dict(port=dict(type='str', required=True), kbps=dict(type='int', required=True), log=dict(type='bool')) arp_spec = dict(number=dict(type='int', required=True), state=dict(default='present', choices=['present', 'absent'])) bum_spec = dict(minutes=dict(type='int', required=True), state=dict(default='present', choices=['present', 'absent'])) element_spec = dict(rate_limit_input=dict(type='dict', options=input_spec), rate_limit_output=dict(type='dict', options=output_spec), rate_limit_arp=dict(type='dict', options=arp_spec), rate_limit_bum=dict(type='dict', options=bum_spec), broadcast_limit=dict(type='dict', options=broadcast_spec), unknown_unicast_limit=dict( type='dict', options=unknown_unicast_spec), multicast_limit=dict(type='dict', options=multicast_spec)) aggregate_spec = deepcopy(element_spec) remove_default_spec(aggregate_spec) argument_spec = dict( aggregate=dict(type='list', elements='dict', options=aggregate_spec)) element_spec.update( check_running_config=dict(default=False, type='bool', fallback=( env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG']))) argument_spec.update(element_spec) required_one_of = [[ 'rate_limit_input', 'rate_limit_output', 'rate_limit_arp', 'rate_limit_bum', 'broadcast_limit', 'unknown_unicast_limit', 'multicast_limit', 'aggregate' ]] module = AnsibleModule(argument_spec=argument_spec, required_one_of=required_one_of, supports_check_mode=True) result = {} result['changed'] = False want = map_params_to_obj(module) result['want'] = want if module.params['check_running_config'] is False: have = [] else: have = map_config_to_obj(module) result['have'] = have commands = map_obj_to_commands((want, have), module) result['commands'] = commands if commands: if not module.check_mode: responses = load_config(module, commands) result['changed'] = True result['responses'] = responses module.exit_json(**result)
def main(): """entry point for module execution """ coa_ignore_spec = dict(state=dict(type='str', default='present', choices=['present', 'absent']), request=dict(type='list', elements='str', required=True, choices=[ 'disable-port', 'dm-request', 'flip-port', 'modify-acl', 'reauth-host' ])) commands_spec = dict( privilege_level=dict(type='int', required=True, choices=[0, 4, 5]), primary_method=dict(type='str', required=True, choices=['radius', 'tacacs+', 'none']), backup_method1=dict(type='str', choices=['radius', 'tacacs+', 'none']), backup_method2=dict(type='str', choices=['none']), state=dict(type='str', default='present', choices=['present', 'absent'])) exec_spec = dict(primary_method=dict(type='str', required=True, choices=['radius', 'tacacs+', 'none']), backup_method1=dict(type='str', choices=['radius', 'tacacs+', 'none']), backup_method2=dict(type='str', choices=['none']), state=dict(type='str', default='present', choices=['present', 'absent'])) argument_spec = dict(coa_ignore=dict(type='dict', options=coa_ignore_spec), coa_enable=dict(type='str', choices=['present', 'absent']), commands=dict(type='dict', options=commands_spec), exec_=dict(type='dict', options=exec_spec)) required_one_of = [['coa_enable', 'coa_ignore', 'commands', 'exec_']] module = AnsibleModule(argument_spec=argument_spec, required_one_of=required_one_of, supports_check_mode=True) warnings = list() results = {'changed': False} coa_enable = module.params["coa_enable"] coa_ignore = module.params["coa_ignore"] commands = module.params["commands"] exec_ = module.params["exec_"] if warnings: results['warnings'] = warnings commands = build_command(module, coa_enable, coa_ignore, commands, exec_) results['commands'] = commands if commands: if not module.check_mode: response = load_config(module, commands) results['changed'] = True module.exit_json(**results)
def main(): """entry point for module execution """ vlan_spec = dict(vlan_num=dict(type='int'), interfaces=dict(type='list', elements='str')) mirror_port_spec = dict(ethernet=dict(type='str'), state=dict(type='str', default='present', choices=['present', 'absent'])) ip_access_group_spec = dict(acl_num=dict(type='int'), acl_name=dict(type='str'), in_out=dict(type='str', choices=['in', 'out']), ethernet=dict(type='str'), lag=dict(type='int'), vlan=dict(type='dict', options=vlan_spec), mirror_port=dict(type='dict', options=mirror_port_spec), logging=dict(type='str', choices=['enable', 'disable']), frag_deny=dict(type='bool', default='no'), state=dict(type='str', default='present', choices=['present', 'absent'])) ipv6_access_group_spec = dict(acl_name=dict(type='str'), in_out=dict(type='str', choices=['in', 'out']), ethernet=dict(type='str'), lag=dict(type='int'), vlan=dict(type='dict', options=vlan_spec), mirror_port=dict(type='dict', options=mirror_port_spec), logging=dict(type='str', choices=['enable', 'disable']), state=dict(type='str', default='present', choices=['present', 'absent'])) mac_access_group_spec = dict(mac_acl_name=dict(type='str', required=True), ethernet=dict(type='str'), lag=dict(type='int'), vlan=dict(type='dict', options=vlan_spec), mirror_port=dict(type='dict', options=mirror_port_spec), logging=dict(type='str', choices=['enable', 'disable']), state=dict(type='str', default='present', choices=['present', 'absent'])) default_acl_spec = dict(ip_type=dict(type='str', required=True, choices=['ipv4', 'ipv6']), acl_name=dict(type='str'), acl_id=dict(type='int'), in_out=dict(type='str', choices=['in', 'out']), state=dict(type='str', default='present', choices=['present', 'absent'])) required_one_of = [['acl_name', 'acl_num', 'frag_deny']] mutually_exclusive = [('acl_name', 'frag_deny'), ('acl_num', 'frag_deny'), ('acl_name', 'acl_num')] argument_spec = dict( ip_access_group=dict(type='dict', options=ip_access_group_spec, required_one_of=required_one_of, mutually_exclusive=mutually_exclusive), ipv6_access_group=dict(type='dict', options=ipv6_access_group_spec), mac_access_group=dict(type='dict', options=mac_access_group_spec), default_acl=dict(type='dict', options=default_acl_spec)) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = {'changed': False} ip_access_group = module.params["ip_access_group"] ipv6_access_group = module.params["ipv6_access_group"] mac_access_group = module.params["mac_access_group"] default_acl = module.params["default_acl"] if warnings: results['warnings'] = warnings commands = build_command(module, ip_access_group, ipv6_access_group, mac_access_group, default_acl) results['commands'] = commands if commands: if not module.check_mode: response = load_config(module, commands) results['changed'] = True module.exit_json(**results)
def main(): """entry point for module execution """ dot1x_spec = dict(primary_method=dict(type='str', required=True, choices=['radius', 'none']), backup_method1=dict(type='str', choices=['none']), state=dict(type='str', default='present', choices=['present', 'absent'])) enable_spec = dict(primary_method=dict(type='str', choices=[ 'enable', 'line', 'local', 'radius', 'tacacs', 'tacacs+', 'none' ]), backup_method_list=dict(type='list', elements='str', choices=[ 'enable', 'line', 'local', 'radius', 'tacacs', 'tacacs+', 'none' ]), implicit_user=dict(type='bool'), state=dict(type='str', default='present', choices=['present', 'absent'])) login_spec = dict(primary_method=dict(type='str', choices=[ 'enable', 'line', 'local', 'radius', 'tacacs', 'tacacs+', 'none' ]), backup_method_list=dict(type='list', elements='str', choices=[ 'enable', 'line', 'local', 'radius', 'tacacs', 'tacacs+', 'none' ]), privilege_mode=dict(type='bool', default=False), state=dict(type='str', default='present', choices=['present', 'absent'])) snmp_server_spec = dict(primary_method=dict(type='str', required=True, choices=[ 'enable', 'line', 'local', 'radius', 'tacacs', 'tacacs+', 'none' ]), backup_method_list=dict(type='list', elements='str', choices=[ 'enable', 'line', 'local', 'radius', 'tacacs', 'tacacs+', 'none' ]), state=dict(type='str', default='present', choices=['present', 'absent'])) web_server_spec = dict(primary_method=dict(type='str', required=True, choices=[ 'enable', 'line', 'local', 'radius', 'tacacs', 'tacacs+', 'none' ]), backup_method_list=dict(type='list', elements='str', choices=[ 'enable', 'line', 'local', 'radius', 'tacacs', 'tacacs+', 'none' ]), state=dict(type='str', default='present', choices=['present', 'absent'])) argument_spec = dict(dot1x=dict(type='dict', options=dot1x_spec), enable=dict(type='dict', options=enable_spec), login=dict(type='dict', options=login_spec), snmp_server=dict(type='dict', options=snmp_server_spec), web_server=dict(type='dict', options=web_server_spec)) required_one_of = [[ 'dot1x', 'enable', 'login', 'snmp_server', 'web_server' ]] module = AnsibleModule(argument_spec=argument_spec, required_one_of=required_one_of, supports_check_mode=True) warnings = list() results = {'changed': False} dot1x = module.params["dot1x"] enable = module.params["enable"] login = module.params["login"] snmp_server = module.params["snmp_server"] web_server = module.params["web_server"] if warnings: results['warnings'] = warnings commands = build_command(module, dot1x, enable, login, snmp_server, web_server) results['commands'] = commands if commands: if not module.check_mode: response = load_config(module, commands) results['changed'] = True module.exit_json(**results)
def main(): """ main entry point for module execution """ stp_spec = dict( type=dict(default='802-1w', choices=['802-1w', 'rstp']), priority=dict(), enabled=dict(type='bool'), ) inter_spec = dict(name=dict(type='list'), purge=dict(type='bool')) tagged_spec = dict(name=dict(type='list'), purge=dict(type='bool')) element_spec = dict(vlan_id=dict(type='int'), name=dict(), interfaces=dict(type='dict', options=inter_spec), tagged=dict(type='dict', options=tagged_spec), ip_dhcp_snooping=dict(type='bool'), ip_arp_inspection=dict(type='bool'), associated_interfaces=dict(type='list'), associated_tagged=dict(type='list'), delay=dict(default=10, type='int'), stp=dict(type='dict', options=stp_spec), state=dict(default='present', choices=['present', 'absent']), check_running_config=dict( default=False, type='bool', fallback=(env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG']))) aggregate_spec = deepcopy(element_spec) aggregate_spec['vlan_id'] = dict(required=True) remove_default_spec(aggregate_spec) argument_spec = dict(aggregate=dict(type='list', elements='dict', options=aggregate_spec), purge=dict(default=False, type='bool')) argument_spec.update(element_spec) required_one_of = [['vlan_id', 'aggregate']] mutually_exclusive = [['vlan_id', 'aggregate']] module = AnsibleModule(argument_spec=argument_spec, required_one_of=required_one_of, mutually_exclusive=mutually_exclusive, supports_check_mode=True) warnings = list() result = {} result['changed'] = False if warnings: result['warnings'] = warnings exec_command(module, 'skip') want = map_params_to_obj(module) result['want'] = want if module.params['check_running_config'] is False: have = [] else: have = map_config_to_obj(module) result['have'] = have commands = map_obj_to_commands((want, have), module) result['commands'] = commands if commands: if not module.check_mode: output = load_config(module, commands) if output: check_fail(module, output) result['output'] = output result['changed'] = True check_declarative_intent_params(want, module, result) module.exit_json(**result)
def main(): """ main entry point for module execution """ power_spec = dict(by_class=dict(choices=['0', '1', '2', '3', '4']), limit=dict(type='str'), priority=dict(choices=['1', '2', '3']), enabled=dict(type='bool')) neighbors_spec = dict(host=dict(), port=dict()) element_spec = dict( name=dict(), description=dict(), enabled=dict(default=True, type='bool'), speed=dict(type='str', choices=[ '10-full', '10-half', '100-full', '100-half', '1000-full', '1000-full-master', '1000-full-slave', '10g-full', '10g-full-master', '10g-full-slave', '2500-full', '2500-full-master', '2500-full-slave', '5g-full', '5g-full-master', '5g-full-slave', 'auto' ]), stp=dict(type='bool'), tx_rate=dict(), rx_rate=dict(), neighbors=dict(type='list', elements='dict', options=neighbors_spec), delay=dict(default=10, type='int'), state=dict(default='present', choices=['present', 'absent', 'up', 'down']), power=dict(type='dict', options=power_spec), check_running_config=dict( default=False, type='bool', fallback=(env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG']))) aggregate_spec = deepcopy(element_spec) aggregate_spec['name'] = dict(required=True) remove_default_spec(aggregate_spec) argument_spec = dict(aggregate=dict(type='list', elements='dict', options=aggregate_spec), ) argument_spec.update(element_spec) required_one_of = [['name', 'aggregate']] mutually_exclusive = [['name', 'aggregate']] module = AnsibleModule(argument_spec=argument_spec, required_one_of=required_one_of, mutually_exclusive=mutually_exclusive, supports_check_mode=True) warnings = list() result = {} result['changed'] = False if warnings: result['warnings'] = warnings want = map_params_to_obj(module) have = map_config_to_obj(module) commands = map_obj_to_commands((want, have)) result['commands'] = commands if commands: if not module.check_mode: load_config(module, commands) result['changed'] = True failed_conditions = check_declarative_intent_params(module, want, result) if failed_conditions: msg = 'One or more conditional statements have not been satisfied' module.fail_json(msg=msg, failed_conditions=failed_conditions) module.exit_json(**result)
def main(): """entry point for module execution """ remark_spec = dict( comment_text=dict(type='str'), state=dict(type='str', default='present', choices=['present', 'absent']) ) source_spec = dict( host_ipv6_address=dict(type='str'), ipv6_prefix_prefix_length=dict(type='str'), any=dict(type='bool') ) source_comparison_operators_spec = dict( operator=dict(type='str', choices=['eq', 'gt', 'lt', 'neq', 'range']), port_num=dict(type='int'), port_name=dict(type='str'), high_port_num=dict(type='int'), high_port_name=dict(type='str') ) destination_spec = dict( host_ipv6_address=dict(type='str'), ipv6_prefix_prefix_length=dict(type='str'), any=dict(type='bool') ) destination_comparison_operators_spec = dict( operator=dict(type='str', choices=['eq', 'gt', 'lt', 'neq', 'range']), port_num=dict(type='int'), port_name=dict(type='str'), high_port_num=dict(type='int'), high_port_name=dict(type='str') ) rules_spec = dict( remark=dict(type='dict', options=remark_spec), seq_num=dict(type='int'), rule_type=dict(type='str', choices=['deny', 'permit'], required=True), ip_protocol_name=dict(type='str', choices=['ahp', 'esp', 'icmp', 'ipv6', 'sctp', 'tcp', 'udp']), ip_protocol_num=dict(type='int'), source=dict(type='dict', required=True, options=source_spec, required_one_of=[['host_ipv6_address', 'ipv6_prefix_prefix_length', 'any']], mutually_exclusive=[['host_ipv6_address', 'ipv6_prefix_prefix_length', 'any']]), source_comparison_operators=dict(type='dict', options=source_comparison_operators_spec), destination=dict(type='dict', required=True, options=destination_spec, required_one_of=[['host_ipv6_address', 'ipv6_prefix_prefix_length', 'any']], mutually_exclusive=[['host_ipv6_address', 'ipv6_prefix_prefix_length', 'any']]), established=dict(type='bool', default='no'), destination_comparison_operators=dict(type='dict', options=destination_comparison_operators_spec), icmp_num=dict(type='int'), icmp_type=dict(type='str', choices=['beyond-scope', 'destination-unreachable', 'echo-reply', 'echo-request', 'header', 'hop-limit', 'mld-query', 'mld-reduction', 'mld-report', 'nd-na', 'nd-ns', 'next-header', 'no-admin', 'no-route', 'packet-too-big', 'parameter-option', 'parameter-problem', 'port-unreachable', 'reassembly-timeout', 'renum-command', 'renum-result', 'renum-seq-number', 'router-advertisement', 'router-renumbering', 'router-solicitation', 'time-exceeded', 'unreachable']), icmp_code=dict(type='int'), fragments=dict(type='bool', default='no'), routing=dict(type='bool', default='no'), dscp_matching=dict(type='int'), dscp_marking=dict(type='int'), priority_matching=dict(type='int'), priority_marking=dict(type='int'), internal_priority_marking=dict(type='int'), traffic_policy_name=dict(type='str'), log=dict(type='bool', default='no'), mirror=dict(type='bool', default='no'), state=dict(type='str', default='present', choices=['present', 'absent']) ) required_one_of = [['ip_protocol_name', 'ip_protocol_num']] mutually_exclusive = [['ip_protocol_name', 'ip_protocol_num']] argument_spec = dict( acl_name=dict(type='str', required=True), accounting=dict(type='str', choices=['enable', 'disable']), rules=dict(type='list', elements='dict', options=rules_spec, required_one_of=required_one_of, mutually_exclusive=mutually_exclusive), state=dict(type='str', default='present', choices=['present', 'absent']) ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = {'changed': False} acl_name = module.params["acl_name"] accounting = module.params["accounting"] rules = module.params["rules"] state = module.params["state"] if warnings: results['warnings'] = warnings commands = build_command(module, acl_name, accounting, rules, state) results['commands'] = commands if commands: if not module.check_mode: response = load_config(module, commands) results['changed'] = True module.exit_json(**results)
def main(): """entry point for module execution """ commands_spec = dict( privilege_level=dict(type='int', required=True, choices=[0, 4, 5]), primary_method=dict(type='str', required=True, choices=['radius', 'tacacs+', 'none']), backup_method1=dict(type='str', choices=['radius', 'tacacs+', 'none']), backup_method2=dict(type='str', choices=['none']), state=dict(type='str', default='present', choices=['present', 'absent'])) dot1x_spec = dict(primary_method=dict(type='str', required=True, choices=['radius', 'none']), backup_method1=dict(type='str', choices=['none']), state=dict(type='str', default='present', choices=['present', 'absent'])) exec_spec = dict(primary_method=dict(type='str', required=True, choices=['radius', 'tacacs+', 'none']), backup_method1=dict(type='str', choices=['radius', 'tacacs+', 'none']), backup_method2=dict(type='str', choices=['none']), state=dict(type='str', default='present', choices=['present', 'absent'])) mac_auth_spec = dict(primary_method=dict(type='str', required=True, choices=['radius', 'none']), backup_method1=dict(type='str', choices=['none']), state=dict(type='str', default='present', choices=['present', 'absent'])) system_spec = dict( primary_method=dict(type='str', required=True, choices=['radius', 'tacacs+', 'none']), backup_method1=dict(type='str', choices=['radius', 'tacacs+', 'none']), backup_method2=dict(type='str', choices=['none']), state=dict(type='str', default='present', choices=['present', 'absent'])) enable_spec = dict(state=dict( type='str', default='present', choices=['present', 'absent'])) argument_spec = dict( commands=dict(type='dict', options=commands_spec), dot1x=dict(type='dict', options=dot1x_spec), exec_=dict(type='dict', options=exec_spec), mac_auth=dict(type='dict', options=mac_auth_spec), system=dict(type='dict', options=system_spec), enable_console=dict(type='dict', options=enable_spec), ) required_one_of = [[ 'commands', 'dot1x', 'exec_', 'mac_auth', 'system', 'enable_console' ]] module = AnsibleModule(argument_spec=argument_spec, required_one_of=required_one_of, supports_check_mode=True) warnings = list() results = {'changed': False} commands = module.params["commands"] dot1x = module.params["dot1x"] exec_ = module.params["exec_"] mac_auth = module.params["mac_auth"] system = module.params["system"] enable_console = module.params["enable_console"] if warnings: results['warnings'] = warnings commands = build_command(module, commands, dot1x, exec_, mac_auth, system, enable_console) results['commands'] = commands if commands: if not module.check_mode: response = load_config(module, commands) results['changed'] = True module.exit_json(**results)
def main(): """ main entry point for module execution """ egress_buffer_profile_7150_spec = dict( port_share_level=dict(type='str', choices=['level3-1/16', 'level4-1/9', 'level5-1/5', 'level6-1/3', 'level7-1/2', 'level8-2/3']), user_profile_name=dict(type='str'), state=dict(default='present', choices=['present', 'absent']) ) egress_buffer_profile_7x50_spec = dict( queue_share_level=dict(type='str', choices=['level1-1/64', 'level2-1/32', 'level3-1/16', 'level4-1/9', 'level5-1/5', 'level6-1/3', 'level7-1/2', 'level8-2/3']), user_profile_name=dict(type='str'), queue_number=dict(type='int'), state=dict(default='present', choices=['present', 'absent']) ) egress_shape_ifg_bytes_spec = dict( value_in_bytes=dict(type='int'), state=dict(default='present', choices=['present', 'absent']) ) ingress_buffer_profile_spec = dict( user_profile_name=dict(type='str'), priority_group_number=dict(type='int'), shared_level=dict(type='str', choices=['level1-1/64', 'level2-1/32', 'level3-1/16', 'level4-1/9', 'level5-1/5', 'level6-1/3', 'level7-1/2']), state=dict(default='present', choices=['present', 'absent']) ) mechanism_spec = dict( queueing_method=dict(type='str', choices=['strict', 'weighted', 'mixed-sp-wrr']), state=dict(default='present', choices=['present', 'absent']) ) monitor_queue_drop_counters_spec = dict( port_id=dict(type='str'), state=dict(default='present', choices=['present', 'absent']) ) queue_name_spec = dict( old_name=dict(type='str'), new_name=dict(type='str') ) priority_to_pg_spec = dict( priority0=dict(type='int', choices=[0, 1, 2]), priority1=dict(type='int', choices=[0, 1, 2]), priority2=dict(type='int', choices=[0, 1, 2]), priority3=dict(type='int', choices=[0, 1, 2]), priority4=dict(type='int', choices=[0, 1, 2]), priority5=dict(type='int', choices=[0, 1, 2]), priority6=dict(type='int', choices=[0, 1, 2, 3]), priority7=dict(type='int', choices=[0, 1, 2, 3, 4]), state=dict(default='present', choices=['present', 'absent']) ) profile_spec = dict( percentage0=dict(type='int'), percentage1=dict(type='int'), percentage2=dict(type='int'), percentage3=dict(type='int'), percentage4=dict(type='int'), percentage5=dict(type='int'), percentage6=dict(type='int'), percentage7=dict(type='int'), state=dict(default='present', choices=['present', 'absent']) ) scheduler_profile_spec = dict( user_profile_name=dict(type='str'), scheduling_mechanism=dict(type='str', choices=['mixed-sp-wrr', 'strict', 'weighted']), wt0=dict(type='int'), wt1=dict(type='int'), wt2=dict(type='int'), wt3=dict(type='int'), wt4=dict(type='int'), wt5=dict(type='int'), wt6=dict(type='int'), wt7=dict(type='int'), state=dict(default='present', choices=['present', 'absent']) ) sflow_set_cpu_rate_limit_spec = dict( packet_rate=dict(type='int'), burst_size=dict(type='int'), state=dict(default='present', choices=['present', 'absent']) ) tagged_priority_spec = dict( num=dict(type='int'), queue=dict(type='str'), state=dict(default='present', choices=['present', 'absent']) ) internal_trunk_queue_spec = dict( level=dict(type='str', choices=['level1-1/64', 'level2-1/32', 'level3-1/16', 'level4-1/9', 'level5-1/5', 'level6-1/3', 'level7-1/2', 'level8-2/3']), queue=dict(type='int'), state=dict(default='present', choices=['present', 'absent']) ) attach_egress_buffer_profile_spec = dict( port=dict(type='str'), profile_name=dict(type='str'), state=dict(default='present', choices=['present', 'absent']) ) dscp_priority_spec = dict( dscp_value=dict(type='list', elements='str'), priority=dict(type='str'), state=dict(default='present', choices=['present', 'absent']) ) argument_spec = dict( egress_buffer_profile_7150=dict(type='dict', options=egress_buffer_profile_7150_spec), egress_buffer_profile_7X50=dict(type='dict', options=egress_buffer_profile_7x50_spec), egress_shape_ifg_bytes=dict(type='dict', options=egress_shape_ifg_bytes_spec), ingress_buffer_profile=dict(type='dict', options=ingress_buffer_profile_spec), mechanism=dict(type='dict', options=mechanism_spec), monitor_queue_drop_counters=dict(type='dict', options=monitor_queue_drop_counters_spec), queue_name=dict(type='dict', options=queue_name_spec), priority_to_pg=dict(type='dict', options=priority_to_pg_spec), profile=dict(type='dict', options=profile_spec), scheduler_profile=dict(type='dict', options=scheduler_profile_spec), sflow_set_cpu_rate_limit=dict(type='dict', options=sflow_set_cpu_rate_limit_spec), tagged_priority=dict(type='dict', options=tagged_priority_spec), internal_trunk_queue=dict(type='dict', options=internal_trunk_queue_spec), attach_egress_buffer_profile=dict(type='dict', options=attach_egress_buffer_profile_spec), dscp_priority=dict(type='dict', options=dscp_priority_spec), check_running_config=dict(default=False, type='bool', fallback=(env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG'])) ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) result = {} result['changed'] = False want = map_params_to_obj(module) result['want'] = want if module.params['check_running_config'] is False: have = [] else: have = map_config_to_obj(module) result['have'] = have commands = map_obj_to_commands((want, have), module) result['commands'] = commands if commands: if not module.check_mode: output = load_config(module, commands) if output: check_fail(module, output) result['output'] = output result['changed'] = True module.exit_json(**result)
def main(): """entry point for module execution """ element_spec = dict(name=dict(), configured_password=dict(no_log=True), nopassword=dict(type='bool', default=False), update_password=dict(default='always', choices=['on_create', 'always']), privilege=dict(type='str', choices=['0', '4', '5']), access_time=dict(type='str'), state=dict(default='present', choices=['present', 'absent']), check_running_config=dict( default=False, type='bool', fallback=(env_fallback, ['ANSIBLE_CHECK_ICX_RUNNING_CONFIG']))) aggregate_spec = deepcopy(element_spec) aggregate_spec['name'] = dict(required=True) remove_default_spec(aggregate_spec) argument_spec = dict(aggregate=dict(type='list', elements='dict', options=aggregate_spec, aliases=['users', 'collection']), purge=dict(type='bool', default=False)) argument_spec.update(element_spec) mutually_exclusive = [('name', 'aggregate')] module = AnsibleModule(argument_spec=argument_spec, mutually_exclusive=mutually_exclusive, supports_check_mode=True) result = {'changed': False} want = map_params_to_obj(module) if module.params['check_running_config'] is False: have = [] else: have = map_config_to_obj(module) commands = map_obj_to_commands(update_objects(want, have), module) if module.params['purge']: want_users = [x['name'] for x in want] if module.params['check_running_config'] is False: have = map_config_to_obj(module) have_users = [x['name'] for x in have] for item in set(have_users).difference(want_users): if item != 'admin': commands.append(user_del_cmd(item)) result["commands"] = commands if commands: if not module.check_mode: load_config(module, commands) result['changed'] = True module.exit_json(**result)