コード例 #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},
        "state": {"required": False, "type": "str",
                  "choices": ["present", "absent"]},
        "firewall_vipgrp64": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "state": {"required": False, "type": "str",
                          "choices": ["present", "absent"]},
                "color": {"required": False, "type": "int"},
                "comments": {"required": False, "type": "str"},
                "member": {"required": False, "type": "list",
                           "options": {
                               "name": {"required": True, "type": "str"}
                           }},
                "name": {"required": True, "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)
コード例 #2
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)
コード例 #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_console": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "baudrate": {"required": False, "type": "str",
                             "choices": ["9600", "19200", "38400",
                                         "57600", "115200"]},
                "login": {"required": False, "type": "str",
                          "choices": ["enable", "disable"]},
                "mode": {"required": False, "type": "str",
                         "choices": ["batch", "line"]},
                "output": {"required": False, "type": "str",
                           "choices": ["standard", "more"]}

            }
        }
    }

    module = AnsibleModule(argument_spec=fields,
                           supports_check_mode=False)

    # legacy_mode refers to using fortiosapi instead of HTTPAPI
    legacy_mode = 'host' in module.params and module.params['host'] is not None and \
                  'username' in module.params and module.params['username'] is not None and \
                  'password' in module.params and module.params['password'] is not None

    if not legacy_mode:
        if module._socket_path:
            connection = Connection(module._socket_path)
            fos = FortiOSHandler(connection)

            is_error, has_changed, result = fortios_system(module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

        login(module.params, fos)
        is_error, has_changed, result = fortios_system(module.params, fos)
        fos.logout()

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #4
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},
        "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)
コード例 #5
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},
        "antivirus_settings": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "default_db": {"required": False, "type": "str",
                               "choices": ["normal", "extended", "extreme"]},
                "grayware": {"required": False, "type": "str",
                             "choices": ["enable", "disable"]},
                "override_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_antivirus(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_antivirus(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)
