Пример #1
0
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},
        "switch_controller_quarantine": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "quarantine": {"required": False, "type": "str",
                               "choices": ["enable", "disable"]},
                "targets": {"required": False, "type": "list",
                            "options": {
                                "description": {"required": False, "type": "str"},
                                "entry_id": {"required": False, "type": "int"},
                                "mac": {"required": True, "type": "str"},
                                "tag": {"required": False, "type": "list",
                                        "options": {
                                            "tags": {"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": True, "type": "str",
                  "choices": ["present", "absent"]},
        "system_vdom_exception": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "id": {"required": True, "type": "int"},
                "object": {"required": False, "type": "str",
                           "choices": ["log.fortianalyzer.setting", "log.fortianalyzer.override-setting"]},
                "oid": {"required": False, "type": "int"},
                "scope": {"required": False, "type": "str",
                          "choices": ["all", "inclusive", "exclusive"]},
                "vdom": {"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_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)
Пример #3
0
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_fortisandbox": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "email": {"required": False, "type": "str"},
                "enc_algorithm": {"required": False, "type": "str",
                                  "choices": ["default", "high", "low"]},
                "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"]}

            }
        }
    }

    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},
        "report_setting": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "fortiview": {"required": False, "type": "str",
                              "choices": ["enable", "disable"]},
                "pdf_report": {"required": False, "type": "str",
                               "choices": ["enable", "disable"]},
                "report_source": {"required": False, "type": "str",
                                  "choices": ["forward-traffic", "sniffer-traffic", "local-deny-traffic"]},
                "top_n": {"required": False, "type": "int"},
                "web_browsing_threshold": {"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_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},
        "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},
        "wanopt_settings": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "auto_detect_algorithm": {"required": False, "type": "str",
                                          "choices": ["simple", "diff-req-resp"]},
                "host_id": {"required": False, "type": "str"},
                "tunnel_ssl_algorithm": {"required": False, "type": "str",
                                         "choices": ["low"]}

            }
        }
    }

    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)
