def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": True, "type": "str", "choices": ["present", "absent"] }, "wireless_controller_hotspot20_h2qp_wan_metric": { "required": False, "type": "dict", "default": None, "options": { "downlink_load": { "required": False, "type": "int" }, "downlink_speed": { "required": False, "type": "int" }, "link_at_capacity": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "link_status": { "required": False, "type": "str", "choices": ["up", "down", "in-test"] }, "load_measurement_duration": { "required": False, "type": "int" }, "name": { "required": True, "type": "str" }, "symmetric_wan_link": { "required": False, "type": "str", "choices": ["symmetric", "asymmetric"] }, "uplink_load": { "required": False, "type": "int" }, "uplink_speed": { "required": False, "type": "int" } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_wireless_controller_hotspot20( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_wireless_controller_hotspot20( module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "switch_controller_lldp_profile": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "802.1_tlvs": { "required": False, "type": "str", "choices": ["port-vlan-id"] }, "802.3_tlvs": { "required": False, "type": "str", "choices": ["max-frame-size"] }, "auto_isl": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "auto_isl_hello_timer": { "required": False, "type": "int" }, "auto_isl_port_group": { "required": False, "type": "int" }, "auto_isl_receive_timeout": { "required": False, "type": "int" }, "custom_tlvs": { "required": False, "type": "list", "options": { "information_string": { "required": False, "type": "str" }, "name": { "required": True, "type": "str" }, "oui": { "required": False, "type": "str" }, "subtype": { "required": False, "type": "int" } } }, "med_network_policy": { "required": False, "type": "list", "options": { "dscp": { "required": False, "type": "int" }, "name": { "required": True, "type": "str" }, "priority": { "required": False, "type": "int" }, "status": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "vlan": { "required": False, "type": "int" } } }, "med_tlvs": { "required": False, "type": "str", "choices": ["inventory-management", "network-policy"] }, "name": { "required": True, "type": "str" } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_switch_controller( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_switch_controller( module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "firewall_service_custom": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "app_category": { "required": False, "type": "list", "options": { "id": { "required": True, "type": "int" } } }, "app_service_type": { "required": False, "type": "str", "choices": ["disable", "app-id", "app-category"] }, "application": { "required": False, "type": "list", "options": { "id": { "required": True, "type": "int" } } }, "category": { "required": False, "type": "str" }, "check_reset_range": { "required": False, "type": "str", "choices": ["disable", "strict", "default"] }, "color": { "required": False, "type": "int" }, "comment": { "required": False, "type": "str" }, "fqdn": { "required": False, "type": "str" }, "helper": { "required": False, "type": "str", "choices": [ "auto", "disable", "ftp", "tftp", "ras", "h323", "tns", "mms", "sip", "pptp", "rtsp", "dns-udp", "dns-tcp", "pmap", "rsh", "dcerpc", "mgcp", "gtp-c", "gtp-u", "gtp-b" ] }, "icmpcode": { "required": False, "type": "int" }, "icmptype": { "required": False, "type": "int" }, "iprange": { "required": False, "type": "str" }, "name": { "required": True, "type": "str" }, "protocol": { "required": False, "type": "str", "choices": [ "TCP/UDP/SCTP", "ICMP", "ICMP6", "IP", "HTTP", "FTP", "CONNECT", "SOCKS-TCP", "SOCKS-UDP", "ALL" ] }, "protocol_number": { "required": False, "type": "int" }, "proxy": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "sctp_portrange": { "required": False, "type": "str" }, "session_ttl": { "required": False, "type": "int" }, "tcp_halfclose_timer": { "required": False, "type": "int" }, "tcp_halfopen_timer": { "required": False, "type": "int" }, "tcp_portrange": { "required": False, "type": "str" }, "tcp_timewait_timer": { "required": False, "type": "int" }, "udp_idle_timer": { "required": False, "type": "int" }, "udp_portrange": { "required": False, "type": "str" }, "visibility": { "required": False, "type": "str", "choices": ["enable", "disable"] } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_firewall_service( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_firewall_service( module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": True, "type": "str", "choices": ["present", "absent"] }, "system_replacemsg_device_detection_portal": { "required": False, "type": "dict", "default": None, "options": { "buffer": { "required": False, "type": "str" }, "format": { "required": False, "type": "str", "choices": ["none", "text", "html", "wml"] }, "header": { "required": False, "type": "str", "choices": ["none", "http", "8bit"] }, "msg_type": { "required": False, "type": "str" } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_system_replacemsg( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_system_replacemsg( module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "firewall_address6_template": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "ip6": { "required": False, "type": "str" }, "name": { "required": True, "type": "str" }, "subnet_segment": { "required": False, "type": "list", "options": { "bits": { "required": False, "type": "int" }, "exclusive": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "id": { "required": True, "type": "int" }, "name": { "required": False, "type": "str" }, "values": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" }, "value": { "required": False, "type": "str" } } } } }, "subnet_segment_count": { "required": False, "type": "int" } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_firewall( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_firewall(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "log_setting": { "required": False, "type": "dict", "default": None, "options": { "brief_traffic_format": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "custom_log_fields": { "required": False, "type": "list", "options": { "field_id": { "required": False, "type": "str" } } }, "daemon_log": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "expolicy_implicit_log": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "fwpolicy_implicit_log": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "fwpolicy6_implicit_log": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "local_in_allow": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "local_in_deny_broadcast": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "local_in_deny_unicast": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "local_out": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "log_invalid_packet": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "log_policy_comment": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "log_policy_name": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "log_user_in_upper": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "neighbor_event": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "resolve_ip": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "resolve_port": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "user_anonymize": { "required": False, "type": "str", "choices": ["enable", "disable"] } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_log(module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_log(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": {"required": False, "type": "str"}, "username": {"required": False, "type": "str"}, "password": {"required": False, "type": "str", "default": "", "no_log": True}, "vdom": {"required": False, "type": "str", "default": "root"}, "https": {"required": False, "type": "bool", "default": True}, "ssl_verify": {"required": False, "type": "bool", "default": True}, "log_fortianalyzer_setting": { "required": False, "type": "dict", "default": None, "options": { "__change_ip": {"required": False, "type": "int"}, "certificate": {"required": False, "type": "str"}, "conn_timeout": {"required": False, "type": "int"}, "enc_algorithm": {"required": False, "type": "str", "choices": ["high-medium", "high", "low"]}, "faz_type": {"required": False, "type": "int"}, "hmac_algorithm": {"required": False, "type": "str", "choices": ["sha256", "sha1"]}, "ips_archive": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "mgmt_name": {"required": False, "type": "str"}, "monitor_failure_retry_period": {"required": False, "type": "int"}, "monitor_keepalive_period": {"required": False, "type": "int"}, "reliable": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "server": {"required": False, "type": "str"}, "source_ip": {"required": False, "type": "str"}, "ssl_min_proto_version": {"required": False, "type": "str", "choices": ["default", "SSLv3", "TLSv1", "TLSv1-1", "TLSv1-2"]}, "status": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "upload_day": {"required": False, "type": "str"}, "upload_interval": {"required": False, "type": "str", "choices": ["daily", "weekly", "monthly"]}, "upload_option": {"required": False, "type": "str", "choices": ["store-and-upload", "realtime", "1-minute", "5-minute"]}, "upload_time": {"required": False, "type": "str"} } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_log_fortianalyzer(module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_log_fortianalyzer(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "router_isis": { "required": False, "type": "dict", "default": None, "options": { "adjacency_check": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "adjacency_check6": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "adv_passive_only": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "adv_passive_only6": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "auth_keychain_l1": { "required": False, "type": "str" }, "auth_keychain_l2": { "required": False, "type": "str" }, "auth_mode_l1": { "required": False, "type": "str", "choices": ["password", "md5"] }, "auth_mode_l2": { "required": False, "type": "str", "choices": ["password", "md5"] }, "auth_password_l1": { "required": False, "type": "str" }, "auth_password_l2": { "required": False, "type": "str" }, "auth_sendonly_l1": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "auth_sendonly_l2": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "default_originate": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "default_originate6": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "dynamic_hostname": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ignore_lsp_errors": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "is_type": { "required": False, "type": "str", "choices": ["level-1-2", "level-1", "level-2-only"] }, "isis_interface": { "required": False, "type": "list", "options": { "auth_keychain_l1": { "required": False, "type": "str" }, "auth_keychain_l2": { "required": False, "type": "str" }, "auth_mode_l1": { "required": False, "type": "str", "choices": ["md5", "password"] }, "auth_mode_l2": { "required": False, "type": "str", "choices": ["md5", "password"] }, "auth_password_l1": { "required": False, "type": "str" }, "auth_password_l2": { "required": False, "type": "str" }, "auth_send_only_l1": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "auth_send_only_l2": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "circuit_type": { "required": False, "type": "str", "choices": ["level-1-2", "level-1", "level-2"] }, "csnp_interval_l1": { "required": False, "type": "int" }, "csnp_interval_l2": { "required": False, "type": "int" }, "hello_interval_l1": { "required": False, "type": "int" }, "hello_interval_l2": { "required": False, "type": "int" }, "hello_multiplier_l1": { "required": False, "type": "int" }, "hello_multiplier_l2": { "required": False, "type": "int" }, "hello_padding": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "lsp_interval": { "required": False, "type": "int" }, "lsp_retransmit_interval": { "required": False, "type": "int" }, "mesh_group": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "mesh_group_id": { "required": False, "type": "int" }, "metric_l1": { "required": False, "type": "int" }, "metric_l2": { "required": False, "type": "int" }, "name": { "required": True, "type": "str" }, "network_type": { "required": False, "type": "str", "choices": ["broadcast", "point-to-point", "loopback"] }, "priority_l1": { "required": False, "type": "int" }, "priority_l2": { "required": False, "type": "int" }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "status6": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "wide_metric_l1": { "required": False, "type": "int" }, "wide_metric_l2": { "required": False, "type": "int" } } }, "isis_net": { "required": False, "type": "list", "options": { "id": { "required": True, "type": "int" }, "net": { "required": False, "type": "str" } } }, "lsp_gen_interval_l1": { "required": False, "type": "int" }, "lsp_gen_interval_l2": { "required": False, "type": "int" }, "lsp_refresh_interval": { "required": False, "type": "int" }, "max_lsp_lifetime": { "required": False, "type": "int" }, "metric_style": { "required": False, "type": "str", "choices": [ "narrow", "wide", "transition", "narrow-transition", "narrow-transition-l1", "narrow-transition-l2", "wide-l1", "wide-l2", "wide-transition", "wide-transition-l1", "wide-transition-l2", "transition-l1", "transition-l2" ] }, "overload_bit": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "overload_bit_on_startup": { "required": False, "type": "int" }, "overload_bit_suppress": { "required": False, "type": "str", "choices": ["external", "interlevel"] }, "redistribute": { "required": False, "type": "list", "options": { "level": { "required": False, "type": "str", "choices": ["level-1-2", "level-1", "level-2"] }, "metric": { "required": False, "type": "int" }, "metric_type": { "required": False, "type": "str", "choices": ["external", "internal"] }, "protocol": { "required": True, "type": "str" }, "routemap": { "required": False, "type": "str" }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] } } }, "redistribute_l1": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "redistribute_l1_list": { "required": False, "type": "str" }, "redistribute_l2": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "redistribute_l2_list": { "required": False, "type": "str" }, "redistribute6": { "required": False, "type": "list", "options": { "level": { "required": False, "type": "str", "choices": ["level-1-2", "level-1", "level-2"] }, "metric": { "required": False, "type": "int" }, "metric_type": { "required": False, "type": "str", "choices": ["external", "internal"] }, "protocol": { "required": True, "type": "str" }, "routemap": { "required": False, "type": "str" }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] } } }, "redistribute6_l1": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "redistribute6_l1_list": { "required": False, "type": "str" }, "redistribute6_l2": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "redistribute6_l2_list": { "required": False, "type": "str" }, "spf_interval_exp_l1": { "required": False, "type": "str" }, "spf_interval_exp_l2": { "required": False, "type": "str" }, "summary_address": { "required": False, "type": "list", "options": { "id": { "required": True, "type": "int" }, "level": { "required": False, "type": "str", "choices": ["level-1-2", "level-1", "level-2"] }, "prefix": { "required": False, "type": "str" } } }, "summary_address6": { "required": False, "type": "list", "options": { "id": { "required": True, "type": "int" }, "level": { "required": False, "type": "str", "choices": ["level-1-2", "level-1", "level-2"] }, "prefix6": { "required": False, "type": "str" } } } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_router(module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_router(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "wireless_controller_inter_controller": { "required": False, "type": "dict", "default": None, "options": { "fast_failover_max": { "required": False, "type": "int" }, "fast_failover_wait": { "required": False, "type": "int" }, "inter_controller_key": { "required": False, "type": "str" }, "inter_controller_mode": { "required": False, "type": "str", "choices": ["disable", "l2-roaming", "1+1"] }, "inter_controller_peer": { "required": False, "type": "list", "options": { "id": { "required": True, "type": "int" }, "peer_ip": { "required": False, "type": "str" }, "peer_port": { "required": False, "type": "int" }, "peer_priority": { "required": False, "type": "str", "choices": ["primary", "secondary"] } } }, "inter_controller_pri": { "required": False, "type": "str", "choices": ["primary", "secondary"] } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_wireless_controller( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_wireless_controller( module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "firewall_ssl_ssh_profile": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "caname": { "required": False, "type": "str" }, "comment": { "required": False, "type": "str" }, "ftps": { "required": False, "type": "dict", "options": { "allow_invalid_server_cert": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "client_cert_request": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "ports": { "required": False, "type": "int" }, "status": { "required": False, "type": "str", "choices": ["disable", "deep-inspection"] }, "unsupported_ssl": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "untrusted_cert": { "required": False, "type": "str", "choices": ["allow", "block", "ignore"] } } }, "https": { "required": False, "type": "dict", "options": { "allow_invalid_server_cert": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "client_cert_request": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "ports": { "required": False, "type": "int" }, "status": { "required": False, "type": "str", "choices": [ "disable", "certificate-inspection", "deep-inspection" ] }, "unsupported_ssl": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "untrusted_cert": { "required": False, "type": "str", "choices": ["allow", "block", "ignore"] } } }, "imaps": { "required": False, "type": "dict", "options": { "allow_invalid_server_cert": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "client_cert_request": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "ports": { "required": False, "type": "int" }, "status": { "required": False, "type": "str", "choices": ["disable", "deep-inspection"] }, "unsupported_ssl": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "untrusted_cert": { "required": False, "type": "str", "choices": ["allow", "block", "ignore"] } } }, "mapi_over_https": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "name": { "required": True, "type": "str" }, "pop3s": { "required": False, "type": "dict", "options": { "allow_invalid_server_cert": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "client_cert_request": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "ports": { "required": False, "type": "int" }, "status": { "required": False, "type": "str", "choices": ["disable", "deep-inspection"] }, "unsupported_ssl": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "untrusted_cert": { "required": False, "type": "str", "choices": ["allow", "block", "ignore"] } } }, "rpc_over_https": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "server_cert": { "required": False, "type": "str" }, "server_cert_mode": { "required": False, "type": "str", "choices": ["re-sign", "replace"] }, "smtps": { "required": False, "type": "dict", "options": { "allow_invalid_server_cert": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "client_cert_request": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "ports": { "required": False, "type": "int" }, "status": { "required": False, "type": "str", "choices": ["disable", "deep-inspection"] }, "unsupported_ssl": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "untrusted_cert": { "required": False, "type": "str", "choices": ["allow", "block", "ignore"] } } }, "ssh": { "required": False, "type": "dict", "options": { "inspect_all": { "required": False, "type": "str", "choices": ["disable", "deep-inspection"] }, "ports": { "required": False, "type": "int" }, "ssh_algorithm": { "required": False, "type": "str", "choices": ["compatible", "high-encryption"] }, "ssh_policy_check": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "ssh_tun_policy_check": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "status": { "required": False, "type": "str", "choices": ["disable", "deep-inspection"] }, "unsupported_version": { "required": False, "type": "str", "choices": ["bypass", "block"] } } }, "ssl": { "required": False, "type": "dict", "options": { "allow_invalid_server_cert": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "client_cert_request": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "inspect_all": { "required": False, "type": "str", "choices": [ "disable", "certificate-inspection", "deep-inspection" ] }, "unsupported_ssl": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "untrusted_cert": { "required": False, "type": "str", "choices": ["allow", "block", "ignore"] } } }, "ssl_anomalies_log": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "ssl_exempt": { "required": False, "type": "list", "options": { "address": { "required": False, "type": "str" }, "address6": { "required": False, "type": "str" }, "fortiguard_category": { "required": False, "type": "int" }, "id": { "required": True, "type": "int" }, "regex": { "required": False, "type": "str" }, "type": { "required": False, "type": "str", "choices": [ "fortiguard-category", "address", "address6", "wildcard-fqdn", "regex" ] }, "wildcard_fqdn": { "required": False, "type": "str" } } }, "ssl_exemptions_log": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "ssl_server": { "required": False, "type": "list", "options": { "ftps_client_cert_request": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "https_client_cert_request": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "id": { "required": True, "type": "int" }, "imaps_client_cert_request": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "ip": { "required": False, "type": "str" }, "pop3s_client_cert_request": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "smtps_client_cert_request": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] }, "ssl_other_client_cert_request": { "required": False, "type": "str", "choices": ["bypass", "inspect", "block"] } } }, "untrusted_caname": { "required": False, "type": "str" }, "use_ssl_server": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "whitelist": { "required": False, "type": "str", "choices": ["enable", "disable"] } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_firewall( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_firewall(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": {"required": False, "type": "str"}, "username": {"required": False, "type": "str"}, "password": {"required": False, "type": "str", "default": "", "no_log": True}, "vdom": {"required": False, "type": "str", "default": "root"}, "https": {"required": False, "type": "bool", "default": True}, "ssl_verify": {"required": False, "type": "bool", "default": True}, "state": {"required": False, "type": "str", "choices": ["present", "absent"]}, "system_admin": { "required": False, "type": "dict", "default": None, "options": { "state": {"required": False, "type": "str", "choices": ["present", "absent"]}, "accprofile": {"required": False, "type": "str"}, "accprofile_override": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "allow_remove_admin_session": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "comments": {"required": False, "type": "str"}, "email_to": {"required": False, "type": "str"}, "force_password_change": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "fortitoken": {"required": False, "type": "str"}, "guest_auth": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "guest_lang": {"required": False, "type": "str"}, "guest_usergroups": {"required": False, "type": "list", "options": { "name": {"required": True, "type": "str"} }}, "gui_dashboard": {"required": False, "type": "list", "options": { "columns": {"required": False, "type": "int"}, "id": {"required": True, "type": "int"}, "layout_type": {"required": False, "type": "str", "choices": ["responsive", "fixed"]}, "name": {"required": False, "type": "str"}, "scope": {"required": False, "type": "str", "choices": ["global", "vdom"]}, "widget": {"required": False, "type": "list", "options": { "fabric_device": {"required": False, "type": "str"}, "fortiview_filters": {"required": False, "type": "list", "options": { "id": {"required": True, "type": "int"}, "key": {"required": False, "type": "str"}, "value": {"required": False, "type": "str"} }}, "fortiview_sort_by": {"required": False, "type": "str"}, "fortiview_timeframe": {"required": False, "type": "str"}, "fortiview_type": {"required": False, "type": "str"}, "fortiview_visualization": {"required": False, "type": "str"}, "height": {"required": False, "type": "int"}, "id": {"required": True, "type": "int"}, "industry": {"required": False, "type": "str", "choices": ["default", "custom"]}, "interface": {"required": False, "type": "str"}, "region": {"required": False, "type": "str", "choices": ["default", "custom"]}, "title": {"required": False, "type": "str"}, "type": {"required": False, "type": "str", "choices": ["sysinfo", "licinfo", "vminfo", "forticloud", "cpu-usage", "memory-usage", "disk-usage", "log-rate", "sessions", "session-rate", "tr-history", "analytics", "usb-modem", "admins", "security-fabric", "security-fabric-ranking", "ha-status", "vulnerability-summary", "host-scan-summary", "fortiview", "botnet-activity", "fortimail"]}, "width": {"required": False, "type": "int"}, "x_pos": {"required": False, "type": "int"}, "y_pos": {"required": False, "type": "int"} }} }}, "gui_global_menu_favorites": {"required": False, "type": "list", "options": { "id": {"required": True, "type": "str"} }}, "gui_vdom_menu_favorites": {"required": False, "type": "list", "options": { "id": {"required": True, "type": "str"} }}, "hidden": {"required": False, "type": "int"}, "history0": {"required": False, "type": "str"}, "history1": {"required": False, "type": "str"}, "ip6_trusthost1": {"required": False, "type": "str"}, "ip6_trusthost10": {"required": False, "type": "str"}, "ip6_trusthost2": {"required": False, "type": "str"}, "ip6_trusthost3": {"required": False, "type": "str"}, "ip6_trusthost4": {"required": False, "type": "str"}, "ip6_trusthost5": {"required": False, "type": "str"}, "ip6_trusthost6": {"required": False, "type": "str"}, "ip6_trusthost7": {"required": False, "type": "str"}, "ip6_trusthost8": {"required": False, "type": "str"}, "ip6_trusthost9": {"required": False, "type": "str"}, "login_time": {"required": False, "type": "list", "options": { "last_failed_login": {"required": False, "type": "str"}, "last_login": {"required": False, "type": "str"}, "usr_name": {"required": False, "type": "str"} }}, "name": {"required": True, "type": "str"}, "password": {"required": False, "type": "str"}, "password_expire": {"required": False, "type": "str"}, "peer_auth": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "peer_group": {"required": False, "type": "str"}, "radius_vdom_override": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "remote_auth": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "remote_group": {"required": False, "type": "str"}, "schedule": {"required": False, "type": "str"}, "sms_custom_server": {"required": False, "type": "str"}, "sms_phone": {"required": False, "type": "str"}, "sms_server": {"required": False, "type": "str", "choices": ["fortiguard", "custom"]}, "ssh_certificate": {"required": False, "type": "str"}, "ssh_public_key1": {"required": False, "type": "str"}, "ssh_public_key2": {"required": False, "type": "str"}, "ssh_public_key3": {"required": False, "type": "str"}, "trusthost1": {"required": False, "type": "str"}, "trusthost10": {"required": False, "type": "str"}, "trusthost2": {"required": False, "type": "str"}, "trusthost3": {"required": False, "type": "str"}, "trusthost4": {"required": False, "type": "str"}, "trusthost5": {"required": False, "type": "str"}, "trusthost6": {"required": False, "type": "str"}, "trusthost7": {"required": False, "type": "str"}, "trusthost8": {"required": False, "type": "str"}, "trusthost9": {"required": False, "type": "str"}, "two_factor": {"required": False, "type": "str", "choices": ["disable", "fortitoken", "email", "sms"]}, "vdom": {"required": False, "type": "list", "options": { "name": {"required": True, "type": "str"} }}, "wildcard": {"required": False, "type": "str", "choices": ["enable", "disable"]} } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_system(module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_system(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "firewall_DoS_policy": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "anomaly": { "required": False, "type": "list", "options": { "action": { "required": False, "type": "str", "choices": ["pass", "block"] }, "log": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "name": { "required": True, "type": "str" }, "quarantine": { "required": False, "type": "str", "choices": ["none", "attacker"] }, "quarantine_expiry": { "required": False, "type": "str" }, "quarantine_log": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "status": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "threshold": { "required": False, "type": "int" }, "threshold(default)": { "required": False, "type": "int" } } }, "comments": { "required": False, "type": "str" }, "dstaddr": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "interface": { "required": False, "type": "str" }, "policyid": { "required": True, "type": "int" }, "service": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "srcaddr": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_firewall( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_firewall(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": {"required": False, "type": "str"}, "username": {"required": False, "type": "str"}, "password": {"required": False, "type": "str", "default": "", "no_log": True}, "vdom": {"required": False, "type": "str", "default": "root"}, "https": {"required": False, "type": "bool", "default": True}, "ssl_verify": {"required": False, "type": "bool", "default": True}, "state": {"required": False, "type": "str", "choices": ["present", "absent"]}, "ips_sensor": { "required": False, "type": "dict", "default": None, "options": { "state": {"required": False, "type": "str", "choices": ["present", "absent"]}, "block_malicious_url": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "comment": {"required": False, "type": "str"}, "entries": {"required": False, "type": "list", "options": { "action": {"required": False, "type": "str", "choices": ["pass", "block", "reset", "default"]}, "application": {"required": False, "type": "str"}, "exempt_ip": {"required": False, "type": "list", "options": { "dst_ip": {"required": False, "type": "str"}, "id": {"required": True, "type": "int"}, "src_ip": {"required": False, "type": "str"} }}, "id": {"required": True, "type": "int"}, "location": {"required": False, "type": "str"}, "log": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "log_attack_context": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "log_packet": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "os": {"required": False, "type": "str"}, "protocol": {"required": False, "type": "str"}, "quarantine": {"required": False, "type": "str", "choices": ["none", "attacker"]}, "quarantine_expiry": {"required": False, "type": "str"}, "quarantine_log": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "rate_count": {"required": False, "type": "int"}, "rate_duration": {"required": False, "type": "int"}, "rate_mode": {"required": False, "type": "str", "choices": ["periodical", "continuous"]}, "rate_track": {"required": False, "type": "str", "choices": ["none", "src-ip", "dest-ip", "dhcp-client-mac", "dns-domain"]}, "rule": {"required": False, "type": "list", "options": { "id": {"required": True, "type": "int"} }}, "severity": {"required": False, "type": "str"}, "status": {"required": False, "type": "str", "choices": ["disable", "enable", "default"]} }}, "extended_log": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "filter": {"required": False, "type": "list", "options": { "action": {"required": False, "type": "str", "choices": ["pass", "block", "reset", "default"]}, "application": {"required": False, "type": "str"}, "location": {"required": False, "type": "str"}, "log": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "log_packet": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "name": {"required": True, "type": "str"}, "os": {"required": False, "type": "str"}, "protocol": {"required": False, "type": "str"}, "quarantine": {"required": False, "type": "str", "choices": ["none", "attacker"]}, "quarantine_expiry": {"required": False, "type": "int"}, "quarantine_log": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "severity": {"required": False, "type": "str"}, "status": {"required": False, "type": "str", "choices": ["disable", "enable", "default"]} }}, "name": {"required": True, "type": "str"}, "override": {"required": False, "type": "list", "options": { "action": {"required": False, "type": "str", "choices": ["pass", "block", "reset"]}, "exempt_ip": {"required": False, "type": "list", "options": { "dst_ip": {"required": False, "type": "str"}, "id": {"required": True, "type": "int"}, "src_ip": {"required": False, "type": "str"} }}, "log": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "log_packet": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "quarantine": {"required": False, "type": "str", "choices": ["none", "attacker"]}, "quarantine_expiry": {"required": False, "type": "int"}, "quarantine_log": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "rule_id": {"required": False, "type": "int"}, "status": {"required": False, "type": "str", "choices": ["disable", "enable"]} }}, "replacemsg_group": {"required": False, "type": "str"} } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_ips(module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_ips(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "webfilter_fortiguard": { "required": False, "type": "dict", "default": None, "options": { "cache_mem_percent": { "required": False, "type": "int" }, "cache_mode": { "required": False, "type": "str", "choices": ["ttl", "db-ver"] }, "cache_prefix_match": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "close_ports": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ovrd_auth_https": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ovrd_auth_port": { "required": False, "type": "int" }, "ovrd_auth_port_http": { "required": False, "type": "int" }, "ovrd_auth_port_https": { "required": False, "type": "int" }, "ovrd_auth_port_warning": { "required": False, "type": "int" }, "request_packet_size_limit": { "required": False, "type": "int" }, "warn_auth_https": { "required": False, "type": "str", "choices": ["enable", "disable"] } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_webfilter( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_webfilter(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "router_policy": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "action": { "required": False, "type": "str", "choices": ["deny", "permit"] }, "comments": { "required": False, "type": "str" }, "dst": { "required": False, "type": "list", "options": { "subnet": { "required": True, "type": "str" } } }, "dst_negate": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "dstaddr": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "end_port": { "required": False, "type": "int" }, "end_source_port": { "required": False, "type": "int" }, "gateway": { "required": False, "type": "str" }, "input_device": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "output_device": { "required": False, "type": "str" }, "protocol": { "required": False, "type": "int" }, "seq_num": { "required": False, "type": "int" }, "src": { "required": False, "type": "list", "options": { "subnet": { "required": True, "type": "str" } } }, "src_negate": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "srcaddr": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "start_port": { "required": False, "type": "int" }, "start_source_port": { "required": False, "type": "int" }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "tos": { "required": False, "type": "str" }, "tos_mask": { "required": False, "type": "str" } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_router(module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_router(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": True, "type": "str", "choices": ["present", "absent"] }, "vpn_ssl_web_user_group_bookmark": { "required": False, "type": "dict", "default": None, "options": { "bookmarks": { "required": False, "type": "list", "options": { "additional_params": { "required": False, "type": "str" }, "apptype": { "required": False, "type": "str", "choices": [ "citrix", "ftp", "portforward", "rdp", "smb", "ssh", "telnet", "vnc", "web" ] }, "description": { "required": False, "type": "str" }, "folder": { "required": False, "type": "str" }, "form_data": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" }, "value": { "required": False, "type": "str" } } }, "host": { "required": False, "type": "str" }, "listening_port": { "required": False, "type": "int" }, "load_balancing_info": { "required": False, "type": "str" }, "logon_password": { "required": False, "type": "str" }, "logon_user": { "required": False, "type": "str" }, "name": { "required": True, "type": "str" }, "port": { "required": False, "type": "int" }, "preconnection_blob": { "required": False, "type": "str" }, "preconnection_id": { "required": False, "type": "int" }, "remote_port": { "required": False, "type": "int" }, "security": { "required": False, "type": "str", "choices": ["rdp", "nla", "tls", "any"] }, "server_layout": { "required": False, "type": "str", "choices": [ "de-de-qwertz", "en-gb-qwerty", "en-us-qwerty", "es-es-qwerty", "fr-fr-azerty", "fr-ch-qwertz", "it-it-qwerty", "ja-jp-qwerty", "pt-br-qwerty", "sv-se-qwerty", "tr-tr-qwerty", "failsafe" ] }, "show_status_window": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "sso": { "required": False, "type": "str", "choices": ["disable", "static", "auto"] }, "sso_credential": { "required": False, "type": "str", "choices": ["sslvpn-login", "alternative"] }, "sso_credential_sent_once": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "sso_password": { "required": False, "type": "str" }, "sso_username": { "required": False, "type": "str" }, "url": { "required": False, "type": "str" } } }, "name": { "required": True, "type": "str" } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_vpn_ssl_web( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_vpn_ssl_web(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "extender_controller_extender": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "aaa_shared_secret": { "required": False, "type": "str" }, "access_point_name": { "required": False, "type": "str" }, "admin": { "required": False, "type": "str", "choices": ["disable", "discovered", "enable"] }, "at_dial_script": { "required": False, "type": "str" }, "billing_start_day": { "required": False, "type": "int" }, "cdma_aaa_spi": { "required": False, "type": "str" }, "cdma_ha_spi": { "required": False, "type": "str" }, "cdma_nai": { "required": False, "type": "str" }, "conn_status": { "required": False, "type": "int" }, "description": { "required": False, "type": "str" }, "dial_mode": { "required": False, "type": "str", "choices": ["dial-on-demand", "always-connect"] }, "dial_status": { "required": False, "type": "int" }, "ext_name": { "required": False, "type": "str" }, "ha_shared_secret": { "required": False, "type": "str" }, "id": { "required": True, "type": "str" }, "ifname": { "required": False, "type": "str" }, "initiated_update": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "mode": { "required": False, "type": "str", "choices": ["standalone", "redundant"] }, "modem_passwd": { "required": False, "type": "str" }, "modem_type": { "required": False, "type": "str", "choices": ["cdma", "gsm/lte", "wimax"] }, "multi_mode": { "required": False, "type": "str", "choices": ["auto", "auto-3g", "force-lte", "force-3g", "force-2g"] }, "ppp_auth_protocol": { "required": False, "type": "str", "choices": ["auto", "pap", "chap"] }, "ppp_echo_request": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ppp_password": { "required": False, "type": "str" }, "ppp_username": { "required": False, "type": "str" }, "primary_ha": { "required": False, "type": "str" }, "quota_limit_mb": { "required": False, "type": "int" }, "redial": { "required": False, "type": "str", "choices": [ "none", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" ] }, "redundant_intf": { "required": False, "type": "str" }, "roaming": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "role": { "required": False, "type": "str", "choices": ["none", "primary", "secondary"] }, "secondary_ha": { "required": False, "type": "str" }, "sim_pin": { "required": False, "type": "str" }, "vdom": { "required": False, "type": "int" }, "wimax_auth_protocol": { "required": False, "type": "str", "choices": ["tls", "ttls"] }, "wimax_carrier": { "required": False, "type": "str" }, "wimax_realm": { "required": False, "type": "str" } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_extender_controller( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_extender_controller( module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "firewall_interface_policy": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "address_type": { "required": False, "type": "str", "choices": ["ipv4", "ipv6"] }, "application_list": { "required": False, "type": "str" }, "application_list_status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "av_profile": { "required": False, "type": "str" }, "av_profile_status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "comments": { "required": False, "type": "str" }, "dlp_sensor": { "required": False, "type": "str" }, "dlp_sensor_status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "dsri": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "dstaddr": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "interface": { "required": False, "type": "str" }, "ips_sensor": { "required": False, "type": "str" }, "ips_sensor_status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "label": { "required": False, "type": "str" }, "logtraffic": { "required": False, "type": "str", "choices": ["all", "utm", "disable"] }, "policyid": { "required": True, "type": "int" }, "scan_botnet_connections": { "required": False, "type": "str", "choices": ["disable", "block", "monitor"] }, "service": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "spamfilter_profile": { "required": False, "type": "str" }, "spamfilter_profile_status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "srcaddr": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "webfilter_profile": { "required": False, "type": "str" }, "webfilter_profile_status": { "required": False, "type": "str", "choices": ["enable", "disable"] } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_firewall( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_firewall(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": True, "type": "str", "choices": ["present", "absent"] }, "wireless_controller_hotspot20_anqp_ip_address_type": { "required": False, "type": "dict", "default": None, "options": { "ipv4_address_type": { "required": False, "type": "str", "choices": [ "not-available", "public", "port-restricted", "single-NATed-private", "double-NATed-private", "port-restricted-and-single-NATed", "port-restricted-and-double-NATed", "not-known" ] }, "ipv6_address_type": { "required": False, "type": "str", "choices": ["not-available", "available", "not-known"] }, "name": { "required": True, "type": "str" } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_wireless_controller_hotspot20( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_wireless_controller_hotspot20( module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "webfilter_ips_urlfilter_setting": { "required": False, "type": "dict", "default": None, "options": { "device": { "required": False, "type": "str" }, "distance": { "required": False, "type": "int" }, "gateway": { "required": False, "type": "str" }, "geo_filter": { "required": False, "type": "str" } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_webfilter( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_webfilter(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "system_ntp": { "required": False, "type": "dict", "default": None, "options": { "interface": { "required": False, "type": "list", "options": { "interface_name": { "required": False, "type": "str" } } }, "ntpserver": { "required": False, "type": "list", "options": { "authentication": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "id": { "required": True, "type": "int" }, "key": { "required": False, "type": "str" }, "key_id": { "required": False, "type": "int" }, "ntpv3": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "server": { "required": False, "type": "str" } } }, "ntpsync": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "server_mode": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "source_ip": { "required": False, "type": "str" }, "source_ip6": { "required": False, "type": "str" }, "syncinterval": { "required": False, "type": "int" }, "type": { "required": False, "type": "str", "choices": ["fortiguard", "custom"] } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_system(module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_system(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "firewall_vip6": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "arp_reply": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "color": { "required": False, "type": "int" }, "comment": { "required": False, "type": "str" }, "extip": { "required": False, "type": "str" }, "extport": { "required": False, "type": "str" }, "http_cookie_age": { "required": False, "type": "int" }, "http_cookie_domain": { "required": False, "type": "str" }, "http_cookie_domain_from_host": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "http_cookie_generation": { "required": False, "type": "int" }, "http_cookie_path": { "required": False, "type": "str" }, "http_cookie_share": { "required": False, "type": "str", "choices": ["disable", "same-ip"] }, "http_ip_header": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "http_ip_header_name": { "required": False, "type": "str" }, "http_multiplex": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "https_cookie_secure": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "id": { "required": False, "type": "int" }, "ldb_method": { "required": False, "type": "str", "choices": [ "static", "round-robin", "weighted", "least-session", "least-rtt", "first-alive", "http-host" ] }, "mappedip": { "required": False, "type": "str" }, "mappedport": { "required": False, "type": "str" }, "max_embryonic_connections": { "required": False, "type": "int" }, "monitor": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "name": { "required": True, "type": "str" }, "outlook_web_access": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "persistence": { "required": False, "type": "str", "choices": ["none", "http-cookie", "ssl-session-id"] }, "portforward": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "protocol": { "required": False, "type": "str", "choices": ["tcp", "udp", "sctp"] }, "realservers": { "required": False, "type": "list", "options": { "client_ip": { "required": False, "type": "str" }, "healthcheck": { "required": False, "type": "str", "choices": ["disable", "enable", "vip"] }, "holddown_interval": { "required": False, "type": "int" }, "http_host": { "required": False, "type": "str" }, "id": { "required": True, "type": "int" }, "ip": { "required": False, "type": "str" }, "max_connections": { "required": False, "type": "int" }, "monitor": { "required": False, "type": "str" }, "port": { "required": False, "type": "int" }, "status": { "required": False, "type": "str", "choices": ["active", "standby", "disable"] }, "weight": { "required": False, "type": "int" } } }, "server_type": { "required": False, "type": "str", "choices": [ "http", "https", "imaps", "pop3s", "smtps", "ssl", "tcp", "udp", "ip" ] }, "src_filter": { "required": False, "type": "list", "options": { "range": { "required": True, "type": "str" } } }, "ssl_algorithm": { "required": False, "type": "str", "choices": ["high", "medium", "low", "custom"] }, "ssl_certificate": { "required": False, "type": "str" }, "ssl_cipher_suites": { "required": False, "type": "list", "options": { "cipher": { "required": False, "type": "str", "choices": [ "TLS-RSA-WITH-3DES-EDE-CBC-SHA", "TLS-DHE-RSA-WITH-DES-CBC-SHA", "TLS-DHE-DSS-WITH-DES-CBC-SHA" ] }, "priority": { "required": True, "type": "int" }, "versions": { "required": False, "type": "str", "choices": ["ssl-3.0", "tls-1.0", "tls-1.1", "tls-1.2"] } } }, "ssl_client_fallback": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "ssl_client_renegotiation": { "required": False, "type": "str", "choices": ["allow", "deny", "secure"] }, "ssl_client_session_state_max": { "required": False, "type": "int" }, "ssl_client_session_state_timeout": { "required": False, "type": "int" }, "ssl_client_session_state_type": { "required": False, "type": "str", "choices": ["disable", "time", "count", "both"] }, "ssl_dh_bits": { "required": False, "type": "str", "choices": ["768", "1024", "1536", "2048", "3072", "4096"] }, "ssl_hpkp": { "required": False, "type": "str", "choices": ["disable", "enable", "report-only"] }, "ssl_hpkp_age": { "required": False, "type": "int" }, "ssl_hpkp_backup": { "required": False, "type": "str" }, "ssl_hpkp_include_subdomains": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "ssl_hpkp_primary": { "required": False, "type": "str" }, "ssl_hpkp_report_uri": { "required": False, "type": "str" }, "ssl_hsts": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "ssl_hsts_age": { "required": False, "type": "int" }, "ssl_hsts_include_subdomains": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "ssl_http_location_conversion": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ssl_http_match_host": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ssl_max_version": { "required": False, "type": "str", "choices": ["ssl-3.0", "tls-1.0", "tls-1.1", "tls-1.2"] }, "ssl_min_version": { "required": False, "type": "str", "choices": ["ssl-3.0", "tls-1.0", "tls-1.1", "tls-1.2"] }, "ssl_mode": { "required": False, "type": "str", "choices": ["half", "full"] }, "ssl_pfs": { "required": False, "type": "str", "choices": ["require", "deny", "allow"] }, "ssl_send_empty_frags": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ssl_server_algorithm": { "required": False, "type": "str", "choices": ["high", "medium", "low", "custom", "client"] }, "ssl_server_cipher_suites": { "required": False, "type": "list", "options": { "cipher": { "required": False, "type": "str", "choices": [ "TLS-RSA-WITH-3DES-EDE-CBC-SHA", "TLS-DHE-RSA-WITH-DES-CBC-SHA", "TLS-DHE-DSS-WITH-DES-CBC-SHA" ] }, "priority": { "required": True, "type": "int" }, "versions": { "required": False, "type": "str", "choices": ["ssl-3.0", "tls-1.0", "tls-1.1", "tls-1.2"] } } }, "ssl_server_max_version": { "required": False, "type": "str", "choices": ["ssl-3.0", "tls-1.0", "tls-1.1", "tls-1.2", "client"] }, "ssl_server_min_version": { "required": False, "type": "str", "choices": ["ssl-3.0", "tls-1.0", "tls-1.1", "tls-1.2", "client"] }, "ssl_server_session_state_max": { "required": False, "type": "int" }, "ssl_server_session_state_timeout": { "required": False, "type": "int" }, "ssl_server_session_state_type": { "required": False, "type": "str", "choices": ["disable", "time", "count", "both"] }, "type": { "required": False, "type": "str", "choices": ["static-nat", "server-load-balance"] }, "uuid": { "required": False, "type": "str" }, "weblogic_server": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "websphere_server": { "required": False, "type": "str", "choices": ["disable", "enable"] } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_firewall( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_firewall(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": {"required": False, "type": "str"}, "username": {"required": False, "type": "str"}, "password": {"required": False, "type": "str", "default": "", "no_log": True}, "vdom": {"required": False, "type": "str", "default": "root"}, "https": {"required": False, "type": "bool", "default": True}, "ssl_verify": {"required": False, "type": "bool", "default": True}, "state": {"required": False, "type": "str", "choices": ["present", "absent"]}, "report_theme": { "required": False, "type": "dict", "default": None, "options": { "state": {"required": False, "type": "str", "choices": ["present", "absent"]}, "bullet_list_style": {"required": False, "type": "str"}, "column_count": {"required": False, "type": "str", "choices": ["1", "2", "3"]}, "default_html_style": {"required": False, "type": "str"}, "default_pdf_style": {"required": False, "type": "str"}, "graph_chart_style": {"required": False, "type": "str"}, "heading1_style": {"required": False, "type": "str"}, "heading2_style": {"required": False, "type": "str"}, "heading3_style": {"required": False, "type": "str"}, "heading4_style": {"required": False, "type": "str"}, "hline_style": {"required": False, "type": "str"}, "image_style": {"required": False, "type": "str"}, "name": {"required": True, "type": "str"}, "normal_text_style": {"required": False, "type": "str"}, "numbered_list_style": {"required": False, "type": "str"}, "page_footer_style": {"required": False, "type": "str"}, "page_header_style": {"required": False, "type": "str"}, "page_orient": {"required": False, "type": "str", "choices": ["portrait", "landscape"]}, "page_style": {"required": False, "type": "str"}, "report_subtitle_style": {"required": False, "type": "str"}, "report_title_style": {"required": False, "type": "str"}, "table_chart_caption_style": {"required": False, "type": "str"}, "table_chart_even_row_style": {"required": False, "type": "str"}, "table_chart_head_style": {"required": False, "type": "str"}, "table_chart_odd_row_style": {"required": False, "type": "str"}, "table_chart_style": {"required": False, "type": "str"}, "toc_heading1_style": {"required": False, "type": "str"}, "toc_heading2_style": {"required": False, "type": "str"}, "toc_heading3_style": {"required": False, "type": "str"}, "toc_heading4_style": {"required": False, "type": "str"}, "toc_title_style": {"required": False, "type": "str"} } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_report(module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_report(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "system_password_policy": { "required": False, "type": "dict", "default": None, "options": { "apply_to": { "required": False, "type": "str", "choices": ["admin-password", "ipsec-preshared-key"] }, "change_4_characters": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "expire_day": { "required": False, "type": "int" }, "expire_status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "min_lower_case_letter": { "required": False, "type": "int" }, "min_non_alphanumeric": { "required": False, "type": "int" }, "min_number": { "required": False, "type": "int" }, "min_upper_case_letter": { "required": False, "type": "int" }, "minimum_length": { "required": False, "type": "int" }, "reuse_password": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_system(module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_system(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "system_dhcp_server": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "auto_configuration": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "conflicted_ip_timeout": { "required": False, "type": "int" }, "ddns_auth": { "required": False, "type": "str", "choices": ["disable", "tsig"] }, "ddns_key": { "required": False, "type": "str" }, "ddns_keyname": { "required": False, "type": "str" }, "ddns_server_ip": { "required": False, "type": "str" }, "ddns_ttl": { "required": False, "type": "int" }, "ddns_update": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "ddns_update_override": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "ddns_zone": { "required": False, "type": "str" }, "default_gateway": { "required": False, "type": "str" }, "dns_server1": { "required": False, "type": "str" }, "dns_server2": { "required": False, "type": "str" }, "dns_server3": { "required": False, "type": "str" }, "dns_service": { "required": False, "type": "str", "choices": ["local", "default", "specify"] }, "domain": { "required": False, "type": "str" }, "exclude_range": { "required": False, "type": "list", "options": { "end_ip": { "required": False, "type": "str" }, "id": { "required": True, "type": "int" }, "start_ip": { "required": False, "type": "str" } } }, "filename": { "required": False, "type": "str" }, "forticlient_on_net_status": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "id": { "required": True, "type": "int" }, "interface": { "required": False, "type": "str" }, "ip_mode": { "required": False, "type": "str", "choices": ["range", "usrgrp"] }, "ip_range": { "required": False, "type": "list", "options": { "end_ip": { "required": False, "type": "str" }, "id": { "required": True, "type": "int" }, "start_ip": { "required": False, "type": "str" } } }, "ipsec_lease_hold": { "required": False, "type": "int" }, "lease_time": { "required": False, "type": "int" }, "mac_acl_default_action": { "required": False, "type": "str", "choices": ["assign", "block"] }, "netmask": { "required": False, "type": "str" }, "next_server": { "required": False, "type": "str" }, "ntp_server1": { "required": False, "type": "str" }, "ntp_server2": { "required": False, "type": "str" }, "ntp_server3": { "required": False, "type": "str" }, "ntp_service": { "required": False, "type": "str", "choices": ["local", "default", "specify"] }, "options": { "required": False, "type": "list", "options": { "code": { "required": False, "type": "int" }, "id": { "required": True, "type": "int" }, "ip": { "required": False, "type": "str" }, "type": { "required": False, "type": "str", "choices": ["hex", "string", "ip", "fqdn"] }, "value": { "required": False, "type": "str" } } }, "reserved_address": { "required": False, "type": "list", "options": { "action": { "required": False, "type": "str", "choices": ["assign", "block", "reserved"] }, "description": { "required": False, "type": "str" }, "id": { "required": True, "type": "int" }, "ip": { "required": False, "type": "str" }, "mac": { "required": False, "type": "str" } } }, "server_type": { "required": False, "type": "str", "choices": ["regular", "ipsec"] }, "status": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "tftp_server": { "required": False, "type": "list", "options": { "tftp_server": { "required": False, "type": "str" } } }, "timezone": { "required": False, "type": "str", "choices": [ "01", "02", "03", "04", "05", "81", "06", "07", "08", "09", "10", "11", "12", "13", "74", "14", "77", "15", "87", "16", "17", "18", "19", "20", "75", "21", "22", "23", "24", "80", "79", "25", "26", "27", "28", "78", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "83", "84", "40", "85", "41", "42", "43", "39", "44", "46", "47", "51", "48", "45", "49", "50", "52", "53", "54", "55", "56", "57", "58", "59", "60", "62", "63", "61", "64", "65", "66", "67", "68", "69", "70", "71", "72", "00", "82", "73", "86", "76" ] }, "timezone_option": { "required": False, "type": "str", "choices": ["disable", "default", "specify"] }, "vci_match": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "vci_string": { "required": False, "type": "list", "options": { "vci_string": { "required": False, "type": "str" } } }, "wifi_ac1": { "required": False, "type": "str" }, "wifi_ac2": { "required": False, "type": "str" }, "wifi_ac3": { "required": False, "type": "str" }, "wins_server1": { "required": False, "type": "str" }, "wins_server2": { "required": False, "type": "str" } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_system_dhcp( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_system_dhcp(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": True, "type": "str", "choices": ["present", "absent"] }, "spamfilter_bword": { "required": False, "type": "dict", "default": None, "options": { "comment": { "required": False, "type": "str" }, "entries": { "required": False, "type": "list", "options": { "action": { "required": False, "type": "str", "choices": ["spam", "clear"] }, "id": { "required": True, "type": "int" }, "language": { "required": False, "type": "str", "choices": [ "western", "simch", "trach", "japanese", "korean", "french", "thai", "spanish" ] }, "pattern": { "required": False, "type": "str" }, "pattern_type": { "required": False, "type": "str", "choices": ["wildcard", "regexp"] }, "score": { "required": False, "type": "int" }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "where": { "required": False, "type": "str", "choices": ["subject", "body", "all"] } } }, "id": { "required": True, "type": "int" }, "name": { "required": False, "type": "str" } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_spamfilter( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_spamfilter(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "firewall_shaping_policy": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "app_category": { "required": False, "type": "list", "options": { "id": { "required": True, "type": "int" } } }, "application": { "required": False, "type": "list", "options": { "id": { "required": True, "type": "int" } } }, "class_id": { "required": False, "type": "int" }, "comment": { "required": False, "type": "str" }, "dstaddr": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "dstaddr6": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "dstintf": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "groups": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "id": { "required": True, "type": "int" }, "internet_service": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "internet_service_custom": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "internet_service_id": { "required": False, "type": "list", "options": { "id": { "required": True, "type": "int" } } }, "internet_service_src": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "internet_service_src_custom": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "internet_service_src_id": { "required": False, "type": "list", "options": { "id": { "required": True, "type": "int" } } }, "ip_version": { "required": False, "type": "str", "choices": ["4", "6"] }, "per_ip_shaper": { "required": False, "type": "str" }, "schedule": { "required": False, "type": "str" }, "service": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "srcaddr": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "srcaddr6": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "traffic_shaper": { "required": False, "type": "str" }, "traffic_shaper_reverse": { "required": False, "type": "str" }, "url_category": { "required": False, "type": "list", "options": { "id": { "required": True, "type": "int" } } }, "users": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_firewall( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_firewall(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "state": { "required": True, "type": "str", "choices": ["present", "absent"] }, "vpn_certificate_ocsp_server": { "required": False, "type": "dict", "default": None, "options": { "cert": { "required": False, "type": "str" }, "name": { "required": True, "type": "str" }, "secondary_cert": { "required": False, "type": "str" }, "secondary_url": { "required": False, "type": "str" }, "source_ip": { "required": False, "type": "str" }, "unavail_action": { "required": False, "type": "str", "choices": ["revoke", "ignore"] }, "url": { "required": False, "type": "str" } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_vpn_certificate( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_vpn_certificate( module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)
try: from ansible_collections.misc.not_a_real_collection.plugins.modules import fortios_router_community_list except ImportError: pytest.skip("Could not load required modules for testing", allow_module_level=True) @pytest.fixture(autouse=True) def connection_mock(mocker): connection_class_mock = mocker.patch( 'ansible_collections.misc.not_a_real_collection.plugins.modules.fortios_router_community_list.Connection' ) return connection_class_mock fos_instance = FortiOSHandler(connection_mock) def test_router_community_list_creation(mocker): schema_method_mock = mocker.patch( 'ansible_collections.misc.not_a_real_collection.plugins.module_utils.network.fortios.fortios.FortiOSHandler.schema' ) set_method_result = { 'status': 'success', 'http_method': 'POST', 'http_status': 200 } set_method_mock = mocker.patch( 'ansible_collections.misc.not_a_real_collection.plugins.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
def main(): fields = { "host": { "required": False, "type": "str" }, "username": { "required": False, "type": "str" }, "password": { "required": False, "type": "str", "default": "", "no_log": True }, "vdom": { "required": False, "type": "str", "default": "root" }, "https": { "required": False, "type": "bool", "default": True }, "ssl_verify": { "required": False, "type": "bool", "default": True }, "log_fortianalyzer_filter": { "required": False, "type": "dict", "default": None, "options": { "anomaly": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "dlp_archive": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "dns": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "filter": { "required": False, "type": "str" }, "filter_type": { "required": False, "type": "str", "choices": ["include", "exclude"] }, "forward_traffic": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "gtp": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "local_traffic": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "multicast_traffic": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "netscan_discovery": { "required": False, "type": "str" }, "netscan_vulnerability": { "required": False, "type": "str" }, "severity": { "required": False, "type": "str", "choices": [ "emergency", "alert", "critical", "error", "warning", "notification", "information", "debug" ] }, "sniffer_traffic": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ssh": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "voip": { "required": False, "type": "str", "choices": ["enable", "disable"] } } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_log_fortianalyzer( module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_log_fortianalyzer( module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result)