コード例 #6
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_fortianalyzer2_setting": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "__change_ip": {
                    "required": False,
                    "type": "int"
                },
                "certificate": {
                    "required": False,
                    "type": "str"
                },
                "conn_timeout": {
                    "required": False,
                    "type": "int"
                },
                "enc_algorithm": {
                    "required": False,
                    "type": "str",
                    "choices": ["high-medium", "high", "low"]
                },
                "faz_type": {
                    "required": False,
                    "type": "int"
                },
                "hmac_algorithm": {
                    "required": False,
                    "type": "str",
                    "choices": ["sha256", "sha1"]
                },
                "ips_archive": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "mgmt_name": {
                    "required": False,
                    "type": "str"
                },
                "monitor_failure_retry_period": {
                    "required": False,
                    "type": "int"
                },
                "monitor_keepalive_period": {
                    "required": False,
                    "type": "int"
                },
                "reliable": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "server": {
                    "required": False,
                    "type": "str"
                },
                "source_ip": {
                    "required": False,
                    "type": "str"
                },
                "ssl_min_proto_version": {
                    "required": False,
                    "type": "str",
                    "choices":
                    ["default", "SSLv3", "TLSv1", "TLSv1-1", "TLSv1-2"]
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "upload_day": {
                    "required": False,
                    "type": "str"
                },
                "upload_interval": {
                    "required": False,
                    "type": "str",
                    "choices": ["daily", "weekly", "monthly"]
                },
                "upload_option": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices":
                    ["store-and-upload", "realtime", "1-minute", "5-minute"]
                },
                "upload_time": {
                    "required": False,
                    "type": "str"
                }
            }
        }
    }

    module = AnsibleModule(argument_spec=fields, supports_check_mode=False)

    # legacy_mode refers to using fortiosapi instead of HTTPAPI
    legacy_mode = 'host' in module.params and module.params['host'] is not None and \
                  'username' in module.params and module.params['username'] is not None and \
                  'password' in module.params and module.params['password'] is not None

    if not legacy_mode:
        if module._socket_path:
            connection = Connection(module._socket_path)
            fos = FortiOSHandler(connection)

            is_error, has_changed, result = fortios_log_fortianalyzer2(
                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_fortianalyzer2(
            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
        },
        "state": {
            "required": False,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "firewall_vip64": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "arp_reply": {
                    "required": False,
                    "type": "str",
                    "choices": ["disable", "enable"]
                },
                "color": {
                    "required": False,
                    "type": "int"
                },
                "comment": {
                    "required": False,
                    "type": "str"
                },
                "extip": {
                    "required": False,
                    "type": "str"
                },
                "extport": {
                    "required": False,
                    "type": "str"
                },
                "id": {
                    "required": False,
                    "type": "int"
                },
                "ldb_method": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "static", "round-robin", "weighted", "least-session",
                        "least-rtt", "first-alive"
                    ]
                },
                "mappedip": {
                    "required": False,
                    "type": "str"
                },
                "mappedport": {
                    "required": False,
                    "type": "str"
                },
                "monitor": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "portforward": {
                    "required": False,
                    "type": "str",
                    "choices": ["disable", "enable"]
                },
                "protocol": {
                    "required": False,
                    "type": "str",
                    "choices": ["tcp", "udp"]
                },
                "realservers": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "client_ip": {
                            "required": False,
                            "type": "str"
                        },
                        "healthcheck": {
                            "required": False,
                            "type": "str",
                            "choices": ["disable", "enable", "vip"]
                        },
                        "holddown_interval": {
                            "required": False,
                            "type": "int"
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "ip": {
                            "required": False,
                            "type": "str"
                        },
                        "max_connections": {
                            "required": False,
                            "type": "int"
                        },
                        "monitor": {
                            "required": False,
                            "type": "str"
                        },
                        "port": {
                            "required": False,
                            "type": "int"
                        },
                        "status": {
                            "required": False,
                            "type": "str",
                            "choices": ["active", "standby", "disable"]
                        },
                        "weight": {
                            "required": False,
                            "type": "int"
                        }
                    }
                },
                "server_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["http", "tcp", "udp", "ip"]
                },
                "src_filter": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "range": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "type": {
                    "required": False,
                    "type": "str",
                    "choices": ["static-nat", "server-load-balance"]
                },
                "uuid": {
                    "required": False,
                    "type": "str"
                }
            }
        }
    }

    module = AnsibleModule(argument_spec=fields, supports_check_mode=False)

    # legacy_mode refers to using fortiosapi instead of HTTPAPI
    legacy_mode = 'host' in module.params and module.params['host'] is not None and \
                  'username' in module.params and module.params['username'] is not None and \
                  'password' in module.params and module.params['password'] is not None

    if not legacy_mode:
        if module._socket_path:
            connection = Connection(module._socket_path)
            fos = FortiOSHandler(connection)

            is_error, has_changed, result = fortios_firewall(
                module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

        login(module.params, fos)
        is_error, has_changed, result = fortios_firewall(module.params, fos)
        fos.logout()

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #8
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"]},
        "wanopt_profile": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "state": {"required": False, "type": "str",
                          "choices": ["present", "absent"]},
                "auth_group": {"required": False, "type": "str"},
                "cifs": {"required": False, "type": "dict",
                         "options": {
                             "byte_caching": {"required": False, "type": "str",
                                              "choices": ["enable", "disable"]},
                             "log_traffic": {"required": False, "type": "str",
                                             "choices": ["enable", "disable"]},
                             "port": {"required": False, "type": "int"},
                             "prefer_chunking": {"required": False, "type": "str",
                                                 "choices": ["dynamic", "fix"]},
                             "secure_tunnel": {"required": False, "type": "str",
                                               "choices": ["enable", "disable"]},
                             "status": {"required": False, "type": "str",
                                        "choices": ["enable", "disable"]},
                             "tunnel_sharing": {"required": False, "type": "str",
                                                "choices": ["private", "shared", "express-shared"]}
                         }},
                "comments": {"required": False, "type": "str"},
                "ftp": {"required": False, "type": "dict",
                        "options": {
                            "byte_caching": {"required": False, "type": "str",
                                             "choices": ["enable", "disable"]},
                            "log_traffic": {"required": False, "type": "str",
                                            "choices": ["enable", "disable"]},
                            "port": {"required": False, "type": "int"},
                            "prefer_chunking": {"required": False, "type": "str",
                                                "choices": ["dynamic", "fix"]},
                            "secure_tunnel": {"required": False, "type": "str",
                                              "choices": ["enable", "disable"]},
                            "status": {"required": False, "type": "str",
                                       "choices": ["enable", "disable"]},
                            "tunnel_sharing": {"required": False, "type": "str",
                                               "choices": ["private", "shared", "express-shared"]}
                        }},
                "http": {"required": False, "type": "dict",
                         "options": {
                             "byte_caching": {"required": False, "type": "str",
                                              "choices": ["enable", "disable"]},
                             "log_traffic": {"required": False, "type": "str",
                                             "choices": ["enable", "disable"]},
                             "port": {"required": False, "type": "int"},
                             "prefer_chunking": {"required": False, "type": "str",
                                                 "choices": ["dynamic", "fix"]},
                             "secure_tunnel": {"required": False, "type": "str",
                                               "choices": ["enable", "disable"]},
                             "ssl": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                             "ssl_port": {"required": False, "type": "int"},
                             "status": {"required": False, "type": "str",
                                        "choices": ["enable", "disable"]},
                             "tunnel_non_http": {"required": False, "type": "str",
                                                 "choices": ["enable", "disable"]},
                             "tunnel_sharing": {"required": False, "type": "str",
                                                "choices": ["private", "shared", "express-shared"]},
                             "unknown_http_version": {"required": False, "type": "str",
                                                      "choices": ["reject", "tunnel", "best-effort"]}
                         }},
                "mapi": {"required": False, "type": "dict",
                         "options": {
                             "byte_caching": {"required": False, "type": "str",
                                              "choices": ["enable", "disable"]},
                             "log_traffic": {"required": False, "type": "str",
                                             "choices": ["enable", "disable"]},
                             "port": {"required": False, "type": "int"},
                             "secure_tunnel": {"required": False, "type": "str",
                                               "choices": ["enable", "disable"]},
                             "status": {"required": False, "type": "str",
                                        "choices": ["enable", "disable"]},
                             "tunnel_sharing": {"required": False, "type": "str",
                                                "choices": ["private", "shared", "express-shared"]}
                         }},
                "name": {"required": True, "type": "str"},
                "tcp": {"required": False, "type": "dict",
                        "options": {
                            "byte_caching": {"required": False, "type": "str",
                                             "choices": ["enable", "disable"]},
                            "byte_caching_opt": {"required": False, "type": "str",
                                                 "choices": ["mem-only", "mem-disk"]},
                            "log_traffic": {"required": False, "type": "str",
                                            "choices": ["enable", "disable"]},
                            "port": {"required": False, "type": "str"},
                            "secure_tunnel": {"required": False, "type": "str",
                                              "choices": ["enable", "disable"]},
                            "ssl": {"required": False, "type": "str",
                                    "choices": ["enable", "disable"]},
                            "ssl_port": {"required": False, "type": "int"},
                            "status": {"required": False, "type": "str",
                                       "choices": ["enable", "disable"]},
                            "tunnel_sharing": {"required": False, "type": "str",
                                               "choices": ["private", "shared", "express-shared"]}
                        }},
                "transparent": {"required": False, "type": "str",
                                "choices": ["enable", "disable"]}

            }
        }
    }

    module = AnsibleModule(argument_spec=fields,
                           supports_check_mode=False)

    # legacy_mode refers to using fortiosapi instead of HTTPAPI
    legacy_mode = 'host' in module.params and module.params['host'] is not None and \
                  'username' in module.params and module.params['username'] is not None and \
                  'password' in module.params and module.params['password'] is not None

    if not legacy_mode:
        if module._socket_path:
            connection = Connection(module._socket_path)
            fos = FortiOSHandler(connection)

            is_error, has_changed, result = fortios_wanopt(module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

        login(module.params, fos)
        is_error, has_changed, result = fortios_wanopt(module.params, fos)
        fos.logout()

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "wireless_controller_inter_controller": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "fast_failover_max": {
                    "required": False,
                    "type": "int"
                },
                "fast_failover_wait": {
                    "required": False,
                    "type": "int"
                },
                "inter_controller_key": {
                    "required": False,
                    "type": "str"
                },
                "inter_controller_mode": {
                    "required": False,
                    "type": "str",
                    "choices": ["disable", "l2-roaming", "1+1"]
                },
                "inter_controller_peer": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "peer_ip": {
                            "required": False,
                            "type": "str"
                        },
                        "peer_port": {
                            "required": False,
                            "type": "int"
                        },
                        "peer_priority": {
                            "required": False,
                            "type": "str",
                            "choices": ["primary", "secondary"]
                        }
                    }
                },
                "inter_controller_pri": {
                    "required": False,
                    "type": "str",
                    "choices": ["primary", "secondary"]
                }
            }
        }
    }

    module = AnsibleModule(argument_spec=fields, supports_check_mode=False)

    # legacy_mode refers to using fortiosapi instead of HTTPAPI
    legacy_mode = 'host' in module.params and module.params['host'] is not None and \
                  'username' in module.params and module.params['username'] is not None and \
                  'password' in module.params and module.params['password'] is not None

    if not legacy_mode:
        if module._socket_path:
            connection = Connection(module._socket_path)
            fos = FortiOSHandler(connection)

            is_error, has_changed, result = fortios_wireless_controller(
                module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

        login(module.params, fos)
        is_error, has_changed, result = fortios_wireless_controller(
            module.params, fos)
        fos.logout()

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #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},
        "web_proxy_global": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "fast_policy_match": {"required": False, "type": "str",
                                      "choices": ["enable", "disable"]},
                "forward_proxy_auth": {"required": False, "type": "str",
                                       "choices": ["enable", "disable"]},
                "forward_server_affinity_timeout": {"required": False, "type": "int"},
                "learn_client_ip": {"required": False, "type": "str",
                                    "choices": ["enable", "disable"]},
                "learn_client_ip_from_header": {"required": False, "type": "str",
                                                "choices": ["true-client-ip", "x-real-ip", "x-forwarded-for"]},
                "learn_client_ip_srcaddr": {"required": False, "type": "list",
                                            "options": {
                                                "name": {"required": True, "type": "str"}
                                            }},
                "learn_client_ip_srcaddr6": {"required": False, "type": "list",
                                             "options": {
                                                 "name": {"required": True, "type": "str"}
                                             }},
                "max_message_length": {"required": False, "type": "int"},
                "max_request_length": {"required": False, "type": "int"},
                "max_waf_body_cache_length": {"required": False, "type": "int"},
                "proxy_fqdn": {"required": False, "type": "str"},
                "strict_web_check": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "tunnel_non_http": {"required": False, "type": "str",
                                    "choices": ["enable", "disable"]},
                "unknown_http_version": {"required": False, "type": "str",
                                         "choices": ["reject", "tunnel", "best-effort"]},
                "webproxy_profile": {"required": False, "type": "str"}

            }
        }
    }

    module = AnsibleModule(argument_spec=fields,
                           supports_check_mode=False)

    # legacy_mode refers to using fortiosapi instead of HTTPAPI
    legacy_mode = 'host' in module.params and module.params['host'] is not None and \
                  'username' in module.params and module.params['username'] is not None and \
                  'password' in module.params and module.params['password'] is not None

    if not legacy_mode:
        if module._socket_path:
            connection = Connection(module._socket_path)
            fos = FortiOSHandler(connection)

            is_error, has_changed, result = fortios_web_proxy(module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

        login(module.params, fos)
        is_error, has_changed, result = fortios_web_proxy(module.params, fos)
        fos.logout()

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #11
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_address6": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "cache_ttl": {
                    "required": False,
                    "type": "int"
                },
                "color": {
                    "required": False,
                    "type": "int"
                },
                "comment": {
                    "required": False,
                    "type": "str"
                },
                "end_ip": {
                    "required": False,
                    "type": "str"
                },
                "fqdn": {
                    "required": False,
                    "type": "str"
                },
                "host": {
                    "required": False,
                    "type": "str"
                },
                "host_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["any", "specific"]
                },
                "ip6": {
                    "required": False,
                    "type": "str"
                },
                "list": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "ip": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "obj_id": {
                    "required": False,
                    "type": "str"
                },
                "sdn": {
                    "required": False,
                    "type": "str",
                    "choices": ["nsx"]
                },
                "start_ip": {
                    "required": False,
                    "type": "str"
                },
                "subnet_segment": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        },
                        "type": {
                            "required": False,
                            "type": "str",
                            "choices": ["any", "specific"]
                        },
                        "value": {
                            "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"
                                }
                            }
                        }
                    }
                },
                "template": {
                    "required": False,
                    "type": "str"
                },
                "type": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices":
                    ["ipprefix", "iprange", "fqdn", "dynamic", "template"]
                },
                "uuid": {
                    "required": False,
                    "type": "str"
                },
                "visibility": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                }
            }
        }
    }

    module = AnsibleModule(argument_spec=fields, supports_check_mode=False)

    # legacy_mode refers to using fortiosapi instead of HTTPAPI
    legacy_mode = 'host' in module.params and module.params['host'] is not None and \
                  'username' in module.params and module.params['username'] is not None and \
                  'password' in module.params and module.params['password'] is not None

    if not legacy_mode:
        if module._socket_path:
            connection = Connection(module._socket_path)
            fos = FortiOSHandler(connection)

            is_error, has_changed, result = fortios_firewall(
                module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

        login(module.params, fos)
        is_error, has_changed, result = fortios_firewall(module.params, fos)
        fos.logout()

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #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
        },
        "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)