Пример #7
0
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_memory_global_setting": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "full_final_warning_threshold": {"required": False, "type": "int"},
                "full_first_warning_threshold": {"required": False, "type": "int"},
                "full_second_warning_threshold": {"required": False, "type": "int"},
                "max_size": {"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_log_memory(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_memory(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)
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_multicast_address": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "associated_interface": {
                    "required": False,
                    "type": "str"
                },
                "color": {
                    "required": False,
                    "type": "int"
                },
                "comment": {
                    "required": False,
                    "type": "str"
                },
                "end_ip": {
                    "required": False,
                    "type": "str"
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "start_ip": {
                    "required": False,
                    "type": "str"
                },
                "subnet": {
                    "required": False,
                    "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": ["multicastrange", "broadcastmask"]
                },
                "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)
Пример #10
0
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_accprofile": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "admintimeout": {
                    "required": False,
                    "type": "int"
                },
                "admintimeout_override": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "authgrp": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "read", "read-write"]
                },
                "comments": {
                    "required": False,
                    "type": "str"
                },
                "ftviewgrp": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "read", "read-write"]
                },
                "fwgrp": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "read", "read-write", "custom"]
                },
                "fwgrp_permission": {
                    "required": False,
                    "type": "dict",
                    "options": {
                        "address": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "policy": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "schedule": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "service": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        }
                    }
                },
                "loggrp": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "read", "read-write", "custom"]
                },
                "loggrp_permission": {
                    "required": False,
                    "type": "dict",
                    "options": {
                        "config": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "data_access": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "report_access": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "threat_weight": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        }
                    }
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "netgrp": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "read", "read-write", "custom"]
                },
                "netgrp_permission": {
                    "required": False,
                    "type": "dict",
                    "options": {
                        "cfg": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "packet_capture": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "route_cfg": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        }
                    }
                },
                "scope": {
                    "required": False,
                    "type": "str",
                    "choices": ["vdom", "global"]
                },
                "secfabgrp": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "read", "read-write"]
                },
                "sysgrp": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "read", "read-write", "custom"]
                },
                "sysgrp_permission": {
                    "required": False,
                    "type": "dict",
                    "options": {
                        "admin": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "cfg": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "mnt": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "upd": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        }
                    }
                },
                "utmgrp": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "read", "read-write", "custom"]
                },
                "utmgrp_permission": {
                    "required": False,
                    "type": "dict",
                    "options": {
                        "antivirus": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "application_control": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "data_loss_prevention": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "dnsfilter": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "endpoint_control": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "icap": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "ips": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "spamfilter": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "voip": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "waf": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        },
                        "webfilter": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "read", "read-write"]
                        }
                    }
                },
                "vpngrp": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "read", "read-write"]
                },
                "wanoptgrp": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "read", "read-write"]
                },
                "wifi": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "read", "read-write"]
                }
            }
        }
    }

    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"]},
        "icap_profile": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "state": {"required": False, "type": "str",
                          "choices": ["present", "absent"]},
                "methods": {"required": False, "type": "str",
                            "choices": ["delete", "get", "head",
                                        "options", "post", "put",
                                        "trace", "other"]},
                "name": {"required": True, "type": "str"},
                "replacemsg_group": {"required": False, "type": "str"},
                "request": {"required": False, "type": "str",
                            "choices": ["disable", "enable"]},
                "request_failure": {"required": False, "type": "str",
                                    "choices": ["error", "bypass"]},
                "request_path": {"required": False, "type": "str"},
                "request_server": {"required": False, "type": "str"},
                "response": {"required": False, "type": "str",
                             "choices": ["disable", "enable"]},
                "response_failure": {"required": False, "type": "str",
                                     "choices": ["error", "bypass"]},
                "response_path": {"required": False, "type": "str"},
                "response_server": {"required": False, "type": "str"},
                "streaming_content_bypass": {"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_icap(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_icap(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)
Пример #12
0
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
        },
        "state": {
            "required": True,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "wireless_controller_qos_profile": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "bandwidth_admission_control": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "bandwidth_capacity": {
                    "required": False,
                    "type": "int"
                },
                "burst": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "call_admission_control": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "call_capacity": {
                    "required": False,
                    "type": "int"
                },
                "comment": {
                    "required": False,
                    "type": "str"
                },
                "downlink": {
                    "required": False,
                    "type": "int"
                },
                "downlink_sta": {
                    "required": False,
                    "type": "int"
                },
                "dscp_wmm_be": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "id": {
                            "required": True,
                            "type": "int"
                        }
                    }
                },
                "dscp_wmm_bk": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "id": {
                            "required": True,
                            "type": "int"
                        }
                    }
                },
                "dscp_wmm_mapping": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "dscp_wmm_vi": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "id": {
                            "required": True,
                            "type": "int"
                        }
                    }
                },
                "dscp_wmm_vo": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "id": {
                            "required": True,
                            "type": "int"
                        }
                    }
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "uplink": {
                    "required": False,
                    "type": "int"
                },
                "uplink_sta": {
                    "required": False,
                    "type": "int"
                },
                "wmm": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "wmm_uapsd": {
                    "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
        },
        "state": {
            "required": False,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "firewall_ssh_host_key": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "hostname": {
                    "required": False,
                    "type": "str"
                },
                "ip": {
                    "required": False,
                    "type": "str"
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "nid": {
                    "required": False,
                    "type": "str",
                    "choices": ["256", "384", "521"]
                },
                "port": {
                    "required": False,
                    "type": "int"
                },
                "public_key": {
                    "required": False,
                    "type": "str"
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["trusted", "revoked"]
                },
                "type": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "RSA", "DSA", "ECDSA", "ED25519", "RSA-CA", "DSA-CA",
                        "ECDSA-CA", "ED25519-CA"
                    ]
                }
            }
        }
    }

    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_ssh(
                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_ssh(
            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)
Пример #15
0
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
        },
        "vpn_ssl_settings": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "auth_timeout": {
                    "required": False,
                    "type": "int"
                },
                "authentication_rule": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "auth": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["any", "local", "radius", "tacacs+", "ldap"]
                        },
                        "cipher": {
                            "required": False,
                            "type": "str",
                            "choices": ["any", "high", "medium"]
                        },
                        "client_cert": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "groups": {
                            "required": False,
                            "type": "list",
                            "options": {
                                "name": {
                                    "required": True,
                                    "type": "str"
                                }
                            }
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "portal": {
                            "required": False,
                            "type": "str"
                        },
                        "realm": {
                            "required": False,
                            "type": "str"
                        },
                        "source_address": {
                            "required": False,
                            "type": "list",
                            "options": {
                                "name": {
                                    "required": True,
                                    "type": "str"
                                }
                            }
                        },
                        "source_address_negate": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "source_address6": {
                            "required": False,
                            "type": "list",
                            "options": {
                                "name": {
                                    "required": True,
                                    "type": "str"
                                }
                            }
                        },
                        "source_address6_negate": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "source_interface": {
                            "required": False,
                            "type": "list",
                            "options": {
                                "name": {
                                    "required": True,
                                    "type": "str"
                                }
                            }
                        },
                        "users": {
                            "required": False,
                            "type": "list",
                            "options": {
                                "name": {
                                    "required": True,
                                    "type": "str"
                                }
                            }
                        }
                    }
                },
                "auto_tunnel_static_route": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "banned_cipher": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "RSA", "DH", "DHE", "ECDH", "ECDHE", "DSS", "ECDSA",
                        "AES", "AESGCM", "CAMELLIA", "3DES", "SHA1", "SHA256",
                        "SHA384", "STATIC"
                    ]
                },
                "check_referer": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "default_portal": {
                    "required": False,
                    "type": "str"
                },
                "deflate_compression_level": {
                    "required": False,
                    "type": "int"
                },
                "deflate_min_data_size": {
                    "required": False,
                    "type": "int"
                },
                "dns_server1": {
                    "required": False,
                    "type": "str"
                },
                "dns_server2": {
                    "required": False,
                    "type": "str"
                },
                "dns_suffix": {
                    "required": False,
                    "type": "str"
                },
                "dtls_hello_timeout": {
                    "required": False,
                    "type": "int"
                },
                "dtls_tunnel": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "force_two_factor_auth": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "header_x_forwarded_for": {
                    "required": False,
                    "type": "str",
                    "choices": ["pass", "add", "remove"]
                },
                "http_compression": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "http_only_cookie": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "http_request_body_timeout": {
                    "required": False,
                    "type": "int"
                },
                "http_request_header_timeout": {
                    "required": False,
                    "type": "int"
                },
                "https_redirect": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "idle_timeout": {
                    "required": False,
                    "type": "int"
                },
                "ipv6_dns_server1": {
                    "required": False,
                    "type": "str"
                },
                "ipv6_dns_server2": {
                    "required": False,
                    "type": "str"
                },
                "ipv6_wins_server1": {
                    "required": False,
                    "type": "str"
                },
                "ipv6_wins_server2": {
                    "required": False,
                    "type": "str"
                },
                "login_attempt_limit": {
                    "required": False,
                    "type": "int"
                },
                "login_block_time": {
                    "required": False,
                    "type": "int"
                },
                "login_timeout": {
                    "required": False,
                    "type": "int"
                },
                "port": {
                    "required": False,
                    "type": "int"
                },
                "port_precedence": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "reqclientcert": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "route_source_interface": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "servercert": {
                    "required": False,
                    "type": "str"
                },
                "source_address": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "source_address_negate": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "source_address6": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "source_address6_negate": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "source_interface": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "ssl_client_renegotiation": {
                    "required": False,
                    "type": "str",
                    "choices": ["disable", "enable"]
                },
                "ssl_insert_empty_fragment": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "tlsv1_0": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "tlsv1_1": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "tlsv1_2": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "tunnel_ip_pools": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "tunnel_ipv6_pools": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "unsafe_legacy_renegotiation": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "url_obscuration": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "wins_server1": {
                    "required": False,
                    "type": "str"
                },
                "wins_server2": {
                    "required": False,
                    "type": "str"
                },
                "x_content_type_options": {
                    "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_vpn_ssl(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(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)
Пример #16
0
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_syslogd_setting": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "certificate": {"required": False, "type": "str"},
                "custom_field_name": {"required": False, "type": "list",
                                      "options": {
                                          "custom": {"required": False, "type": "str"},
                                          "id": {"required": True, "type": "int"},
                                          "name": {"required": False, "type": "str"}
                                      }},
                "enc_algorithm": {"required": False, "type": "str",
                                  "choices": ["high-medium", "high", "low",
                                              "disable"]},
                "facility": {"required": False, "type": "str",
                             "choices": ["kernel", "user", "mail",
                                         "daemon", "auth", "syslog",
                                         "lpr", "news", "uucp",
                                         "cron", "authpriv", "ftp",
                                         "ntp", "audit", "alert",
                                         "clock", "local0", "local1",
                                         "local2", "local3", "local4",
                                         "local5", "local6", "local7"]},
                "format": {"required": False, "type": "str",
                           "choices": ["default", "csv", "cef"]},
                "mode": {"required": False, "type": "str",
                         "choices": ["udp", "legacy-reliable", "reliable"]},
                "port": {"required": False, "type": "int"},
                "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"]}

            }
        }
    }

    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_syslogd(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_syslogd(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_probe_response": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "http_probe_value": {
                    "required": False,
                    "type": "str"
                },
                "mode": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "http-probe", "twamp"]
                },
                "password": {
                    "required": False,
                    "type": "str"
                },
                "port": {
                    "required": False,
                    "type": "int"
                },
                "security_mode": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "authentication"]
                },
                "timeout": {
                    "required": False,
                    "type": "int"
                },
                "ttl_mode": {
                    "required": False,
                    "type": "str",
                    "choices": ["reinit", "decrease", "retain"]
                }
            }
        }
    }

    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},
        "wireless_controller_setting": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "account_id": {"required": False, "type": "str"},
                "country": {"required": False, "type": "str",
                            "choices": ["NA", "AL", "DZ",
                                        "AO", "AR", "AM",
                                        "AU", "AT", "AZ",
                                        "BH", "BD", "BB",
                                        "BY", "BE", "BZ",
                                        "BO", "BA", "BR",
                                        "BN", "BG", "KH",
                                        "CL", "CN", "CO",
                                        "CR", "HR", "CY",
                                        "CZ", "DK", "DO",
                                        "EC", "EG", "SV",
                                        "EE", "FI", "FR",
                                        "GE", "DE", "GR",
                                        "GL", "GD", "GU",
                                        "GT", "HT", "HN",
                                        "HK", "HU", "IS",
                                        "IN", "ID", "IR",
                                        "IE", "IL", "IT",
                                        "JM", "JO", "KZ",
                                        "KE", "KP", "KR",
                                        "KW", "LV", "LB",
                                        "LI", "LT", "LU",
                                        "MO", "MK", "MY",
                                        "MT", "MX", "MC",
                                        "MA", "MZ", "MM",
                                        "NP", "NL", "AN",
                                        "AW", "NZ", "NO",
                                        "OM", "PK", "PA",
                                        "PG", "PY", "PE",
                                        "PH", "PL", "PT",
                                        "PR", "QA", "RO",
                                        "RU", "RW", "SA",
                                        "RS", "ME", "SG",
                                        "SK", "SI", "ZA",
                                        "ES", "LK", "SE",
                                        "SD", "CH", "SY",
                                        "TW", "TZ", "TH",
                                        "TT", "TN", "TR",
                                        "AE", "UA", "GB",
                                        "US", "PS", "UY",
                                        "UZ", "VE", "VN",
                                        "YE", "ZB", "ZW",
                                        "JP", "CA"]},
                "duplicate_ssid": {"required": False, "type": "str",
                                   "choices": ["enable", "disable"]},
                "fapc_compatibility": {"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
        },
        "log_syslogd_filter": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "anomaly": {
                    "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_syslogd(
                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_syslogd(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_central_management": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "allow_monitor": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "allow_push_configuration": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "allow_push_firmware": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "allow_remote_firmware_upgrade": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "enc_algorithm": {
                    "required": False,
                    "type": "str",
                    "choices": ["default", "high", "low"]
                },
                "fmg": {
                    "required": False,
                    "type": "str"
                },
                "fmg_source_ip": {
                    "required": False,
                    "type": "str"
                },
                "fmg_source_ip6": {
                    "required": False,
                    "type": "str"
                },
                "include_default_servers": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "mode": {
                    "required": False,
                    "type": "str",
                    "choices": ["normal", "backup"]
                },
                "schedule_config_restore": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "schedule_script_restore": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "serial_number": {
                    "required": False,
                    "type": "str"
                },
                "server_list": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "addr_type": {
                            "required": False,
                            "type": "str",
                            "choices": ["ipv4", "ipv6", "fqdn"]
                        },
                        "fqdn": {
                            "required": False,
                            "type": "str"
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "server_address": {
                            "required": False,
                            "type": "str"
                        },
                        "server_address6": {
                            "required": False,
                            "type": "str"
                        },
                        "server_type": {
                            "required": False,
                            "type": "str",
                            "choices": ["update", "rating"]
                        }
                    }
                },
                "type": {
                    "required": False,
                    "type": "str",
                    "choices": ["fortimanager", "fortiguard", "none"]
                },
                "vdom": {
                    "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_fortiguard": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "antispam_cache": {"required": False, "type": "str",
                                   "choices": ["enable", "disable"]},
                "antispam_cache_mpercent": {"required": False, "type": "int"},
                "antispam_cache_ttl": {"required": False, "type": "int"},
                "antispam_expiration": {"required": False, "type": "int"},
                "antispam_force_off": {"required": False, "type": "str",
                                       "choices": ["enable", "disable"]},
                "antispam_license": {"required": False, "type": "int"},
                "antispam_timeout": {"required": False, "type": "int"},
                "auto_join_forticloud": {"required": False, "type": "str",
                                         "choices": ["enable", "disable"]},
                "ddns_server_ip": {"required": False, "type": "str"},
                "ddns_server_port": {"required": False, "type": "int"},
                "load_balance_servers": {"required": False, "type": "int"},
                "outbreak_prevention_cache": {"required": False, "type": "str",
                                              "choices": ["enable", "disable"]},
                "outbreak_prevention_cache_mpercent": {"required": False, "type": "int"},
                "outbreak_prevention_cache_ttl": {"required": False, "type": "int"},
                "outbreak_prevention_expiration": {"required": False, "type": "int"},
                "outbreak_prevention_force_off": {"required": False, "type": "str",
                                                  "choices": ["enable", "disable"]},
                "outbreak_prevention_license": {"required": False, "type": "int"},
                "outbreak_prevention_timeout": {"required": False, "type": "int"},
                "port": {"required": False, "type": "str",
                         "choices": ["53", "8888", "80"]},
                "sdns_server_ip": {"required": False, "type": "str"},
                "sdns_server_port": {"required": False, "type": "int"},
                "service_account_id": {"required": False, "type": "str"},
                "source_ip": {"required": False, "type": "str"},
                "source_ip6": {"required": False, "type": "str"},
                "update_server_location": {"required": False, "type": "str",
                                           "choices": ["usa", "any"]},
                "webfilter_cache": {"required": False, "type": "str",
                                    "choices": ["enable", "disable"]},
                "webfilter_cache_ttl": {"required": False, "type": "int"},
                "webfilter_expiration": {"required": False, "type": "int"},
                "webfilter_force_off": {"required": False, "type": "str",
                                        "choices": ["enable", "disable"]},
                "webfilter_license": {"required": False, "type": "int"},
                "webfilter_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"]
        },
        "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)
