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_automation_action": { "required": False, "type": "dict", "default": None, "options": { "action_type": { "required": False, "type": "str", "choices": [ "email", "ios-notification", "alert", "disable-ssid", "quarantine", "quarantine-forticlient", "ban-ip", "aws-lambda", "webhook" ] }, "aws_api_id": { "required": False, "type": "str" }, "aws_api_key": { "required": False, "type": "str" }, "aws_api_path": { "required": False, "type": "str" }, "aws_api_stage": { "required": False, "type": "str" }, "aws_domain": { "required": False, "type": "str" }, "aws_region": { "required": False, "type": "str" }, "delay": { "required": False, "type": "int" }, "email_subject": { "required": False, "type": "str" }, "email_to": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "headers": { "required": False, "type": "list", "options": { "header": { "required": True, "type": "str" } } }, "http_body": { "required": False, "type": "str" }, "method": { "required": False, "type": "str", "choices": ["post", "put", "get"] }, "minimum_interval": { "required": False, "type": "int" }, "name": { "required": True, "type": "str" }, "port": { "required": False, "type": "int" }, "protocol": { "required": False, "type": "str", "choices": ["http", "https"] }, "required": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "uri": { "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(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": True, "type": "str", "choices": ["present", "absent"] }, "system_replacemsg_mail": { "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)
try: from ansible_collections.notstdlib.moveitallout.plugins.modules import fortios_system_replacemsg_ftp 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.notstdlib.moveitallout.plugins.modules.fortios_system_replacemsg_ftp.Connection' ) return connection_class_mock fos_instance = FortiOSHandler(connection_mock) def test_system_replacemsg_ftp_creation(mocker): schema_method_mock = mocker.patch( 'ansible_collections.notstdlib.moveitallout.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.notstdlib.moveitallout.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 }, "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "wanopt_profile": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "auth_group": { "required": False, "type": "str" }, "cifs": { "required": False, "type": "dict", "options": { "byte_caching": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "log_traffic": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "port": { "required": False, "type": "int" }, "prefer_chunking": { "required": False, "type": "str", "choices": ["dynamic", "fix"] }, "secure_tunnel": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "tunnel_sharing": { "required": False, "type": "str", "choices": ["private", "shared", "express-shared"] } } }, "comments": { "required": False, "type": "str" }, "ftp": { "required": False, "type": "dict", "options": { "byte_caching": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "log_traffic": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "port": { "required": False, "type": "int" }, "prefer_chunking": { "required": False, "type": "str", "choices": ["dynamic", "fix"] }, "secure_tunnel": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "tunnel_sharing": { "required": False, "type": "str", "choices": ["private", "shared", "express-shared"] } } }, "http": { "required": False, "type": "dict", "options": { "byte_caching": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "log_traffic": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "port": { "required": False, "type": "int" }, "prefer_chunking": { "required": False, "type": "str", "choices": ["dynamic", "fix"] }, "secure_tunnel": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ssl": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ssl_port": { "required": False, "type": "int" }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "tunnel_non_http": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "tunnel_sharing": { "required": False, "type": "str", "choices": ["private", "shared", "express-shared"] }, "unknown_http_version": { "required": False, "type": "str", "choices": ["reject", "tunnel", "best-effort"] } } }, "mapi": { "required": False, "type": "dict", "options": { "byte_caching": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "log_traffic": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "port": { "required": False, "type": "int" }, "secure_tunnel": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "tunnel_sharing": { "required": False, "type": "str", "choices": ["private", "shared", "express-shared"] } } }, "name": { "required": True, "type": "str" }, "tcp": { "required": False, "type": "dict", "options": { "byte_caching": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "byte_caching_opt": { "required": False, "type": "str", "choices": ["mem-only", "mem-disk"] }, "log_traffic": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "port": { "required": False, "type": "str" }, "secure_tunnel": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ssl": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ssl_port": { "required": False, "type": "int" }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "tunnel_sharing": { "required": False, "type": "str", "choices": ["private", "shared", "express-shared"] } } }, "transparent": { "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_wanopt(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_wanopt(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}, "user_setting": { "required": False, "type": "dict", "default": None, "options": { "auth_blackout_time": {"required": False, "type": "int"}, "auth_ca_cert": {"required": False, "type": "str"}, "auth_cert": {"required": False, "type": "str"}, "auth_http_basic": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "auth_invalid_max": {"required": False, "type": "int"}, "auth_lockout_duration": {"required": False, "type": "int"}, "auth_lockout_threshold": {"required": False, "type": "int"}, "auth_portal_timeout": {"required": False, "type": "int"}, "auth_ports": {"required": False, "type": "list", "options": { "id": {"required": True, "type": "int"}, "port": {"required": False, "type": "int"}, "type": {"required": False, "type": "str", "choices": ["http", "https", "ftp", "telnet"]} }}, "auth_secure_http": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "auth_src_mac": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "auth_ssl_allow_renegotiation": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "auth_timeout": {"required": False, "type": "int"}, "auth_timeout_type": {"required": False, "type": "str", "choices": ["idle-timeout", "hard-timeout", "new-session"]}, "auth_type": {"required": False, "type": "str", "choices": ["http", "https", "ftp", "telnet"]}, "radius_ses_timeout_act": {"required": False, "type": "str", "choices": ["hard-timeout", "ignore-timeout"]} } } } 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_user(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_user(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_bwl": { "required": False, "type": "dict", "default": None, "options": { "comment": {"required": False, "type": "str"}, "entries": {"required": False, "type": "list", "options": { "action": {"required": False, "type": "str", "choices": ["reject", "spam", "clear"]}, "addr_type": {"required": False, "type": "str", "choices": ["ipv4", "ipv6"]}, "email_pattern": {"required": False, "type": "str"}, "id": {"required": True, "type": "int"}, "ip4_subnet": {"required": False, "type": "str"}, "ip6_subnet": {"required": False, "type": "str"}, "pattern_type": {"required": False, "type": "str", "choices": ["wildcard", "regexp"]}, "status": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "type": {"required": False, "type": "str", "choices": ["ip", "email"]} }}, "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": True, "type": "str", "choices": ["present", "absent"]}, "system_dhcp6_server": { "required": False, "type": "dict", "default": None, "options": { "dns_search_list": {"required": False, "type": "str", "choices": ["delegated", "specify"]}, "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": ["delegated", "default", "specify"]}, "domain": {"required": False, "type": "str"}, "id": {"required": True, "type": "int"}, "interface": {"required": False, "type": "str"}, "ip_mode": {"required": False, "type": "str", "choices": ["range", "delegated"]}, "ip_range": {"required": False, "type": "list", "options": { "end_ip": {"required": False, "type": "str"}, "id": {"required": True, "type": "int"}, "start_ip": {"required": False, "type": "str"} }}, "lease_time": {"required": False, "type": "int"}, "option1": {"required": False, "type": "str"}, "option2": {"required": False, "type": "str"}, "option3": {"required": False, "type": "str"}, "prefix_range": {"required": False, "type": "list", "options": { "end_prefix": {"required": False, "type": "str"}, "id": {"required": True, "type": "int"}, "prefix_length": {"required": False, "type": "int"}, "start_prefix": {"required": False, "type": "str"} }}, "rapid_commit": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "status": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "subnet": {"required": False, "type": "str"}, "upstream_interface": {"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_dhcp6(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_dhcp6(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_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"} }}, "custom_lang": {"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 }, "wireless_controller_global": { "required": False, "type": "dict", "default": None, "options": { "ap_log_server": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ap_log_server_ip": { "required": False, "type": "str" }, "ap_log_server_port": { "required": False, "type": "int" }, "control_message_offload": { "required": False, "type": "str", "choices": [ "ebp-frame", "aeroscout-tag", "ap-list", "sta-list", "sta-cap-list", "stats", "aeroscout-mu" ] }, "data_ethernet_II": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "discovery_mc_addr": { "required": False, "type": "str" }, "fiapp_eth_type": { "required": False, "type": "int" }, "image_download": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ipsec_base_ip": { "required": False, "type": "str" }, "link_aggregation": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "location": { "required": False, "type": "str" }, "max_clients": { "required": False, "type": "int" }, "max_retransmit": { "required": False, "type": "int" }, "mesh_eth_type": { "required": False, "type": "int" }, "name": { "required": False, "type": "str" }, "rogue_scan_mac_adjacency": { "required": False, "type": "int" }, "wtp_share": { "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_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 }, "system_console": { "required": False, "type": "dict", "default": None, "options": { "baudrate": { "required": False, "type": "str", "choices": ["9600", "19200", "38400", "57600", "115200"] }, "login": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "mode": { "required": False, "type": "str", "choices": ["batch", "line"] }, "output": { "required": False, "type": "str", "choices": ["standard", "more"] } } } } 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 }, "system_resource_limits": { "required": False, "type": "dict", "default": None, "options": { "custom_service": { "required": False, "type": "int" }, "dialup_tunnel": { "required": False, "type": "int" }, "firewall_address": { "required": False, "type": "int" }, "firewall_addrgrp": { "required": False, "type": "int" }, "firewall_policy": { "required": False, "type": "int" }, "ipsec_phase1": { "required": False, "type": "int" }, "ipsec_phase1_interface": { "required": False, "type": "int" }, "ipsec_phase2": { "required": False, "type": "int" }, "ipsec_phase2_interface": { "required": False, "type": "int" }, "log_disk_quota": { "required": False, "type": "int" }, "onetime_schedule": { "required": False, "type": "int" }, "proxy": { "required": False, "type": "int" }, "recurring_schedule": { "required": False, "type": "int" }, "service_group": { "required": False, "type": "int" }, "session": { "required": False, "type": "int" }, "sslvpn": { "required": False, "type": "int" }, "user": { "required": False, "type": "int" }, "user_group": { "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_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 }, "log_threat_weight": { "required": False, "type": "dict", "default": None, "options": { "application": { "required": False, "type": "list", "options": { "category": { "required": False, "type": "int" }, "id": { "required": True, "type": "int" }, "level": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] } } }, "blocked_connection": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "failed_connection": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "geolocation": { "required": False, "type": "list", "options": { "country": { "required": False, "type": "str" }, "id": { "required": True, "type": "int" }, "level": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] } } }, "ips": { "required": False, "type": "dict", "options": { "critical_severity": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "high_severity": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "info_severity": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "low_severity": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "medium_severity": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] } } }, "level": { "required": False, "type": "dict", "options": { "critical": { "required": False, "type": "int" }, "high": { "required": False, "type": "int" }, "low": { "required": False, "type": "int" }, "medium": { "required": False, "type": "int" } } }, "malware": { "required": False, "type": "dict", "options": { "botnet_connection": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "command_blocked": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "content_disarm": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "mimefragmented": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "oversized": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "switch_proto": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "virus_blocked": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "virus_file_type_executable": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "virus_infected": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "virus_outbreak_prevention": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "virus_scan_error": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] } } }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "url_block_detected": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] }, "web": { "required": False, "type": "list", "options": { "category": { "required": False, "type": "int" }, "id": { "required": True, "type": "int" }, "level": { "required": False, "type": "str", "choices": ["disable", "low", "medium", "high", "critical"] } } } } } } 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 }, "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "spamfilter_profile": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "comment": { "required": False, "type": "str" }, "external": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "flow_based": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "gmail": { "required": False, "type": "dict", "options": { "log": { "required": False, "type": "str", "choices": ["enable", "disable"] } } }, "imap": { "required": False, "type": "dict", "options": { "action": { "required": False, "type": "str", "choices": ["pass", "tag"] }, "log": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "tag_msg": { "required": False, "type": "str" }, "tag_type": { "required": False, "type": "list", "choices": ["subject", "header", "spaminfo"] } } }, "mapi": { "required": False, "type": "dict", "options": { "action": { "required": False, "type": "str", "choices": ["pass", "discard"] }, "log": { "required": False, "type": "str", "choices": ["enable", "disable"] } } }, "msn_hotmail": { "required": False, "type": "dict", "options": { "log": { "required": False, "type": "str", "choices": ["enable", "disable"] } } }, "name": { "required": True, "type": "str" }, "options": { "required": False, "type": "list", "choices": [ "bannedword", "spambwl", "spamfsip", "spamfssubmit", "spamfschksum", "spamfsurl", "spamhelodns", "spamraddrdns", "spamrbl", "spamhdrcheck", "spamfsphish" ] }, "pop3": { "required": False, "type": "dict", "options": { "action": { "required": False, "type": "str", "choices": ["pass", "tag"] }, "log": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "tag_msg": { "required": False, "type": "str" }, "tag_type": { "required": False, "type": "list", "choices": ["subject", "header", "spaminfo"] } } }, "replacemsg_group": { "required": False, "type": "str" }, "smtp": { "required": False, "type": "dict", "options": { "action": { "required": False, "type": "str", "choices": ["pass", "tag", "discard"] }, "hdrip": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "local_override": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "log": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "tag_msg": { "required": False, "type": "str" }, "tag_type": { "required": False, "type": "list", "choices": ["subject", "header", "spaminfo"] } } }, "spam_bwl_table": { "required": False, "type": "int" }, "spam_bword_table": { "required": False, "type": "int" }, "spam_bword_threshold": { "required": False, "type": "int" }, "spam_filtering": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "spam_iptrust_table": { "required": False, "type": "int" }, "spam_log": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "spam_log_fortiguard_response": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "spam_mheader_table": { "required": False, "type": "int" }, "spam_rbl_table": { "required": False, "type": "int" }, "yahoo_mail": { "required": False, "type": "dict", "options": { "log": { "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_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": True, "type": "str", "choices": ["present", "absent"]}, "system_gre_tunnel": { "required": False, "type": "dict", "default": None, "options": { "checksum_reception": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "checksum_transmission": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "dscp_copying": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "interface": {"required": False, "type": "str"}, "ip_version": {"required": False, "type": "str", "choices": ["4", "6"]}, "keepalive_failtimes": {"required": False, "type": "int"}, "keepalive_interval": {"required": False, "type": "int"}, "key_inbound": {"required": False, "type": "int"}, "key_outbound": {"required": False, "type": "int"}, "local_gw": {"required": False, "type": "str"}, "local_gw6": {"required": False, "type": "str"}, "name": {"required": True, "type": "str"}, "remote_gw": {"required": False, "type": "str"}, "remote_gw6": {"required": False, "type": "str"}, "sequence_number_reception": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "sequence_number_transmission": {"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_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 }, "log_fortiguard_override_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_fortiguard( 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_fortiguard( 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"] }, "vpn_ipsec_manualkey": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "authentication": { "required": False, "type": "str", "choices": ["null", "md5", "sha1", "sha256", "sha384", "sha512"] }, "authkey": { "required": False, "type": "str" }, "enckey": { "required": False, "type": "str" }, "encryption": { "required": False, "type": "str", "choices": ["null", "des"] }, "interface": { "required": False, "type": "str" }, "local_gw": { "required": False, "type": "str" }, "localspi": { "required": False, "type": "str" }, "name": { "required": True, "type": "str" }, "remote_gw": { "required": False, "type": "str" }, "remotespi": { "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_ipsec( 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_ipsec(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"] }, "webfilter_override": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "expires": { "required": False, "type": "str" }, "id": { "required": True, "type": "int" }, "initiator": { "required": False, "type": "str" }, "ip": { "required": False, "type": "str" }, "ip6": { "required": False, "type": "str" }, "new_profile": { "required": False, "type": "str" }, "old_profile": { "required": False, "type": "str" }, "scope": { "required": False, "type": "str", "choices": ["user", "user-group", "ip", "ip6"] }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "user": { "required": False, "type": "str" }, "user_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_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": True, "type": "str", "choices": ["present", "absent"] }, "system_snmp_user": { "required": False, "type": "dict", "default": None, "options": { "auth_proto": { "required": False, "type": "str", "choices": ["md5", "sha"] }, "auth_pwd": { "required": False, "type": "str" }, "events": { "required": False, "type": "list", "choices": [ "cpu-high", "mem-low", "log-full", "intf-ip", "vpn-tun-up", "vpn-tun-down", "ha-switch", "ha-hb-failure", "ips-signature", "ips-anomaly", "av-virus", "av-oversize", "av-pattern", "av-fragmented", "fm-if-change", "fm-conf-change", "bgp-established", "bgp-backward-transition", "ha-member-up", "ha-member-down", "ent-conf-change", "av-conserve", "av-bypass", "av-oversize-passed", "av-oversize-blocked", "ips-pkg-update", "ips-fail-open", "faz-disconnect", "wc-ap-up", "wc-ap-down", "fswctl-session-up", "fswctl-session-down", "load-balance-real-server-down", "device-new", "per-cpu-high" ] }, "ha_direct": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "name": { "required": True, "type": "str" }, "notify_hosts": { "required": False, "type": "list" }, "notify_hosts6": { "required": False, "type": "list" }, "priv_proto": { "required": False, "type": "str", "choices": ["aes", "des", "aes256", "aes256cisco"] }, "priv_pwd": { "required": False, "type": "str" }, "queries": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "query_port": { "required": False, "type": "int" }, "security_level": { "required": False, "type": "str", "choices": ["no-auth-no-priv", "auth-no-priv", "auth-priv"] }, "source_ip": { "required": False, "type": "str" }, "source_ipv6": { "required": False, "type": "str" }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "trap_lport": { "required": False, "type": "int" }, "trap_rport": { "required": False, "type": "int" }, "trap_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_snmp( 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_snmp(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 }, "web_proxy_global": { "required": False, "type": "dict", "default": None, "options": { "fast_policy_match": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "forward_proxy_auth": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "forward_server_affinity_timeout": { "required": False, "type": "int" }, "learn_client_ip": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "learn_client_ip_from_header": { "required": False, "type": "str", "choices": ["true-client-ip", "x-real-ip", "x-forwarded-for"] }, "learn_client_ip_srcaddr": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "learn_client_ip_srcaddr6": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "max_message_length": { "required": False, "type": "int" }, "max_request_length": { "required": False, "type": "int" }, "max_waf_body_cache_length": { "required": False, "type": "int" }, "proxy_fqdn": { "required": False, "type": "str" }, "strict_web_check": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "tunnel_non_http": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "unknown_http_version": { "required": False, "type": "str", "choices": ["reject", "tunnel", "best-effort"] }, "webproxy_profile": { "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_web_proxy( 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_web_proxy(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_vip46": { "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" }, "id": { "required": False, "type": "int" }, "ldb_method": { "required": False, "type": "str", "choices": [ "static", "round-robin", "weighted", "least-session", "least-rtt", "first-alive" ] }, "mappedip": { "required": False, "type": "str" }, "mappedport": { "required": False, "type": "str" }, "monitor": { "required": False, "type": "list", "options": { "name": { "required": True, "type": "str" } } }, "name": { "required": True, "type": "str" }, "portforward": { "required": False, "type": "str", "choices": ["disable", "enable"] }, "protocol": { "required": False, "type": "str", "choices": ["tcp", "udp"] }, "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" }, "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", "tcp", "udp", "ip"] }, "src_filter": { "required": False, "type": "list", "options": { "range": { "required": True, "type": "str" } } }, "type": { "required": False, "type": "str", "choices": ["static-nat", "server-load-balance"] }, "uuid": { "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_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_fortiguard_setting": { "required": False, "type": "dict", "default": None, "options": { "enc_algorithm": { "required": False, "type": "str", "choices": ["high-medium", "high", "low"] }, "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_fortiguard( 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_fortiguard( 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_ha": { "required": False, "type": "dict", "default": None, "options": { "arps": { "required": False, "type": "int" }, "arps_interval": { "required": False, "type": "int" }, "authentication": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "cpu_threshold": { "required": False, "type": "str" }, "encryption": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ftp_proxy_threshold": { "required": False, "type": "str" }, "gratuitous_arps": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "group_id": { "required": False, "type": "int" }, "group_name": { "required": False, "type": "str" }, "ha_direct": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ha_eth_type": { "required": False, "type": "str" }, "ha_mgmt_interfaces": { "required": False, "type": "list", "options": { "dst": { "required": False, "type": "str" }, "gateway": { "required": False, "type": "str" }, "gateway6": { "required": False, "type": "str" }, "id": { "required": True, "type": "int" }, "interface": { "required": False, "type": "str" } } }, "ha_mgmt_status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "ha_uptime_diff_margin": { "required": False, "type": "int" }, "hb_interval": { "required": False, "type": "int" }, "hb_lost_threshold": { "required": False, "type": "int" }, "hbdev": { "required": False, "type": "str" }, "hc_eth_type": { "required": False, "type": "str" }, "hello_holddown": { "required": False, "type": "int" }, "http_proxy_threshold": { "required": False, "type": "str" }, "imap_proxy_threshold": { "required": False, "type": "str" }, "inter_cluster_session_sync": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "key": { "required": False, "type": "str" }, "l2ep_eth_type": { "required": False, "type": "str" }, "link_failed_signal": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "load_balance_all": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "memory_compatible_mode": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "memory_threshold": { "required": False, "type": "str" }, "mode": { "required": False, "type": "str", "choices": ["standalone", "a-a", "a-p"] }, "monitor": { "required": False, "type": "str" }, "multicast_ttl": { "required": False, "type": "int" }, "nntp_proxy_threshold": { "required": False, "type": "str" }, "override": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "override_wait_time": { "required": False, "type": "int" }, "password": { "required": False, "type": "str" }, "pingserver_failover_threshold": { "required": False, "type": "int" }, "pingserver_flip_timeout": { "required": False, "type": "int" }, "pingserver_monitor_interface": { "required": False, "type": "str" }, "pingserver_slave_force_reset": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "pop3_proxy_threshold": { "required": False, "type": "str" }, "priority": { "required": False, "type": "int" }, "route_hold": { "required": False, "type": "int" }, "route_ttl": { "required": False, "type": "int" }, "route_wait": { "required": False, "type": "int" }, "schedule": { "required": False, "type": "str", "choices": [ "none", "hub", "leastconnection", "round-robin", "weight-round-robin", "random", "ip", "ipport" ] }, "secondary_vcluster": { "required": False, "type": "dict", "options": { "monitor": { "required": False, "type": "str" }, "override": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "override_wait_time": { "required": False, "type": "int" }, "pingserver_failover_threshold": { "required": False, "type": "int" }, "pingserver_monitor_interface": { "required": False, "type": "str" }, "pingserver_slave_force_reset": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "priority": { "required": False, "type": "int" }, "vcluster_id": { "required": False, "type": "int" }, "vdom": { "required": False, "type": "str" } } }, "session_pickup": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "session_pickup_connectionless": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "session_pickup_delay": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "session_pickup_expectation": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "session_pickup_nat": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "session_sync_dev": { "required": False, "type": "str" }, "smtp_proxy_threshold": { "required": False, "type": "str" }, "standalone_config_sync": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "standalone_mgmt_vdom": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "sync_config": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "sync_packet_balance": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "unicast_hb": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "unicast_hb_netmask": { "required": False, "type": "str" }, "unicast_hb_peerip": { "required": False, "type": "str" }, "uninterruptible_upgrade": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "vcluster_id": { "required": False, "type": "int" }, "vcluster2": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "vdom": { "required": False, "type": "str" }, "weight": { "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(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 }, "system_netflow": { "required": False, "type": "dict", "default": None, "options": { "active_flow_timeout": { "required": False, "type": "int" }, "collector_ip": { "required": False, "type": "str" }, "collector_port": { "required": False, "type": "int" }, "inactive_flow_timeout": { "required": False, "type": "int" }, "source_ip": { "required": False, "type": "str" }, "template_tx_counter": { "required": False, "type": "int" }, "template_tx_timeout": { "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_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_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"] }, "wireless_controller_hotspot20_anqp_network_auth_type": { "required": False, "type": "dict", "default": None, "options": { "auth_type": { "required": False, "type": "str", "choices": [ "acceptance-of-terms", "online-enrollment", "http-redirection", "dns-redirection" ] }, "name": { "required": True, "type": "str" }, "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_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"] }, "dlp_filepattern": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "comment": { "required": False, "type": "str" }, "entries": { "required": False, "type": "list", "options": { "file_type": { "required": False, "type": "str", "choices": [ "7z", "arj", "cab", "lzh", "rar", "tar", "zip", "bzip", "gzip", "bzip2", "xz", "bat", "msc", "uue", "mime", "base64", "binhex", "elf", "exe", "hta", "html", "jad", "class", "cod", "javascript", "msoffice", "msofficex", "fsg", "upx", "petite", "aspack", "sis", "hlp", "activemime", "jpeg", "gif", "tiff", "png", "bmp", "ignored", "unknown", "mpeg", "mov", "mp3", "wma", "wav", "pdf", "avi", "rm", "torrent", "hibun", "msi", "mach-o", "dmg", ".net", "xar", "chm", "iso", "crx" ] }, "filter_type": { "required": False, "type": "str", "choices": ["pattern", "type"] }, "pattern": { "required": True, "type": "str" } } }, "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_dlp(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_dlp(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"] }, "webfilter_urlfilter": { "required": False, "type": "dict", "default": None, "options": { "state": { "required": False, "type": "str", "choices": ["present", "absent"] }, "comment": { "required": False, "type": "str" }, "entries": { "required": False, "type": "list", "options": { "action": { "required": False, "type": "str", "choices": ["exempt", "block", "allow", "monitor"] }, "dns_address_family": { "required": False, "type": "str", "choices": ["ipv4", "ipv6", "both"] }, "exempt": { "required": False, "type": "str", "choices": [ "av", "web-content", "activex-java-cookie", "dlp", "fortiguard", "range-block", "pass", "all" ] }, "id": { "required": True, "type": "int" }, "referrer_host": { "required": False, "type": "str" }, "status": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "type": { "required": False, "type": "str", "choices": ["simple", "regex", "wildcard"] }, "url": { "required": False, "type": "str" }, "web_proxy_profile": { "required": False, "type": "str" } } }, "id": { "required": True, "type": "int" }, "ip_addr_block": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "name": { "required": False, "type": "str" }, "one_arm_ips_urlfilter": { "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 }, "endpoint_control_settings": { "required": False, "type": "dict", "default": None, "options": { "download_custom_link": { "required": False, "type": "str" }, "download_location": { "required": False, "type": "str", "choices": ["fortiguard", "custom"] }, "forticlient_avdb_update_interval": { "required": False, "type": "int" }, "forticlient_dereg_unsupported_client": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "forticlient_ems_rest_api_call_timeout": { "required": False, "type": "int" }, "forticlient_keepalive_interval": { "required": False, "type": "int" }, "forticlient_offline_grace": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "forticlient_offline_grace_interval": { "required": False, "type": "int" }, "forticlient_reg_key": { "required": False, "type": "str" }, "forticlient_reg_key_enforce": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "forticlient_reg_timeout": { "required": False, "type": "int" }, "forticlient_sys_update_interval": { "required": False, "type": "int" }, "forticlient_user_avatar": { "required": False, "type": "str", "choices": ["enable", "disable"] }, "forticlient_warning_interval": { "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_endpoint_control( 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_endpoint_control( 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_proxy_addrgrp": { "required": False, "type": "dict", "default": None, "options": { "state": {"required": False, "type": "str", "choices": ["present", "absent"]}, "color": {"required": False, "type": "int"}, "comment": {"required": False, "type": "str"}, "member": {"required": False, "type": "list", "options": { "name": {"required": True, "type": "str"} }}, "name": {"required": True, "type": "str"}, "tagging": {"required": False, "type": "list", "options": { "category": {"required": False, "type": "str"}, "name": {"required": True, "type": "str"}, "tags": {"required": False, "type": "list", "options": { "name": {"required": True, "type": "str"} }} }}, "type": {"required": False, "type": "str", "choices": ["src", "dst"]}, "uuid": {"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(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"]}, "endpoint_control_forticlient_ems": { "required": False, "type": "dict", "default": None, "options": { "state": {"required": False, "type": "str", "choices": ["present", "absent"]}, "address": {"required": False, "type": "str"}, "admin_password": {"required": False, "type": "str"}, "admin_type": {"required": False, "type": "str", "choices": ["Windows", "LDAP"]}, "admin_username": {"required": False, "type": "str"}, "https_port": {"required": False, "type": "int"}, "listen_port": {"required": False, "type": "int"}, "name": {"required": True, "type": "str"}, "rest_api_auth": {"required": False, "type": "str", "choices": ["disable", "userpass"]}, "serial_number": {"required": False, "type": "str"}, "upload_port": {"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_endpoint_control(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_endpoint_control(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)