コード例 #13
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"]
        },
        "switch_controller_lldp_profile": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "802.1_tlvs": {
                    "required": False,
                    "type": "str",
                    "choices": ["port-vlan-id"]
                },
                "802.3_tlvs": {
                    "required": False,
                    "type": "str",
                    "choices": ["max-frame-size"]
                },
                "auto_isl": {
                    "required": False,
                    "type": "str",
                    "choices": ["disable", "enable"]
                },
                "auto_isl_hello_timer": {
                    "required": False,
                    "type": "int"
                },
                "auto_isl_port_group": {
                    "required": False,
                    "type": "int"
                },
                "auto_isl_receive_timeout": {
                    "required": False,
                    "type": "int"
                },
                "custom_tlvs": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "information_string": {
                            "required": False,
                            "type": "str"
                        },
                        "name": {
                            "required": True,
                            "type": "str"
                        },
                        "oui": {
                            "required": False,
                            "type": "str"
                        },
                        "subtype": {
                            "required": False,
                            "type": "int"
                        }
                    }
                },
                "med_network_policy": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "dscp": {
                            "required": False,
                            "type": "int"
                        },
                        "name": {
                            "required": True,
                            "type": "str"
                        },
                        "priority": {
                            "required": False,
                            "type": "int"
                        },
                        "status": {
                            "required": False,
                            "type": "str",
                            "choices": ["disable", "enable"]
                        },
                        "vlan": {
                            "required": False,
                            "type": "int"
                        }
                    }
                },
                "med_tlvs": {
                    "required": False,
                    "type": "str",
                    "choices": ["inventory-management", "network-policy"]
                },
                "name": {
                    "required": True,
                    "type": "str"
                }
            }
        }
    }

    module = AnsibleModule(argument_spec=fields, supports_check_mode=False)

    # legacy_mode refers to using fortiosapi instead of HTTPAPI
    legacy_mode = 'host' in module.params and module.params['host'] is not None and \
                  'username' in module.params and module.params['username'] is not None and \
                  'password' in module.params and module.params['password'] is not None

    if not legacy_mode:
        if module._socket_path:
            connection = Connection(module._socket_path)
            fos = FortiOSHandler(connection)

            is_error, has_changed, result = fortios_switch_controller(
                module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

        login(module.params, fos)
        is_error, has_changed, result = fortios_switch_controller(
            module.params, fos)
        fos.logout()

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #14
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": True,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "system_session_helper": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "id": {
                    "required": True,
                    "type": "int"
                },
                "name": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "ftp", "tftp", "ras", "h323", "tns", "mms", "sip",
                        "pptp", "rtsp", "dns-udp", "dns-tcp", "pmap", "rsh",
                        "dcerpc", "mgcp", "gtp-c", "gtp-u", "gtp-b"
                    ]
                },
                "port": {
                    "required": False,
                    "type": "int"
                },
                "protocol": {
                    "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)
コード例 #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
        },
        "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)