Пример #23
0
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_csf": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "configuration_sync": {"required": False, "type": "str",
                                       "choices": ["default", "local"]},
                "fabric_device": {"required": False, "type": "list",
                                  "options": {
                                      "device_ip": {"required": False, "type": "str"},
                                      "device_type": {"required": False, "type": "str",
                                                      "choices": ["fortimail"]},
                                      "login": {"required": False, "type": "str"},
                                      "name": {"required": True, "type": "str"},
                                      "password": {"required": False, "type": "str"}
                                  }},
                "fixed_key": {"required": False, "type": "str"},
                "group_name": {"required": False, "type": "str"},
                "group_password": {"required": False, "type": "str"},
                "management_ip": {"required": False, "type": "str"},
                "management_port": {"required": False, "type": "int"},
                "status": {"required": False, "type": "str",
                           "choices": ["enable", "disable"]},
                "trusted_list": {"required": False, "type": "list",
                                 "options": {
                                     "action": {"required": False, "type": "str",
                                                "choices": ["accept", "deny"]},
                                     "downstream_authorization": {"required": False, "type": "str",
                                                                  "choices": ["enable", "disable"]},
                                     "ha_members": {"required": False, "type": "str"},
                                     "serial": {"required": True, "type": "str"}
                                 }},
                "upstream_ip": {"required": False, "type": "str"},
                "upstream_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_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_link_monitor": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "addr_mode": {"required": False, "type": "str",
                              "choices": ["ipv4", "ipv6"]},
                "failtime": {"required": False, "type": "int"},
                "gateway_ip": {"required": False, "type": "str"},
                "gateway_ip6": {"required": False, "type": "str"},
                "ha_priority": {"required": False, "type": "int"},
                "http_agent": {"required": False, "type": "str"},
                "http_get": {"required": False, "type": "str"},
                "http_match": {"required": False, "type": "str"},
                "interval": {"required": False, "type": "int"},
                "name": {"required": True, "type": "str"},
                "packet_size": {"required": False, "type": "int"},
                "password": {"required": False, "type": "str"},
                "port": {"required": False, "type": "int"},
                "protocol": {"required": False, "type": "str",
                             "choices": ["ping", "tcp-echo", "udp-echo",
                                         "http", "twamp", "ping6"]},
                "recoverytime": {"required": False, "type": "int"},
                "security_mode": {"required": False, "type": "str",
                                  "choices": ["none", "authentication"]},
                "server": {"required": False, "type": "list",
                           "options": {
                               "address": {"required": True, "type": "str"}
                           }},
                "source_ip": {"required": False, "type": "str"},
                "source_ip6": {"required": False, "type": "str"},
                "srcintf": {"required": False, "type": "str"},
                "status": {"required": False, "type": "str",
                           "choices": ["enable", "disable"]},
                "update_cascade_interface": {"required": False, "type": "str",
                                             "choices": ["enable", "disable"]},
                "update_static_route": {"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_shaper_traffic_shaper": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "bandwidth_unit": {
                    "required": False,
                    "type": "str",
                    "choices": ["kbps", "mbps", "gbps"]
                },
                "diffserv": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "diffservcode": {
                    "required": False,
                    "type": "str"
                },
                "guaranteed_bandwidth": {
                    "required": False,
                    "type": "int"
                },
                "maximum_bandwidth": {
                    "required": False,
                    "type": "int"
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "per_policy": {
                    "required": False,
                    "type": "str",
                    "choices": ["disable", "enable"]
                },
                "priority": {
                    "required": False,
                    "type": "str",
                    "choices": ["low", "medium", "high"]
                }
            }
        }
    }

    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_shaper(
                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_shaper(
            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)
Пример #26
0
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_policy46": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "action": {
                    "required": False,
                    "type": "str",
                    "choices": ["accept", "deny"]
                },
                "comments": {
                    "required": False,
                    "type": "str"
                },
                "dstaddr": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "dstintf": {
                    "required": False,
                    "type": "str"
                },
                "fixedport": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "ippool": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "logtraffic": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "per_ip_shaper": {
                    "required": False,
                    "type": "str"
                },
                "permit_any_host": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "policyid": {
                    "required": True,
                    "type": "int"
                },
                "poolname": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "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"
                        }
                    }
                },
                "srcintf": {
                    "required": False,
                    "type": "str"
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "tcp_mss_receiver": {
                    "required": False,
                    "type": "int"
                },
                "tcp_mss_sender": {
                    "required": False,
                    "type": "int"
                },
                "traffic_shaper": {
                    "required": False,
                    "type": "str"
                },
                "traffic_shaper_reverse": {
                    "required": False,
                    "type": "str"
                },
                "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)
Пример #27
0
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_ospf6": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "abr_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["cisco", "ibm", "standard"]
                },
                "area": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "default_cost": {
                            "required": False,
                            "type": "int"
                        },
                        "id": {
                            "required": True,
                            "type": "str"
                        },
                        "nssa_default_information_originate": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "nssa_default_information_originate_metric": {
                            "required": False,
                            "type": "int"
                        },
                        "nssa_default_information_originate_metric_type": {
                            "required": False,
                            "type": "str",
                            "choices": ["1", "2"]
                        },
                        "nssa_redistribution": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "nssa_translator_role": {
                            "required": False,
                            "type": "str",
                            "choices": ["candidate", "never", "always"]
                        },
                        "range": {
                            "required": False,
                            "type": "list",
                            "options": {
                                "advertise": {
                                    "required": False,
                                    "type": "str",
                                    "choices": ["disable", "enable"]
                                },
                                "id": {
                                    "required": True,
                                    "type": "int"
                                },
                                "prefix6": {
                                    "required": False,
                                    "type": "str"
                                }
                            }
                        },
                        "stub_type": {
                            "required": False,
                            "type": "str",
                            "choices": ["no-summary", "summary"]
                        },
                        "type": {
                            "required": False,
                            "type": "str",
                            "choices": ["regular", "nssa", "stub"]
                        },
                        "virtual_link": {
                            "required": False,
                            "type": "list",
                            "options": {
                                "dead_interval": {
                                    "required": False,
                                    "type": "int"
                                },
                                "hello_interval": {
                                    "required": False,
                                    "type": "int"
                                },
                                "name": {
                                    "required": True,
                                    "type": "str"
                                },
                                "peer": {
                                    "required": False,
                                    "type": "str"
                                },
                                "retransmit_interval": {
                                    "required": False,
                                    "type": "int"
                                },
                                "transmit_delay": {
                                    "required": False,
                                    "type": "int"
                                }
                            }
                        }
                    }
                },
                "auto_cost_ref_bandwidth": {
                    "required": False,
                    "type": "int"
                },
                "bfd": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "default_information_metric": {
                    "required": False,
                    "type": "int"
                },
                "default_information_metric_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["1", "2"]
                },
                "default_information_originate": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "always", "disable"]
                },
                "default_information_route_map": {
                    "required": False,
                    "type": "str"
                },
                "default_metric": {
                    "required": False,
                    "type": "int"
                },
                "log_neighbour_changes": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "ospf6_interface": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "area_id": {
                            "required": False,
                            "type": "str"
                        },
                        "bfd": {
                            "required": False,
                            "type": "str",
                            "choices": ["global", "enable", "disable"]
                        },
                        "cost": {
                            "required": False,
                            "type": "int"
                        },
                        "dead_interval": {
                            "required": False,
                            "type": "int"
                        },
                        "hello_interval": {
                            "required": False,
                            "type": "int"
                        },
                        "interface": {
                            "required": False,
                            "type": "str"
                        },
                        "mtu": {
                            "required": False,
                            "type": "int"
                        },
                        "mtu_ignore": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "name": {
                            "required": True,
                            "type": "str"
                        },
                        "neighbor": {
                            "required": False,
                            "type": "list",
                            "options": {
                                "cost": {
                                    "required": False,
                                    "type": "int"
                                },
                                "ip6": {
                                    "required": True,
                                    "type": "str"
                                },
                                "poll_interval": {
                                    "required": False,
                                    "type": "int"
                                },
                                "priority": {
                                    "required": False,
                                    "type": "int"
                                }
                            }
                        },
                        "network_type": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices": [
                                "broadcast", "point-to-point", "non-broadcast",
                                "point-to-multipoint",
                                "point-to-multipoint-non-broadcast"
                            ]
                        },
                        "priority": {
                            "required": False,
                            "type": "int"
                        },
                        "retransmit_interval": {
                            "required": False,
                            "type": "int"
                        },
                        "status": {
                            "required": False,
                            "type": "str",
                            "choices": ["disable", "enable"]
                        },
                        "transmit_delay": {
                            "required": False,
                            "type": "int"
                        }
                    }
                },
                "passive_interface": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "redistribute": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "metric": {
                            "required": False,
                            "type": "int"
                        },
                        "metric_type": {
                            "required": False,
                            "type": "str",
                            "choices": ["1", "2"]
                        },
                        "name": {
                            "required": True,
                            "type": "str"
                        },
                        "routemap": {
                            "required": False,
                            "type": "str"
                        },
                        "status": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        }
                    }
                },
                "router_id": {
                    "required": False,
                    "type": "str"
                },
                "spf_timers": {
                    "required": False,
                    "type": "str"
                },
                "summary_address": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "advertise": {
                            "required": False,
                            "type": "str",
                            "choices": ["disable", "enable"]
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "prefix6": {
                            "required": False,
                            "type": "str"
                        },
                        "tag": {
                            "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_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"]
        },
        "system_vdom_property": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "custom_service": {
                    "required": False,
                    "type": "str"
                },
                "description": {
                    "required": False,
                    "type": "str"
                },
                "dialup_tunnel": {
                    "required": False,
                    "type": "str"
                },
                "firewall_address": {
                    "required": False,
                    "type": "str"
                },
                "firewall_addrgrp": {
                    "required": False,
                    "type": "str"
                },
                "firewall_policy": {
                    "required": False,
                    "type": "str"
                },
                "ipsec_phase1": {
                    "required": False,
                    "type": "str"
                },
                "ipsec_phase1_interface": {
                    "required": False,
                    "type": "str"
                },
                "ipsec_phase2": {
                    "required": False,
                    "type": "str"
                },
                "ipsec_phase2_interface": {
                    "required": False,
                    "type": "str"
                },
                "log_disk_quota": {
                    "required": False,
                    "type": "str"
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "onetime_schedule": {
                    "required": False,
                    "type": "str"
                },
                "proxy": {
                    "required": False,
                    "type": "str"
                },
                "recurring_schedule": {
                    "required": False,
                    "type": "str"
                },
                "service_group": {
                    "required": False,
                    "type": "str"
                },
                "session": {
                    "required": False,
                    "type": "str"
                },
                "snmp_index": {
                    "required": False,
                    "type": "int"
                },
                "sslvpn": {
                    "required": False,
                    "type": "str"
                },
                "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_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_disk_setting": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "diskfull": {"required": False, "type": "str",
                             "choices": ["overwrite", "nolog"]},
                "dlp_archive_quota": {"required": False, "type": "int"},
                "full_final_warning_threshold": {"required": False, "type": "int"},
                "full_first_warning_threshold": {"required": False, "type": "int"},
                "full_second_warning_threshold": {"required": False, "type": "int"},
                "ips_archive": {"required": False, "type": "str",
                                "choices": ["enable", "disable"]},
                "log_quota": {"required": False, "type": "int"},
                "max_log_file_size": {"required": False, "type": "int"},
                "max_policy_packet_capture_size": {"required": False, "type": "int"},
                "maximum_log_age": {"required": False, "type": "int"},
                "report_quota": {"required": False, "type": "int"},
                "roll_day": {"required": False, "type": "str",
                             "choices": ["sunday", "monday", "tuesday",
                                         "wednesday", "thursday", "friday",
                                         "saturday"]},
                "roll_schedule": {"required": False, "type": "str",
                                  "choices": ["daily", "weekly"]},
                "roll_time": {"required": False, "type": "str"},
                "source_ip": {"required": False, "type": "str"},
                "status": {"required": False, "type": "str",
                           "choices": ["enable", "disable"]},
                "upload": {"required": False, "type": "str",
                           "choices": ["enable", "disable"]},
                "upload_delete_files": {"required": False, "type": "str",
                                        "choices": ["enable", "disable"]},
                "upload_destination": {"required": False, "type": "str",
                                       "choices": ["ftp-server"]},
                "upload_ssl_conn": {"required": False, "type": "str",
                                    "choices": ["default", "high", "low",
                                                "disable"]},
                "uploaddir": {"required": False, "type": "str"},
                "uploadip": {"required": False, "type": "str"},
                "uploadpass": {"required": False, "type": "str"},
                "uploadport": {"required": False, "type": "int"},
                "uploadsched": {"required": False, "type": "str",
                                "choices": ["disable", "enable"]},
                "uploadtime": {"required": False, "type": "str"},
                "uploadtype": {"required": False, "type": "str",
                               "choices": ["traffic", "event", "virus",
                                           "webfilter", "IPS", "spamfilter",
                                           "dlp-archive", "anomaly", "voip",
                                           "dlp", "app-ctrl", "waf",
                                           "netscan", "gtp", "dns"]},
                "uploaduser": {"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_disk(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_disk(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_crl": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "crl": {
                    "required": False,
                    "type": "str"
                },
                "http_url": {
                    "required": False,
                    "type": "str"
                },
                "last_updated": {
                    "required": False,
                    "type": "int"
                },
                "ldap_password": {
                    "required": False,
                    "type": "str"
                },
                "ldap_server": {
                    "required": False,
                    "type": "str"
                },
                "ldap_username": {
                    "required": False,
                    "type": "str"
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "range": {
                    "required": False,
                    "type": "str",
                    "choices": ["global", "vdom"]
                },
                "scep_cert": {
                    "required": False,
                    "type": "str"
                },
                "scep_url": {
                    "required": False,
                    "type": "str"
                },
                "source": {
                    "required": False,
                    "type": "str",
                    "choices": ["factory", "user", "bundle"]
                },
                "source_ip": {
                    "required": False,
                    "type": "str"
                },
                "update_interval": {
                    "required": False,
                    "type": "int"
                },
                "update_vdom": {
                    "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)