コード例 #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
        },
        "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)
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"]
        },
        "wanopt_content_delivery_network_rule": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "category": {
                    "required": False,
                    "type": "str",
                    "choices": ["vcache", "youtube"]
                },
                "comment": {
                    "required": False,
                    "type": "str"
                },
                "host_domain_name_suffix": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "request_cache_control": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "response_cache_control": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "response_expires": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "rules": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "content_id": {
                            "required": False,
                            "type": "dict",
                            "options": {
                                "end_direction": {
                                    "required": False,
                                    "type": "str",
                                    "choices": ["forward", "backward"]
                                },
                                "end_skip": {
                                    "required": False,
                                    "type": "int"
                                },
                                "end_str": {
                                    "required": False,
                                    "type": "str"
                                },
                                "range_str": {
                                    "required": False,
                                    "type": "str"
                                },
                                "start_direction": {
                                    "required": False,
                                    "type": "str",
                                    "choices": ["forward", "backward"]
                                },
                                "start_skip": {
                                    "required": False,
                                    "type": "int"
                                },
                                "start_str": {
                                    "required": False,
                                    "type": "str"
                                },
                                "target": {
                                    "required":
                                    False,
                                    "type":
                                    "str",
                                    "choices": [
                                        "path", "parameter", "referrer",
                                        "youtube-map", "youtube-id",
                                        "youku-id", "hls-manifest",
                                        "dash-manifest", "hls-fragment",
                                        "dash-fragment"
                                    ]
                                }
                            }
                        },
                        "match_entries": {
                            "required": False,
                            "type": "list",
                            "options": {
                                "id": {
                                    "required": True,
                                    "type": "int"
                                },
                                "pattern": {
                                    "required": False,
                                    "type": "list",
                                    "options": {
                                        "string": {
                                            "required": True,
                                            "type": "str"
                                        }
                                    }
                                },
                                "target": {
                                    "required":
                                    False,
                                    "type":
                                    "str",
                                    "choices": [
                                        "path", "parameter", "referrer",
                                        "youtube-map", "youtube-id", "youku-id"
                                    ]
                                }
                            }
                        },
                        "match_mode": {
                            "required": False,
                            "type": "str",
                            "choices": ["all", "any"]
                        },
                        "name": {
                            "required": True,
                            "type": "str"
                        },
                        "skip_entries": {
                            "required": False,
                            "type": "list",
                            "options": {
                                "id": {
                                    "required": True,
                                    "type": "int"
                                },
                                "pattern": {
                                    "required": False,
                                    "type": "list",
                                    "options": {
                                        "string": {
                                            "required": True,
                                            "type": "str"
                                        }
                                    }
                                },
                                "target": {
                                    "required":
                                    False,
                                    "type":
                                    "str",
                                    "choices": [
                                        "path", "parameter", "referrer",
                                        "youtube-map", "youtube-id", "youku-id"
                                    ]
                                }
                            }
                        },
                        "skip_rule_mode": {
                            "required": False,
                            "type": "str",
                            "choices": ["all", "any"]
                        }
                    }
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "text_response_vcache": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "updateserver": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                }
            }
        }
    }

    module = AnsibleModule(argument_spec=fields, supports_check_mode=False)

    # legacy_mode refers to using fortiosapi instead of HTTPAPI
    legacy_mode = 'host' in module.params and module.params['host'] is not None and \
                  'username' in module.params and module.params['username'] is not None and \
                  'password' in module.params and module.params['password'] is not None

    if not legacy_mode:
        if module._socket_path:
            connection = Connection(module._socket_path)
            fos = FortiOSHandler(connection)

            is_error, has_changed, result = fortios_wanopt(module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

        login(module.params, fos)
        is_error, has_changed, result = fortios_wanopt(module.params, fos)
        fos.logout()

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #18
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"]
        },
        "router_static": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "bfd": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "blackhole": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "comment": {
                    "required": False,
                    "type": "str"
                },
                "device": {
                    "required": False,
                    "type": "str"
                },
                "distance": {
                    "required": False,
                    "type": "int"
                },
                "dst": {
                    "required": False,
                    "type": "str"
                },
                "dstaddr": {
                    "required": False,
                    "type": "str"
                },
                "dynamic_gateway": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "gateway": {
                    "required": False,
                    "type": "str"
                },
                "internet_service": {
                    "required": False,
                    "type": "int"
                },
                "internet_service_custom": {
                    "required": False,
                    "type": "str"
                },
                "link_monitor_exempt": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "priority": {
                    "required": False,
                    "type": "int"
                },
                "seq_num": {
                    "required": False,
                    "type": "int"
                },
                "src": {
                    "required": False,
                    "type": "str"
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "virtual_wan_link": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "vrf": {
                    "required": False,
                    "type": "int"
                },
                "weight": {
                    "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)
コード例 #19
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_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)
コード例 #20
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"]},
        "webfilter_profile": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "state": {"required": False, "type": "str",
                          "choices": ["present", "absent"]},
                "comment": {"required": False, "type": "str"},
                "extended_log": {"required": False, "type": "str",
                                 "choices": ["enable", "disable"]},
                "ftgd_wf": {"required": False, "type": "dict",
                            "options": {
                                "exempt_quota": {"required": False, "type": "str"},
                                "filters": {"required": False, "type": "list",
                                            "options": {
                                                "action": {"required": False, "type": "str",
                                                           "choices": ["block", "authenticate", "monitor",
                                                                       "warning"]},
                                                "auth_usr_grp": {"required": False, "type": "str",
                                                                 "options": {
                                                                     "name": {"required": True, "type": "str"}
                                                                 }},
                                                "category": {"required": False, "type": "int"},
                                                "id": {"required": True, "type": "int"},
                                                "log": {"required": False, "type": "str",
                                                        "choices": ["enable", "disable"]},
                                                "override_replacemsg": {"required": False, "type": "str"},
                                                "warn_duration": {"required": False, "type": "str"},
                                                "warning_duration_type": {"required": False, "type": "str",
                                                                          "choices": ["session", "timeout"]},
                                                "warning_prompt": {"required": False, "type": "str",
                                                                   "choices": ["per-domain", "per-category"]}
                                            }},
                                "max_quota_timeout": {"required": False, "type": "int"},
                                "options": {"required": False, "type": "str",
                                            "choices": ["error-allow", "rate-server-ip", "connect-request-bypass",
                                                        "ftgd-disable"]},
                                "ovrd": {"required": False, "type": "str"},
                                "quota": {"required": False, "type": "list",
                                          "options": {
                                              "category": {"required": False, "type": "str"},
                                              "duration": {"required": False, "type": "str"},
                                              "id": {"required": True, "type": "int"},
                                              "override_replacemsg": {"required": False, "type": "str"},
                                              "type": {"required": False, "type": "str",
                                                       "choices": ["time", "traffic"]},
                                              "unit": {"required": False, "type": "str",
                                                       "choices": ["B", "KB", "MB",
                                                                   "GB"]},
                                              "value": {"required": False, "type": "int"}
                                          }},
                                "rate_crl_urls": {"required": False, "type": "str",
                                                  "choices": ["disable", "enable"]},
                                "rate_css_urls": {"required": False, "type": "str",
                                                  "choices": ["disable", "enable"]},
                                "rate_image_urls": {"required": False, "type": "str",
                                                    "choices": ["disable", "enable"]},
                                "rate_javascript_urls": {"required": False, "type": "str",
                                                         "choices": ["disable", "enable"]}
                            }},
                "https_replacemsg": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "inspection_mode": {"required": False, "type": "str",
                                    "choices": ["proxy", "flow-based"]},
                "log_all_url": {"required": False, "type": "str",
                                "choices": ["enable", "disable"]},
                "name": {"required": True, "type": "str"},
                "options": {"required": False, "type": "str",
                            "choices": ["activexfilter", "cookiefilter", "javafilter",
                                        "block-invalid-url", "jscript", "js",
                                        "vbs", "unknown", "intrinsic",
                                        "wf-referer", "wf-cookie", "per-user-bwl"]},
                "override": {"required": False, "type": "dict",
                             "options": {
                                 "ovrd_cookie": {"required": False, "type": "str",
                                                 "choices": ["allow", "deny"]},
                                 "ovrd_dur": {"required": False, "type": "str"},
                                 "ovrd_dur_mode": {"required": False, "type": "str",
                                                   "choices": ["constant", "ask"]},
                                 "ovrd_scope": {"required": False, "type": "str",
                                                "choices": ["user", "user-group", "ip",
                                                            "browser", "ask"]},
                                 "ovrd_user_group": {"required": False, "type": "str",
                                                     "options": {
                                                         "name": {"required": True, "type": "str"}
                                                     }},
                                 "profile": {"required": False, "type": "list",
                                             "options": {
                                                 "name": {"required": True, "type": "str"}
                                             }},
                                 "profile_attribute": {"required": False, "type": "str",
                                                       "choices": ["User-Name", "NAS-IP-Address", "Framed-IP-Address",
                                                                   "Framed-IP-Netmask", "Filter-Id", "Login-IP-Host",
                                                                   "Reply-Message", "Callback-Number", "Callback-Id",
                                                                   "Framed-Route", "Framed-IPX-Network", "Class",
                                                                   "Called-Station-Id", "Calling-Station-Id", "NAS-Identifier",
                                                                   "Proxy-State", "Login-LAT-Service", "Login-LAT-Node",
                                                                   "Login-LAT-Group", "Framed-AppleTalk-Zone", "Acct-Session-Id",
                                                                   "Acct-Multi-Session-Id"]},
                                 "profile_type": {"required": False, "type": "str",
                                                  "choices": ["list", "radius"]}
                             }},
                "ovrd_perm": {"required": False, "type": "str",
                              "choices": ["bannedword-override", "urlfilter-override", "fortiguard-wf-override",
                                          "contenttype-check-override"]},
                "post_action": {"required": False, "type": "str",
                                "choices": ["normal", "block"]},
                "replacemsg_group": {"required": False, "type": "str"},
                "web": {"required": False, "type": "dict",
                        "options": {
                            "blacklist": {"required": False, "type": "str",
                                          "choices": ["enable", "disable"]},
                            "bword_table": {"required": False, "type": "int"},
                            "bword_threshold": {"required": False, "type": "int"},
                            "content_header_list": {"required": False, "type": "int"},
                            "keyword_match": {"required": False, "type": "str",
                                              "options": {
                                                  "pattern": {"required": True, "type": "str"}
                                              }},
                            "log_search": {"required": False, "type": "str",
                                           "choices": ["enable", "disable"]},
                            "safe_search": {"required": False, "type": "str",
                                            "choices": ["url", "header"]},
                            "urlfilter_table": {"required": False, "type": "int"},
                            "whitelist": {"required": False, "type": "str",
                                          "choices": ["exempt-av", "exempt-webcontent", "exempt-activex-java-cookie",
                                                      "exempt-dlp", "exempt-rangeblock", "extended-log-others"]},
                            "youtube_restrict": {"required": False, "type": "str",
                                                 "choices": ["none", "strict", "moderate"]}
                        }},
                "web_content_log": {"required": False, "type": "str",
                                    "choices": ["enable", "disable"]},
                "web_extended_all_action_log": {"required": False, "type": "str",
                                                "choices": ["enable", "disable"]},
                "web_filter_activex_log": {"required": False, "type": "str",
                                           "choices": ["enable", "disable"]},
                "web_filter_applet_log": {"required": False, "type": "str",
                                          "choices": ["enable", "disable"]},
                "web_filter_command_block_log": {"required": False, "type": "str",
                                                 "choices": ["enable", "disable"]},
                "web_filter_cookie_log": {"required": False, "type": "str",
                                          "choices": ["enable", "disable"]},
                "web_filter_cookie_removal_log": {"required": False, "type": "str",
                                                  "choices": ["enable", "disable"]},
                "web_filter_js_log": {"required": False, "type": "str",
                                      "choices": ["enable", "disable"]},
                "web_filter_jscript_log": {"required": False, "type": "str",
                                           "choices": ["enable", "disable"]},
                "web_filter_referer_log": {"required": False, "type": "str",
                                           "choices": ["enable", "disable"]},
                "web_filter_unknown_log": {"required": False, "type": "str",
                                           "choices": ["enable", "disable"]},
                "web_filter_vbs_log": {"required": False, "type": "str",
                                       "choices": ["enable", "disable"]},
                "web_ftgd_err_log": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "web_ftgd_quota_usage": {"required": False, "type": "str",
                                         "choices": ["enable", "disable"]},
                "web_invalid_domain_log": {"required": False, "type": "str",
                                           "choices": ["enable", "disable"]},
                "web_url_log": {"required": False, "type": "str",
                                "choices": ["enable", "disable"]},
                "wisp": {"required": False, "type": "str",
                         "choices": ["enable", "disable"]},
                "wisp_algorithm": {"required": False, "type": "str",
                                   "choices": ["primary-secondary", "round-robin", "auto-learning"]},
                "wisp_servers": {"required": False, "type": "list",
                                 "options": {
                                     "name": {"required": True, "type": "str"}
                                 }},
                "youtube_channel_filter": {"required": False, "type": "list",
                                           "options": {
                                               "channel_id": {"required": False, "type": "str"},
                                               "comment": {"required": False, "type": "str"},
                                               "id": {"required": True, "type": "int"}
                                           }},
                "youtube_channel_status": {"required": False, "type": "str",
                                           "choices": ["disable", "blacklist", "whitelist"]}

            }
        }
    }

    module = AnsibleModule(argument_spec=fields,
                           supports_check_mode=False)

    # legacy_mode refers to using fortiosapi instead of HTTPAPI
    legacy_mode = 'host' in module.params and module.params['host'] is not None and \
                  'username' in module.params and module.params['username'] is not None and \
                  'password' in module.params and module.params['password'] is not None

    if not legacy_mode:
        if module._socket_path:
            connection = Connection(module._socket_path)
            fos = FortiOSHandler(connection)

            is_error, has_changed, result = fortios_webfilter(module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

        login(module.params, fos)
        is_error, has_changed, result = fortios_webfilter(module.params, fos)
        fos.logout()

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #21
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)
コード例 #22
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},
        "ips_global": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "anomaly_mode": {"required": False, "type": "str",
                                 "choices": ["periodical", "continuous"]},
                "database": {"required": False, "type": "str",
                             "choices": ["regular", "extended"]},
                "deep_app_insp_db_limit": {"required": False, "type": "int"},
                "deep_app_insp_timeout": {"required": False, "type": "int"},
                "engine_count": {"required": False, "type": "int"},
                "exclude_signatures": {"required": False, "type": "str",
                                       "choices": ["none", "industrial"]},
                "fail_open": {"required": False, "type": "str",
                              "choices": ["enable", "disable"]},
                "intelligent_mode": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "session_limit_mode": {"required": False, "type": "str",
                                       "choices": ["accurate", "heuristic"]},
                "skype_client_public_ipaddr": {"required": False, "type": "str"},
                "socket_size": {"required": False, "type": "int"},
                "sync_session_ttl": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "traffic_submit": {"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_ips(module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

        login(module.params, fos)
        is_error, has_changed, result = fortios_ips(module.params, fos)
        fos.logout()

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #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
        },
        "state": {
            "required": False,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "dlp_filepattern": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "comment": {
                    "required": False,
                    "type": "str"
                },
                "entries": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "file_type": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices": [
                                "7z", "arj", "cab", "lzh", "rar", "tar", "zip",
                                "bzip", "gzip", "bzip2", "xz", "bat", "msc",
                                "uue", "mime", "base64", "binhex", "elf",
                                "exe", "hta", "html", "jad", "class", "cod",
                                "javascript", "msoffice", "msofficex", "fsg",
                                "upx", "petite", "aspack", "sis", "hlp",
                                "activemime", "jpeg", "gif", "tiff", "png",
                                "bmp", "ignored", "unknown", "mpeg", "mov",
                                "mp3", "wma", "wav", "pdf", "avi", "rm",
                                "torrent", "hibun", "msi", "mach-o", "dmg",
                                ".net", "xar", "chm", "iso", "crx"
                            ]
                        },
                        "filter_type": {
                            "required": False,
                            "type": "str",
                            "choices": ["pattern", "type"]
                        },
                        "pattern": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "id": {
                    "required": True,
                    "type": "int"
                },
                "name": {
                    "required": False,
                    "type": "str"
                }
            }
        }
    }

    module = AnsibleModule(argument_spec=fields, supports_check_mode=False)

    # legacy_mode refers to using fortiosapi instead of HTTPAPI
    legacy_mode = 'host' in module.params and module.params['host'] is not None and \
                  'username' in module.params and module.params['username'] is not None and \
                  'password' in module.params and module.params['password'] is not None

    if not legacy_mode:
        if module._socket_path:
            connection = Connection(module._socket_path)
            fos = FortiOSHandler(connection)

            is_error, has_changed, result = fortios_dlp(module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

        login(module.params, fos)
        is_error, has_changed, result = fortios_dlp(module.params, fos)
        fos.logout()

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #24
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_fortianalyzer_filter": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "anomaly": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "dlp_archive": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "dns": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "filter": {
                    "required": False,
                    "type": "str"
                },
                "filter_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["include", "exclude"]
                },
                "forward_traffic": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "gtp": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "local_traffic": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "multicast_traffic": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "netscan_discovery": {
                    "required": False,
                    "type": "str"
                },
                "netscan_vulnerability": {
                    "required": False,
                    "type": "str"
                },
                "severity": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "emergency", "alert", "critical", "error", "warning",
                        "notification", "information", "debug"
                    ]
                },
                "sniffer_traffic": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "ssh": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "voip": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                }
            }
        }
    }

    module = AnsibleModule(argument_spec=fields, supports_check_mode=False)

    # legacy_mode refers to using fortiosapi instead of HTTPAPI
    legacy_mode = 'host' in module.params and module.params['host'] is not None and \
                  'username' in module.params and module.params['username'] is not None and \
                  'password' in module.params and module.params['password'] is not None

    if not legacy_mode:
        if module._socket_path:
            connection = Connection(module._socket_path)
            fos = FortiOSHandler(connection)

            is_error, has_changed, result = fortios_log_fortianalyzer(
                module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

        login(module.params, fos)
        is_error, has_changed, result = fortios_log_fortianalyzer(
            module.params, fos)
        fos.logout()

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #25
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": True,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "system_snmp_community": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "events": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "cpu-high", "mem-low", "log-full", "intf-ip",
                        "vpn-tun-up", "vpn-tun-down", "ha-switch",
                        "ha-hb-failure", "ips-signature", "ips-anomaly",
                        "av-virus", "av-oversize", "av-pattern",
                        "av-fragmented", "fm-if-change", "fm-conf-change",
                        "bgp-established", "bgp-backward-transition",
                        "ha-member-up", "ha-member-down", "ent-conf-change",
                        "av-conserve", "av-bypass", "av-oversize-passed",
                        "av-oversize-blocked", "ips-pkg-update",
                        "ips-fail-open", "faz-disconnect", "wc-ap-up",
                        "wc-ap-down", "fswctl-session-up",
                        "fswctl-session-down", "load-balance-real-server-down",
                        "device-new", "per-cpu-high"
                    ]
                },
                "hosts": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "ha_direct": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "host_type": {
                            "required": False,
                            "type": "str",
                            "choices": ["any", "query", "trap"]
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "ip": {
                            "required": False,
                            "type": "str"
                        },
                        "source_ip": {
                            "required": False,
                            "type": "str"
                        }
                    }
                },
                "hosts6": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "ha_direct": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "host_type": {
                            "required": False,
                            "type": "str",
                            "choices": ["any", "query", "trap"]
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "ipv6": {
                            "required": False,
                            "type": "str"
                        },
                        "source_ipv6": {
                            "required": False,
                            "type": "str"
                        }
                    }
                },
                "id": {
                    "required": True,
                    "type": "int"
                },
                "name": {
                    "required": False,
                    "type": "str"
                },
                "query_v1_port": {
                    "required": False,
                    "type": "int"
                },
                "query_v1_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "query_v2c_port": {
                    "required": False,
                    "type": "int"
                },
                "query_v2c_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "trap_v1_lport": {
                    "required": False,
                    "type": "int"
                },
                "trap_v1_rport": {
                    "required": False,
                    "type": "int"
                },
                "trap_v1_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "trap_v2c_lport": {
                    "required": False,
                    "type": "int"
                },
                "trap_v2c_rport": {
                    "required": False,
                    "type": "int"
                },
                "trap_v2c_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                }
            }
        }
    }

    module = AnsibleModule(argument_spec=fields, supports_check_mode=False)

    # legacy_mode refers to using fortiosapi instead of HTTPAPI
    legacy_mode = 'host' in module.params and module.params['host'] is not None and \
                  'username' in module.params and module.params['username'] is not None and \
                  'password' in module.params and module.params['password'] is not None

    if not legacy_mode:
        if module._socket_path:
            connection = Connection(module._socket_path)
            fos = FortiOSHandler(connection)

            is_error, has_changed, result = fortios_system_snmp(
                module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

        login(module.params, fos)
        is_error, has_changed, result = fortios_system_snmp(module.params, fos)
        fos.logout()

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #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_ssl_server": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "state": {"required": False, "type": "str",
                          "choices": ["present", "absent"]},
                "add_header_x_forwarded_proto": {"required": False, "type": "str",
                                                 "choices": ["enable", "disable"]},
                "ip": {"required": False, "type": "str"},
                "mapped_port": {"required": False, "type": "int"},
                "name": {"required": True, "type": "str"},
                "port": {"required": False, "type": "int"},
                "ssl_algorithm": {"required": False, "type": "str",
                                  "choices": ["high", "medium", "low"]},
                "ssl_cert": {"required": False, "type": "str"},
                "ssl_client_renegotiation": {"required": False, "type": "str",
                                             "choices": ["allow", "deny", "secure"]},
                "ssl_dh_bits": {"required": False, "type": "str",
                                "choices": ["768", "1024", "1536",
                                            "2048"]},
                "ssl_max_version": {"required": False, "type": "str",
                                    "choices": ["tls-1.0", "tls-1.1", "tls-1.2"]},
                "ssl_min_version": {"required": False, "type": "str",
                                    "choices": ["tls-1.0", "tls-1.1", "tls-1.2"]},
                "ssl_mode": {"required": False, "type": "str",
                             "choices": ["half", "full"]},
                "ssl_send_empty_frags": {"required": False, "type": "str",
                                         "choices": ["enable", "disable"]},
                "url_rewrite": {"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)
コード例 #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_multicast": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "interface": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "bfd": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "cisco_exclude_genid": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "dr_priority": {
                            "required": False,
                            "type": "int"
                        },
                        "hello_holdtime": {
                            "required": False,
                            "type": "int"
                        },
                        "hello_interval": {
                            "required": False,
                            "type": "int"
                        },
                        "igmp": {
                            "required": False,
                            "type": "dict",
                            "options": {
                                "access_group": {
                                    "required": False,
                                    "type": "str"
                                },
                                "immediate_leave_group": {
                                    "required": False,
                                    "type": "str"
                                },
                                "last_member_query_count": {
                                    "required": False,
                                    "type": "int"
                                },
                                "last_member_query_interval": {
                                    "required": False,
                                    "type": "int"
                                },
                                "query_interval": {
                                    "required": False,
                                    "type": "int"
                                },
                                "query_max_response_time": {
                                    "required": False,
                                    "type": "int"
                                },
                                "query_timeout": {
                                    "required": False,
                                    "type": "int"
                                },
                                "router_alert_check": {
                                    "required": False,
                                    "type": "str",
                                    "choices": ["enable", "disable"]
                                },
                                "version": {
                                    "required": False,
                                    "type": "str",
                                    "choices": ["3", "2", "1"]
                                }
                            }
                        },
                        "join_group": {
                            "required": False,
                            "type": "list",
                            "options": {
                                "address": {
                                    "required": True,
                                    "type": "str"
                                }
                            }
                        },
                        "multicast_flow": {
                            "required": False,
                            "type": "str"
                        },
                        "name": {
                            "required": True,
                            "type": "str"
                        },
                        "neighbour_filter": {
                            "required": False,
                            "type": "str"
                        },
                        "passive": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "pim_mode": {
                            "required": False,
                            "type": "str",
                            "choices": ["sparse-mode", "dense-mode"]
                        },
                        "propagation_delay": {
                            "required": False,
                            "type": "int"
                        },
                        "rp_candidate": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "rp_candidate_group": {
                            "required": False,
                            "type": "str"
                        },
                        "rp_candidate_interval": {
                            "required": False,
                            "type": "int"
                        },
                        "rp_candidate_priority": {
                            "required": False,
                            "type": "int"
                        },
                        "state_refresh_interval": {
                            "required": False,
                            "type": "int"
                        },
                        "static_group": {
                            "required": False,
                            "type": "str"
                        },
                        "ttl_threshold": {
                            "required": False,
                            "type": "int"
                        }
                    }
                },
                "multicast_routing": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "pim_sm_global": {
                    "required": False,
                    "type": "dict",
                    "options": {
                        "accept_register_list": {
                            "required": False,
                            "type": "str"
                        },
                        "accept_source_list": {
                            "required": False,
                            "type": "str"
                        },
                        "bsr_allow_quick_refresh": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "bsr_candidate": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "bsr_hash": {
                            "required": False,
                            "type": "int"
                        },
                        "bsr_interface": {
                            "required": False,
                            "type": "str"
                        },
                        "bsr_priority": {
                            "required": False,
                            "type": "int"
                        },
                        "cisco_crp_prefix": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "cisco_ignore_rp_set_priority": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "cisco_register_checksum": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "cisco_register_checksum_group": {
                            "required": False,
                            "type": "str"
                        },
                        "join_prune_holdtime": {
                            "required": False,
                            "type": "int"
                        },
                        "message_interval": {
                            "required": False,
                            "type": "int"
                        },
                        "null_register_retries": {
                            "required": False,
                            "type": "int"
                        },
                        "register_rate_limit": {
                            "required": False,
                            "type": "int"
                        },
                        "register_rp_reachability": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "register_source": {
                            "required": False,
                            "type": "str",
                            "choices": ["disable", "interface", "ip-address"]
                        },
                        "register_source_interface": {
                            "required": False,
                            "type": "str"
                        },
                        "register_source_ip": {
                            "required": False,
                            "type": "str"
                        },
                        "register_supression": {
                            "required": False,
                            "type": "int"
                        },
                        "rp_address": {
                            "required": False,
                            "type": "list",
                            "options": {
                                "group": {
                                    "required": False,
                                    "type": "str"
                                },
                                "id": {
                                    "required": True,
                                    "type": "int"
                                },
                                "ip_address": {
                                    "required": False,
                                    "type": "str"
                                }
                            }
                        },
                        "rp_register_keepalive": {
                            "required": False,
                            "type": "int"
                        },
                        "spt_threshold": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "spt_threshold_group": {
                            "required": False,
                            "type": "str"
                        },
                        "ssm": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "ssm_range": {
                            "required": False,
                            "type": "str"
                        }
                    }
                },
                "route_limit": {
                    "required": False,
                    "type": "int"
                },
                "route_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_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)
コード例 #28
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_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)
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)
コード例 #30
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_sdn_connector": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "state": {"required": False, "type": "str",
                          "choices": ["present", "absent"]},
                "access_key": {"required": False, "type": "str"},
                "azure_region": {"required": False, "type": "str",
                                 "choices": ["global", "china", "germany",
                                             "usgov", "local"]},
                "client_id": {"required": False, "type": "str"},
                "client_secret": {"required": False, "type": "str"},
                "compartment_id": {"required": False, "type": "str"},
                "external_ip": {"required": False, "type": "list",
                                "options": {
                                    "name": {"required": True, "type": "str"}
                                }},
                "gcp_project": {"required": False, "type": "str"},
                "key_passwd": {"required": False, "type": "str"},
                "login_endpoint": {"required": False, "type": "str"},
                "name": {"required": True, "type": "str"},
                "nic": {"required": False, "type": "list",
                        "options": {
                            "ip": {"required": False, "type": "list",
                                   "options": {
                                       "name": {"required": True, "type": "str"},
                                       "public_ip": {"required": False, "type": "str"}
                                   }},
                            "name": {"required": True, "type": "str"}
                        }},
                "oci_cert": {"required": False, "type": "str"},
                "oci_fingerprint": {"required": False, "type": "str"},
                "oci_region": {"required": False, "type": "str",
                               "choices": ["phoenix", "ashburn", "frankfurt",
                                           "london"]},
                "password": {"required": False, "type": "str"},
                "private_key": {"required": False, "type": "str"},
                "region": {"required": False, "type": "str"},
                "resource_group": {"required": False, "type": "str"},
                "resource_url": {"required": False, "type": "str"},
                "route": {"required": False, "type": "list",
                          "options": {
                              "name": {"required": True, "type": "str"}
                          }},
                "route_table": {"required": False, "type": "list",
                                "options": {
                                    "name": {"required": True, "type": "str"},
                                    "route": {"required": False, "type": "list",
                                              "options": {
                                                  "name": {"required": True, "type": "str"},
                                                  "next_hop": {"required": False, "type": "str"}
                                              }}
                                }},
                "secret_key": {"required": False, "type": "str"},
                "server": {"required": False, "type": "str"},
                "server_port": {"required": False, "type": "int"},
                "service_account": {"required": False, "type": "str"},
                "status": {"required": False, "type": "str",
                           "choices": ["disable", "enable"]},
                "subscription_id": {"required": False, "type": "str"},
                "tenant_id": {"required": False, "type": "str"},
                "type": {"required": False, "type": "str",
                         "choices": ["aci", "aws", "azure",
                                     "gcp", "nsx", "nuage",
                                     "oci", "openstack"]},
                "update_interval": {"required": False, "type": "int"},
                "use_metadata_iam": {"required": False, "type": "str",
                                     "choices": ["disable", "enable"]},
                "user_id": {"required": False, "type": "str"},
                "username": {"required": False, "type": "str"},
                "vpc_id": {"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)