コード例 #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_proxy_policy": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "action": {
                    "required": False,
                    "type": "str",
                    "choices": ["accept", "deny", "redirect"]
                },
                "application_list": {
                    "required": False,
                    "type": "str"
                },
                "av_profile": {
                    "required": False,
                    "type": "str"
                },
                "comments": {
                    "required": False,
                    "type": "str"
                },
                "disclaimer": {
                    "required": False,
                    "type": "str",
                    "choices": ["disable", "domain", "policy", "user"]
                },
                "dlp_sensor": {
                    "required": False,
                    "type": "str"
                },
                "dstaddr": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "dstaddr_negate": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "dstaddr6": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "dstintf": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "global_label": {
                    "required": False,
                    "type": "str"
                },
                "groups": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "http_tunnel_auth": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "icap_profile": {
                    "required": False,
                    "type": "str"
                },
                "internet_service": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "internet_service_custom": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "internet_service_id": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "id": {
                            "required": True,
                            "type": "int"
                        }
                    }
                },
                "internet_service_negate": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "ips_sensor": {
                    "required": False,
                    "type": "str"
                },
                "label": {
                    "required": False,
                    "type": "str"
                },
                "logtraffic": {
                    "required": False,
                    "type": "str",
                    "choices": ["all", "utm", "disable"]
                },
                "logtraffic_start": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "policyid": {
                    "required": True,
                    "type": "int"
                },
                "poolname": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "profile_group": {
                    "required": False,
                    "type": "str"
                },
                "profile_protocol_options": {
                    "required": False,
                    "type": "str"
                },
                "profile_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["single", "group"]
                },
                "proxy": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "explicit-web", "transparent-web", "ftp", "ssh",
                        "ssh-tunnel", "wanopt"
                    ]
                },
                "redirect_url": {
                    "required": False,
                    "type": "str"
                },
                "replacemsg_override_group": {
                    "required": False,
                    "type": "str"
                },
                "scan_botnet_connections": {
                    "required": False,
                    "type": "str",
                    "choices": ["disable", "block", "monitor"]
                },
                "schedule": {
                    "required": False,
                    "type": "str"
                },
                "service": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "service_negate": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "session_ttl": {
                    "required": False,
                    "type": "int"
                },
                "spamfilter_profile": {
                    "required": False,
                    "type": "str"
                },
                "srcaddr": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "srcaddr_negate": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "srcaddr6": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "srcintf": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "ssh_filter_profile": {
                    "required": False,
                    "type": "str"
                },
                "ssl_ssh_profile": {
                    "required": False,
                    "type": "str"
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "transparent": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "users": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "utm_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "uuid": {
                    "required": False,
                    "type": "str"
                },
                "waf_profile": {
                    "required": False,
                    "type": "str"
                },
                "webcache": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "webcache_https": {
                    "required": False,
                    "type": "str",
                    "choices": ["disable", "enable"]
                },
                "webfilter_profile": {
                    "required": False,
                    "type": "str"
                },
                "webproxy_forward_server": {
                    "required": False,
                    "type": "str"
                },
                "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_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_ha": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "arps": {"required": False, "type": "int"},
                "arps_interval": {"required": False, "type": "int"},
                "authentication": {"required": False, "type": "str",
                                   "choices": ["enable", "disable"]},
                "cpu_threshold": {"required": False, "type": "str"},
                "encryption": {"required": False, "type": "str",
                               "choices": ["enable", "disable"]},
                "ftp_proxy_threshold": {"required": False, "type": "str"},
                "gratuitous_arps": {"required": False, "type": "str",
                                    "choices": ["enable", "disable"]},
                "group_id": {"required": False, "type": "int"},
                "group_name": {"required": False, "type": "str"},
                "ha_direct": {"required": False, "type": "str",
                              "choices": ["enable", "disable"]},
                "ha_eth_type": {"required": False, "type": "str"},
                "ha_mgmt_interfaces": {"required": False, "type": "list",
                                       "options": {
                                           "dst": {"required": False, "type": "str"},
                                           "gateway": {"required": False, "type": "str"},
                                           "gateway6": {"required": False, "type": "str"},
                                           "id": {"required": True, "type": "int"},
                                           "interface": {"required": False, "type": "str"}
                                       }},
                "ha_mgmt_status": {"required": False, "type": "str",
                                   "choices": ["enable", "disable"]},
                "ha_uptime_diff_margin": {"required": False, "type": "int"},
                "hb_interval": {"required": False, "type": "int"},
                "hb_lost_threshold": {"required": False, "type": "int"},
                "hbdev": {"required": False, "type": "str"},
                "hc_eth_type": {"required": False, "type": "str"},
                "hello_holddown": {"required": False, "type": "int"},
                "http_proxy_threshold": {"required": False, "type": "str"},
                "imap_proxy_threshold": {"required": False, "type": "str"},
                "inter_cluster_session_sync": {"required": False, "type": "str",
                                               "choices": ["enable", "disable"]},
                "key": {"required": False, "type": "str"},
                "l2ep_eth_type": {"required": False, "type": "str"},
                "link_failed_signal": {"required": False, "type": "str",
                                       "choices": ["enable", "disable"]},
                "load_balance_all": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "memory_compatible_mode": {"required": False, "type": "str",
                                           "choices": ["enable", "disable"]},
                "memory_threshold": {"required": False, "type": "str"},
                "mode": {"required": False, "type": "str",
                         "choices": ["standalone", "a-a", "a-p"]},
                "monitor": {"required": False, "type": "str"},
                "multicast_ttl": {"required": False, "type": "int"},
                "nntp_proxy_threshold": {"required": False, "type": "str"},
                "override": {"required": False, "type": "str",
                             "choices": ["enable", "disable"]},
                "override_wait_time": {"required": False, "type": "int"},
                "password": {"required": False, "type": "str"},
                "pingserver_failover_threshold": {"required": False, "type": "int"},
                "pingserver_flip_timeout": {"required": False, "type": "int"},
                "pingserver_monitor_interface": {"required": False, "type": "str"},
                "pingserver_slave_force_reset": {"required": False, "type": "str",
                                                 "choices": ["enable", "disable"]},
                "pop3_proxy_threshold": {"required": False, "type": "str"},
                "priority": {"required": False, "type": "int"},
                "route_hold": {"required": False, "type": "int"},
                "route_ttl": {"required": False, "type": "int"},
                "route_wait": {"required": False, "type": "int"},
                "schedule": {"required": False, "type": "str",
                             "choices": ["none", "hub", "leastconnection",
                                         "round-robin", "weight-round-robin", "random",
                                         "ip", "ipport"]},
                "secondary_vcluster": {"required": False, "type": "dict",
                                       "options": {
                                           "monitor": {"required": False, "type": "str"},
                                           "override": {"required": False, "type": "str",
                                                        "choices": ["enable", "disable"]},
                                           "override_wait_time": {"required": False, "type": "int"},
                                           "pingserver_failover_threshold": {"required": False, "type": "int"},
                                           "pingserver_monitor_interface": {"required": False, "type": "str"},
                                           "pingserver_slave_force_reset": {"required": False, "type": "str",
                                                                            "choices": ["enable", "disable"]},
                                           "priority": {"required": False, "type": "int"},
                                           "vcluster_id": {"required": False, "type": "int"},
                                           "vdom": {"required": False, "type": "str"}
                                       }},
                "session_pickup": {"required": False, "type": "str",
                                   "choices": ["enable", "disable"]},
                "session_pickup_connectionless": {"required": False, "type": "str",
                                                  "choices": ["enable", "disable"]},
                "session_pickup_delay": {"required": False, "type": "str",
                                         "choices": ["enable", "disable"]},
                "session_pickup_expectation": {"required": False, "type": "str",
                                               "choices": ["enable", "disable"]},
                "session_pickup_nat": {"required": False, "type": "str",
                                       "choices": ["enable", "disable"]},
                "session_sync_dev": {"required": False, "type": "str"},
                "smtp_proxy_threshold": {"required": False, "type": "str"},
                "standalone_config_sync": {"required": False, "type": "str",
                                           "choices": ["enable", "disable"]},
                "standalone_mgmt_vdom": {"required": False, "type": "str",
                                         "choices": ["enable", "disable"]},
                "sync_config": {"required": False, "type": "str",
                                "choices": ["enable", "disable"]},
                "sync_packet_balance": {"required": False, "type": "str",
                                        "choices": ["enable", "disable"]},
                "unicast_hb": {"required": False, "type": "str",
                               "choices": ["enable", "disable"]},
                "unicast_hb_netmask": {"required": False, "type": "str"},
                "unicast_hb_peerip": {"required": False, "type": "str"},
                "uninterruptible_upgrade": {"required": False, "type": "str",
                                            "choices": ["enable", "disable"]},
                "vcluster_id": {"required": False, "type": "int"},
                "vcluster2": {"required": False, "type": "str",
                              "choices": ["enable", "disable"]},
                "vdom": {"required": False, "type": "str"},
                "weight": {"required": False, "type": "str"}

            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": True,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "system_ipv6_neighbor_cache": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "id": {
                    "required": True,
                    "type": "int"
                },
                "interface": {
                    "required": False,
                    "type": "str"
                },
                "ipv6": {
                    "required": False,
                    "type": "str"
                },
                "mac": {
                    "required": False,
                    "type": "str"
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": True,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "system_link_monitor": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "addr_mode": {
                    "required": False,
                    "type": "str",
                    "choices": ["ipv4", "ipv6"]
                },
                "failtime": {
                    "required": False,
                    "type": "int"
                },
                "gateway_ip": {
                    "required": False,
                    "type": "str"
                },
                "gateway_ip6": {
                    "required": False,
                    "type": "str"
                },
                "ha_priority": {
                    "required": False,
                    "type": "int"
                },
                "http_agent": {
                    "required": False,
                    "type": "str"
                },
                "http_get": {
                    "required": False,
                    "type": "str"
                },
                "http_match": {
                    "required": False,
                    "type": "str"
                },
                "interval": {
                    "required": False,
                    "type": "int"
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "packet_size": {
                    "required": False,
                    "type": "int"
                },
                "password": {
                    "required": False,
                    "type": "str"
                },
                "port": {
                    "required": False,
                    "type": "int"
                },
                "protocol": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices":
                    ["ping", "tcp-echo", "udp-echo", "http", "twamp", "ping6"]
                },
                "recoverytime": {
                    "required": False,
                    "type": "int"
                },
                "security_mode": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "authentication"]
                },
                "server": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "address": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "source_ip": {
                    "required": False,
                    "type": "str"
                },
                "source_ip6": {
                    "required": False,
                    "type": "str"
                },
                "srcintf": {
                    "required": False,
                    "type": "str"
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "update_cascade_interface": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "update_static_route": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

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

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

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

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

            is_error, has_changed, result = fortios_log_syslogd3(
                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_syslogd3(
            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
        },
        "vpn_certificate_setting": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "certname_dsa1024": {
                    "required": False,
                    "type": "str"
                },
                "certname_dsa2048": {
                    "required": False,
                    "type": "str"
                },
                "certname_ecdsa256": {
                    "required": False,
                    "type": "str"
                },
                "certname_ecdsa384": {
                    "required": False,
                    "type": "str"
                },
                "certname_rsa1024": {
                    "required": False,
                    "type": "str"
                },
                "certname_rsa2048": {
                    "required": False,
                    "type": "str"
                },
                "check_ca_cert": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "check_ca_chain": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "cmp_save_extra_certs": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "cn_match": {
                    "required": False,
                    "type": "str",
                    "choices": ["substring", "value"]
                },
                "ocsp_default_server": {
                    "required": False,
                    "type": "str"
                },
                "ocsp_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "ssl_min_proto_version": {
                    "required": False,
                    "type": "str",
                    "choices":
                    ["default", "SSLv3", "TLSv1", "TLSv1-1", "TLSv1-2"]
                },
                "ssl_ocsp_option": {
                    "required": False,
                    "type": "str",
                    "choices": ["certificate", "server"]
                },
                "ssl_ocsp_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "strict_crl_check": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "strict_ocsp_check": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "subject_match": {
                    "required": False,
                    "type": "str",
                    "choices": ["substring", "value"]
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": False,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "vpn_ipsec_phase2": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "add_route": {
                    "required": False,
                    "type": "str",
                    "choices": ["phase1", "enable", "disable"]
                },
                "auto_negotiate": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "comments": {
                    "required": False,
                    "type": "str"
                },
                "dhcp_ipsec": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "dhgrp": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "1", "2", "5", "14", "15", "16", "17", "18", "19",
                        "20", "21", "27", "28", "29", "30", "31"
                    ]
                },
                "dst_addr_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["subnet", "range", "ip", "name"]
                },
                "dst_end_ip": {
                    "required": False,
                    "type": "str"
                },
                "dst_end_ip6": {
                    "required": False,
                    "type": "str"
                },
                "dst_name": {
                    "required": False,
                    "type": "str"
                },
                "dst_name6": {
                    "required": False,
                    "type": "str"
                },
                "dst_port": {
                    "required": False,
                    "type": "int"
                },
                "dst_start_ip": {
                    "required": False,
                    "type": "str"
                },
                "dst_start_ip6": {
                    "required": False,
                    "type": "str"
                },
                "dst_subnet": {
                    "required": False,
                    "type": "str"
                },
                "dst_subnet6": {
                    "required": False,
                    "type": "str"
                },
                "encapsulation": {
                    "required": False,
                    "type": "str",
                    "choices": ["tunnel-mode", "transport-mode"]
                },
                "keepalive": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "keylife_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["seconds", "kbs", "both"]
                },
                "keylifekbs": {
                    "required": False,
                    "type": "int"
                },
                "keylifeseconds": {
                    "required": False,
                    "type": "int"
                },
                "l2tp": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "pfs": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "phase1name": {
                    "required": False,
                    "type": "str"
                },
                "proposal": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "null-md5", "null-sha1", "null-sha256", "null-sha384",
                        "null-sha512", "des-null", "des-md5", "des-sha1",
                        "des-sha256", "des-sha384", "des-sha512"
                    ]
                },
                "protocol": {
                    "required": False,
                    "type": "int"
                },
                "replay": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "route_overlap": {
                    "required": False,
                    "type": "str",
                    "choices": ["use-old", "use-new", "allow"]
                },
                "selector_match": {
                    "required": False,
                    "type": "str",
                    "choices": ["exact", "subset", "auto"]
                },
                "single_source": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "src_addr_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["subnet", "range", "ip", "name"]
                },
                "src_end_ip": {
                    "required": False,
                    "type": "str"
                },
                "src_end_ip6": {
                    "required": False,
                    "type": "str"
                },
                "src_name": {
                    "required": False,
                    "type": "str"
                },
                "src_name6": {
                    "required": False,
                    "type": "str"
                },
                "src_port": {
                    "required": False,
                    "type": "int"
                },
                "src_start_ip": {
                    "required": False,
                    "type": "str"
                },
                "src_start_ip6": {
                    "required": False,
                    "type": "str"
                },
                "src_subnet": {
                    "required": False,
                    "type": "str"
                },
                "src_subnet6": {
                    "required": False,
                    "type": "str"
                },
                "use_natip": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #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"]
        },
        "authentication_rule": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "active_auth_method": {
                    "required": False,
                    "type": "str"
                },
                "comments": {
                    "required": False,
                    "type": "str"
                },
                "ip_based": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "protocol": {
                    "required": False,
                    "type": "str",
                    "choices": ["http", "ftp", "socks", "ssh"]
                },
                "srcaddr": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "srcaddr6": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "sso_auth_method": {
                    "required": False,
                    "type": "str"
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "transaction_based": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "web_auth_cookie": {
                    "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_authentication(
                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_authentication(
            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_bonjour_profile": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "comment": {"required": False, "type": "str"},
                "name": {"required": True, "type": "str"},
                "policy_list": {"required": False, "type": "list",
                                "options": {
                                    "description": {"required": False, "type": "str"},
                                    "from_vlan": {"required": False, "type": "str"},
                                    "policy_id": {"required": False, "type": "int"},
                                    "services": {"required": False, "type": "str",
                                                 "choices": ["all", "airplay", "afp",
                                                             "bit-torrent", "ftp", "ichat",
                                                             "itunes", "printers", "samba",
                                                             "scanners", "ssh", "chromecast"]},
                                    "to_vlan": {"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(module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": True,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "switch_controller_qos_dot1p_map": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "description": {
                    "required": False,
                    "type": "str"
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "priority_0": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "queue-0", "queue-1", "queue-2", "queue-3", "queue-4",
                        "queue-5", "queue-6", "queue-7"
                    ]
                },
                "priority_1": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "queue-0", "queue-1", "queue-2", "queue-3", "queue-4",
                        "queue-5", "queue-6", "queue-7"
                    ]
                },
                "priority_2": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "queue-0", "queue-1", "queue-2", "queue-3", "queue-4",
                        "queue-5", "queue-6", "queue-7"
                    ]
                },
                "priority_3": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "queue-0", "queue-1", "queue-2", "queue-3", "queue-4",
                        "queue-5", "queue-6", "queue-7"
                    ]
                },
                "priority_4": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "queue-0", "queue-1", "queue-2", "queue-3", "queue-4",
                        "queue-5", "queue-6", "queue-7"
                    ]
                },
                "priority_5": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "queue-0", "queue-1", "queue-2", "queue-3", "queue-4",
                        "queue-5", "queue-6", "queue-7"
                    ]
                },
                "priority_6": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "queue-0", "queue-1", "queue-2", "queue-3", "queue-4",
                        "queue-5", "queue-6", "queue-7"
                    ]
                },
                "priority_7": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "queue-0", "queue-1", "queue-2", "queue-3", "queue-4",
                        "queue-5", "queue-6", "queue-7"
                    ]
                }
            }
        }
    }

    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_qos(
                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_qos(
            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"]
        },
        "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)
コード例 #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
        },
        "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)
コード例 #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"]},
        "report_layout": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "state": {"required": False, "type": "str",
                          "choices": ["present", "absent"]},
                "body_item": {"required": False, "type": "list",
                              "options": {
                                  "chart": {"required": False, "type": "str"},
                                  "chart_options": {"required": False, "type": "str",
                                                    "choices": ["include-no-data", "hide-title", "show-caption"]},
                                  "column": {"required": False, "type": "int"},
                                  "content": {"required": False, "type": "str"},
                                  "description": {"required": False, "type": "str"},
                                  "drill_down_items": {"required": False, "type": "str"},
                                  "drill_down_types": {"required": False, "type": "str"},
                                  "hide": {"required": False, "type": "str",
                                           "choices": ["enable", "disable"]},
                                  "id": {"required": True, "type": "int"},
                                  "img_src": {"required": False, "type": "str"},
                                  "list": {"required": False, "type": "list",
                                           "options": {
                                               "content": {"required": False, "type": "str"},
                                               "id": {"required": True, "type": "int"}
                                           }},
                                  "list_component": {"required": False, "type": "str",
                                                     "choices": ["bullet", "numbered"]},
                                  "misc_component": {"required": False, "type": "str",
                                                     "choices": ["hline", "page-break", "column-break",
                                                                 "section-start"]},
                                  "parameters": {"required": False, "type": "list",
                                                 "options": {
                                                     "id": {"required": True, "type": "int"},
                                                     "name": {"required": False, "type": "str"},
                                                     "value": {"required": False, "type": "str"}
                                                 }},
                                  "style": {"required": False, "type": "str"},
                                  "table_caption_style": {"required": False, "type": "str"},
                                  "table_column_widths": {"required": False, "type": "str"},
                                  "table_even_row_style": {"required": False, "type": "str"},
                                  "table_head_style": {"required": False, "type": "str"},
                                  "table_odd_row_style": {"required": False, "type": "str"},
                                  "text_component": {"required": False, "type": "str",
                                                     "choices": ["text", "heading1", "heading2",
                                                                 "heading3"]},
                                  "title": {"required": False, "type": "str"},
                                  "top_n": {"required": False, "type": "int"},
                                  "type": {"required": False, "type": "str",
                                           "choices": ["text", "image", "chart",
                                                       "misc"]}
                              }},
                "cutoff_option": {"required": False, "type": "str",
                                  "choices": ["run-time", "custom"]},
                "cutoff_time": {"required": False, "type": "str"},
                "day": {"required": False, "type": "str",
                        "choices": ["sunday", "monday", "tuesday",
                                    "wednesday", "thursday", "friday",
                                    "saturday"]},
                "description": {"required": False, "type": "str"},
                "email_recipients": {"required": False, "type": "str"},
                "email_send": {"required": False, "type": "str",
                               "choices": ["enable", "disable"]},
                "format": {"required": False, "type": "str",
                           "choices": ["pdf"]},
                "max_pdf_report": {"required": False, "type": "int"},
                "name": {"required": True, "type": "str"},
                "options": {"required": False, "type": "str",
                            "choices": ["include-table-of-content", "auto-numbering-heading", "view-chart-as-heading",
                                        "show-html-navbar-before-heading", "dummy-option"]},
                "page": {"required": False, "type": "dict",
                         "options": {
                             "column_break_before": {"required": False, "type": "str",
                                                     "choices": ["heading1", "heading2", "heading3"]},
                             "footer": {"required": False, "type": "dict",
                                        "options": {
                                            "footer_item": {"required": False, "type": "list",
                                                            "options": {
                                                                "content": {"required": False, "type": "str"},
                                                                "description": {"required": False, "type": "str"},
                                                                "id": {"required": True, "type": "int"},
                                                                "img_src": {"required": False, "type": "str"},
                                                                "style": {"required": False, "type": "str"},
                                                                "type": {"required": False, "type": "str",
                                                                         "choices": ["text", "image"]}
                                                            }},
                                            "style": {"required": False, "type": "str"}
                                        }},
                             "header": {"required": False, "type": "dict",
                                        "options": {
                                            "header_item": {"required": False, "type": "list",
                                                            "options": {
                                                                "content": {"required": False, "type": "str"},
                                                                "description": {"required": False, "type": "str"},
                                                                "id": {"required": True, "type": "int"},
                                                                "img_src": {"required": False, "type": "str"},
                                                                "style": {"required": False, "type": "str"},
                                                                "type": {"required": False, "type": "str",
                                                                         "choices": ["text", "image"]}
                                                            }},
                                            "style": {"required": False, "type": "str"}
                                        }},
                             "options": {"required": False, "type": "str",
                                         "choices": ["header-on-first-page", "footer-on-first-page"]},
                             "page_break_before": {"required": False, "type": "str",
                                                   "choices": ["heading1", "heading2", "heading3"]},
                             "paper": {"required": False, "type": "str",
                                       "choices": ["a4", "letter"]}
                         }},
                "schedule_type": {"required": False, "type": "str",
                                  "choices": ["demand", "daily", "weekly"]},
                "style_theme": {"required": False, "type": "str"},
                "subtitle": {"required": False, "type": "str"},
                "time": {"required": False, "type": "str"},
                "title": {"required": False, "type": "str"}

            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": False,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "firewall_profile_group": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "application_list": {
                    "required": False,
                    "type": "str"
                },
                "av_profile": {
                    "required": False,
                    "type": "str"
                },
                "dlp_sensor": {
                    "required": False,
                    "type": "str"
                },
                "dnsfilter_profile": {
                    "required": False,
                    "type": "str"
                },
                "icap_profile": {
                    "required": False,
                    "type": "str"
                },
                "ips_sensor": {
                    "required": False,
                    "type": "str"
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "profile_protocol_options": {
                    "required": False,
                    "type": "str"
                },
                "spamfilter_profile": {
                    "required": False,
                    "type": "str"
                },
                "ssh_filter_profile": {
                    "required": False,
                    "type": "str"
                },
                "ssl_ssh_profile": {
                    "required": False,
                    "type": "str"
                },
                "voip_profile": {
                    "required": False,
                    "type": "str"
                },
                "waf_profile": {
                    "required": False,
                    "type": "str"
                },
                "webfilter_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_firewall(
                module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "user_setting": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "auth_blackout_time": {
                    "required": False,
                    "type": "int"
                },
                "auth_ca_cert": {
                    "required": False,
                    "type": "str"
                },
                "auth_cert": {
                    "required": False,
                    "type": "str"
                },
                "auth_http_basic": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "auth_invalid_max": {
                    "required": False,
                    "type": "int"
                },
                "auth_lockout_duration": {
                    "required": False,
                    "type": "int"
                },
                "auth_lockout_threshold": {
                    "required": False,
                    "type": "int"
                },
                "auth_portal_timeout": {
                    "required": False,
                    "type": "int"
                },
                "auth_ports": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "port": {
                            "required": False,
                            "type": "int"
                        },
                        "type": {
                            "required": False,
                            "type": "str",
                            "choices": ["http", "https", "ftp", "telnet"]
                        }
                    }
                },
                "auth_secure_http": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "auth_src_mac": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "auth_ssl_allow_renegotiation": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "auth_timeout": {
                    "required": False,
                    "type": "int"
                },
                "auth_timeout_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["idle-timeout", "hard-timeout", "new-session"]
                },
                "auth_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["http", "https", "ftp", "telnet"]
                },
                "radius_ses_timeout_act": {
                    "required": False,
                    "type": "str",
                    "choices": ["hard-timeout", "ignore-timeout"]
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #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"]
        },
        "authentication_scheme": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "domain_controller": {
                    "required": False,
                    "type": "str"
                },
                "fsso_agent_for_ntlm": {
                    "required": False,
                    "type": "str"
                },
                "fsso_guest": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "kerberos_keytab": {
                    "required": False,
                    "type": "str"
                },
                "method": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "ntlm", "basic", "digest", "form", "negotiate", "fsso",
                        "rsso", "ssh-publickey"
                    ]
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "negotiate_ntlm": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "require_tfa": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "ssh_ca": {
                    "required": False,
                    "type": "str"
                },
                "user_database": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                }
            }
        }
    }

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

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

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

            is_error, has_changed, result = fortios_authentication(
                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_authentication(
            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)
コード例 #17
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"]},
        "web_proxy_forward_server_group": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "affinity": {"required": False, "type": "str",
                             "choices": ["enable", "disable"]},
                "group_down_option": {"required": False, "type": "str",
                                      "choices": ["block", "pass"]},
                "ldb_method": {"required": False, "type": "str",
                               "choices": ["weighted", "least-session"]},
                "name": {"required": True, "type": "str"},
                "server_list": {"required": False, "type": "list",
                                "options": {
                                    "name": {"required": True, "type": "str"},
                                    "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_web_proxy(module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": False,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "extender_controller_extender": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "aaa_shared_secret": {
                    "required": False,
                    "type": "str"
                },
                "access_point_name": {
                    "required": False,
                    "type": "str"
                },
                "admin": {
                    "required": False,
                    "type": "str",
                    "choices": ["disable", "discovered", "enable"]
                },
                "at_dial_script": {
                    "required": False,
                    "type": "str"
                },
                "billing_start_day": {
                    "required": False,
                    "type": "int"
                },
                "cdma_aaa_spi": {
                    "required": False,
                    "type": "str"
                },
                "cdma_ha_spi": {
                    "required": False,
                    "type": "str"
                },
                "cdma_nai": {
                    "required": False,
                    "type": "str"
                },
                "conn_status": {
                    "required": False,
                    "type": "int"
                },
                "description": {
                    "required": False,
                    "type": "str"
                },
                "dial_mode": {
                    "required": False,
                    "type": "str",
                    "choices": ["dial-on-demand", "always-connect"]
                },
                "dial_status": {
                    "required": False,
                    "type": "int"
                },
                "ext_name": {
                    "required": False,
                    "type": "str"
                },
                "ha_shared_secret": {
                    "required": False,
                    "type": "str"
                },
                "id": {
                    "required": True,
                    "type": "str"
                },
                "ifname": {
                    "required": False,
                    "type": "str"
                },
                "initiated_update": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "mode": {
                    "required": False,
                    "type": "str",
                    "choices": ["standalone", "redundant"]
                },
                "modem_passwd": {
                    "required": False,
                    "type": "str"
                },
                "modem_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["cdma", "gsm/lte", "wimax"]
                },
                "multi_mode": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices":
                    ["auto", "auto-3g", "force-lte", "force-3g", "force-2g"]
                },
                "ppp_auth_protocol": {
                    "required": False,
                    "type": "str",
                    "choices": ["auto", "pap", "chap"]
                },
                "ppp_echo_request": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "ppp_password": {
                    "required": False,
                    "type": "str"
                },
                "ppp_username": {
                    "required": False,
                    "type": "str"
                },
                "primary_ha": {
                    "required": False,
                    "type": "str"
                },
                "quota_limit_mb": {
                    "required": False,
                    "type": "int"
                },
                "redial": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "none", "1", "2", "3", "4", "5", "6", "7", "8", "9",
                        "10"
                    ]
                },
                "redundant_intf": {
                    "required": False,
                    "type": "str"
                },
                "roaming": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "role": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "primary", "secondary"]
                },
                "secondary_ha": {
                    "required": False,
                    "type": "str"
                },
                "sim_pin": {
                    "required": False,
                    "type": "str"
                },
                "vdom": {
                    "required": False,
                    "type": "int"
                },
                "wimax_auth_protocol": {
                    "required": False,
                    "type": "str",
                    "choices": ["tls", "ttls"]
                },
                "wimax_carrier": {
                    "required": False,
                    "type": "str"
                },
                "wimax_realm": {
                    "required": False,
                    "type": "str"
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "log_threat_weight": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "application": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "category": {
                            "required": False,
                            "type": "int"
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "level": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        }
                    }
                },
                "blocked_connection": {
                    "required": False,
                    "type": "str",
                    "choices":
                    ["disable", "low", "medium", "high", "critical"]
                },
                "failed_connection": {
                    "required": False,
                    "type": "str",
                    "choices":
                    ["disable", "low", "medium", "high", "critical"]
                },
                "geolocation": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "country": {
                            "required": False,
                            "type": "str"
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "level": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        }
                    }
                },
                "ips": {
                    "required": False,
                    "type": "dict",
                    "options": {
                        "critical_severity": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "high_severity": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "info_severity": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "low_severity": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "medium_severity": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        }
                    }
                },
                "level": {
                    "required": False,
                    "type": "dict",
                    "options": {
                        "critical": {
                            "required": False,
                            "type": "int"
                        },
                        "high": {
                            "required": False,
                            "type": "int"
                        },
                        "low": {
                            "required": False,
                            "type": "int"
                        },
                        "medium": {
                            "required": False,
                            "type": "int"
                        }
                    }
                },
                "malware": {
                    "required": False,
                    "type": "dict",
                    "options": {
                        "botnet_connection": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "command_blocked": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "content_disarm": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "mimefragmented": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "oversized": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "switch_proto": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "virus_blocked": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "virus_file_type_executable": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "virus_infected": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "virus_outbreak_prevention": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        },
                        "virus_scan_error": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        }
                    }
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "url_block_detected": {
                    "required": False,
                    "type": "str",
                    "choices":
                    ["disable", "low", "medium", "high", "critical"]
                },
                "web": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "category": {
                            "required": False,
                            "type": "int"
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "level": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices":
                            ["disable", "low", "medium", "high", "critical"]
                        }
                    }
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #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
        },
        "log_fortiguard_override_setting": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "override": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "upload_day": {
                    "required": False,
                    "type": "str"
                },
                "upload_interval": {
                    "required": False,
                    "type": "str",
                    "choices": ["daily", "weekly", "monthly"]
                },
                "upload_option": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices":
                    ["store-and-upload", "realtime", "1-minute", "5-minute"]
                },
                "upload_time": {
                    "required": False,
                    "type": "str"
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #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},
        "router_isis": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "adjacency_check": {"required": False, "type": "str",
                                    "choices": ["enable", "disable"]},
                "adjacency_check6": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "adv_passive_only": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "adv_passive_only6": {"required": False, "type": "str",
                                      "choices": ["enable", "disable"]},
                "auth_keychain_l1": {"required": False, "type": "str"},
                "auth_keychain_l2": {"required": False, "type": "str"},
                "auth_mode_l1": {"required": False, "type": "str",
                                 "choices": ["password", "md5"]},
                "auth_mode_l2": {"required": False, "type": "str",
                                 "choices": ["password", "md5"]},
                "auth_password_l1": {"required": False, "type": "str"},
                "auth_password_l2": {"required": False, "type": "str"},
                "auth_sendonly_l1": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "auth_sendonly_l2": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "default_originate": {"required": False, "type": "str",
                                      "choices": ["enable", "disable"]},
                "default_originate6": {"required": False, "type": "str",
                                       "choices": ["enable", "disable"]},
                "dynamic_hostname": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "ignore_lsp_errors": {"required": False, "type": "str",
                                      "choices": ["enable", "disable"]},
                "is_type": {"required": False, "type": "str",
                            "choices": ["level-1-2", "level-1", "level-2-only"]},
                "isis_interface": {"required": False, "type": "list",
                                   "options": {
                                       "auth_keychain_l1": {"required": False, "type": "str"},
                                       "auth_keychain_l2": {"required": False, "type": "str"},
                                       "auth_mode_l1": {"required": False, "type": "str",
                                                        "choices": ["md5", "password"]},
                                       "auth_mode_l2": {"required": False, "type": "str",
                                                        "choices": ["md5", "password"]},
                                       "auth_password_l1": {"required": False, "type": "str"},
                                       "auth_password_l2": {"required": False, "type": "str"},
                                       "auth_send_only_l1": {"required": False, "type": "str",
                                                             "choices": ["enable", "disable"]},
                                       "auth_send_only_l2": {"required": False, "type": "str",
                                                             "choices": ["enable", "disable"]},
                                       "circuit_type": {"required": False, "type": "str",
                                                        "choices": ["level-1-2", "level-1", "level-2"]},
                                       "csnp_interval_l1": {"required": False, "type": "int"},
                                       "csnp_interval_l2": {"required": False, "type": "int"},
                                       "hello_interval_l1": {"required": False, "type": "int"},
                                       "hello_interval_l2": {"required": False, "type": "int"},
                                       "hello_multiplier_l1": {"required": False, "type": "int"},
                                       "hello_multiplier_l2": {"required": False, "type": "int"},
                                       "hello_padding": {"required": False, "type": "str",
                                                         "choices": ["enable", "disable"]},
                                       "lsp_interval": {"required": False, "type": "int"},
                                       "lsp_retransmit_interval": {"required": False, "type": "int"},
                                       "mesh_group": {"required": False, "type": "str",
                                                      "choices": ["enable", "disable"]},
                                       "mesh_group_id": {"required": False, "type": "int"},
                                       "metric_l1": {"required": False, "type": "int"},
                                       "metric_l2": {"required": False, "type": "int"},
                                       "name": {"required": True, "type": "str"},
                                       "network_type": {"required": False, "type": "str",
                                                        "choices": ["broadcast", "point-to-point", "loopback"]},
                                       "priority_l1": {"required": False, "type": "int"},
                                       "priority_l2": {"required": False, "type": "int"},
                                       "status": {"required": False, "type": "str",
                                                  "choices": ["enable", "disable"]},
                                       "status6": {"required": False, "type": "str",
                                                   "choices": ["enable", "disable"]},
                                       "wide_metric_l1": {"required": False, "type": "int"},
                                       "wide_metric_l2": {"required": False, "type": "int"}
                                   }},
                "isis_net": {"required": False, "type": "list",
                             "options": {
                                 "id": {"required": True, "type": "int"},
                                 "net": {"required": False, "type": "str"}
                             }},
                "lsp_gen_interval_l1": {"required": False, "type": "int"},
                "lsp_gen_interval_l2": {"required": False, "type": "int"},
                "lsp_refresh_interval": {"required": False, "type": "int"},
                "max_lsp_lifetime": {"required": False, "type": "int"},
                "metric_style": {"required": False, "type": "str",
                                 "choices": ["narrow", "wide", "transition",
                                             "narrow-transition", "narrow-transition-l1", "narrow-transition-l2",
                                             "wide-l1", "wide-l2", "wide-transition",
                                             "wide-transition-l1", "wide-transition-l2", "transition-l1",
                                             "transition-l2"]},
                "overload_bit": {"required": False, "type": "str",
                                 "choices": ["enable", "disable"]},
                "overload_bit_on_startup": {"required": False, "type": "int"},
                "overload_bit_suppress": {"required": False, "type": "str",
                                          "choices": ["external", "interlevel"]},
                "redistribute": {"required": False, "type": "list",
                                 "options": {
                                     "level": {"required": False, "type": "str",
                                               "choices": ["level-1-2", "level-1", "level-2"]},
                                     "metric": {"required": False, "type": "int"},
                                     "metric_type": {"required": False, "type": "str",
                                                     "choices": ["external", "internal"]},
                                     "protocol": {"required": True, "type": "str"},
                                     "routemap": {"required": False, "type": "str"},
                                     "status": {"required": False, "type": "str",
                                                "choices": ["enable", "disable"]}
                                 }},
                "redistribute_l1": {"required": False, "type": "str",
                                    "choices": ["enable", "disable"]},
                "redistribute_l1_list": {"required": False, "type": "str"},
                "redistribute_l2": {"required": False, "type": "str",
                                    "choices": ["enable", "disable"]},
                "redistribute_l2_list": {"required": False, "type": "str"},
                "redistribute6": {"required": False, "type": "list",
                                  "options": {
                                      "level": {"required": False, "type": "str",
                                                "choices": ["level-1-2", "level-1", "level-2"]},
                                      "metric": {"required": False, "type": "int"},
                                      "metric_type": {"required": False, "type": "str",
                                                      "choices": ["external", "internal"]},
                                      "protocol": {"required": True, "type": "str"},
                                      "routemap": {"required": False, "type": "str"},
                                      "status": {"required": False, "type": "str",
                                                 "choices": ["enable", "disable"]}
                                  }},
                "redistribute6_l1": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "redistribute6_l1_list": {"required": False, "type": "str"},
                "redistribute6_l2": {"required": False, "type": "str",
                                     "choices": ["enable", "disable"]},
                "redistribute6_l2_list": {"required": False, "type": "str"},
                "spf_interval_exp_l1": {"required": False, "type": "str"},
                "spf_interval_exp_l2": {"required": False, "type": "str"},
                "summary_address": {"required": False, "type": "list",
                                    "options": {
                                        "id": {"required": True, "type": "int"},
                                        "level": {"required": False, "type": "str",
                                                  "choices": ["level-1-2", "level-1", "level-2"]},
                                        "prefix": {"required": False, "type": "str"}
                                    }},
                "summary_address6": {"required": False, "type": "list",
                                     "options": {
                                         "id": {"required": True, "type": "int"},
                                         "level": {"required": False, "type": "str",
                                                   "choices": ["level-1-2", "level-1", "level-2"]},
                                         "prefix6": {"required": False, "type": "str"}
                                     }}

            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
コード例 #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
        },
        "system_management_tunnel": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "allow_collect_statistics": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "allow_config_restore": {
                    "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"]
                },
                "authorized_manager_only": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "serial_number": {
                    "required": False,
                    "type": "str"
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                }
            }
        }
    }

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

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

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

            is_error, has_changed, result = fortios_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)
コード例 #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"]
        },
        "web_proxy_profile": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "header_client_ip": {
                    "required": False,
                    "type": "str",
                    "choices": ["pass", "add", "remove"]
                },
                "header_front_end_https": {
                    "required": False,
                    "type": "str",
                    "choices": ["pass", "add", "remove"]
                },
                "header_via_request": {
                    "required": False,
                    "type": "str",
                    "choices": ["pass", "add", "remove"]
                },
                "header_via_response": {
                    "required": False,
                    "type": "str",
                    "choices": ["pass", "add", "remove"]
                },
                "header_x_authenticated_groups": {
                    "required": False,
                    "type": "str",
                    "choices": ["pass", "add", "remove"]
                },
                "header_x_authenticated_user": {
                    "required": False,
                    "type": "str",
                    "choices": ["pass", "add", "remove"]
                },
                "header_x_forwarded_for": {
                    "required": False,
                    "type": "str",
                    "choices": ["pass", "add", "remove"]
                },
                "headers": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "action": {
                            "required":
                            False,
                            "type":
                            "str",
                            "choices": [
                                "add-to-request", "add-to-response",
                                "remove-from-request", "remove-from-response"
                            ]
                        },
                        "content": {
                            "required": False,
                            "type": "str"
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "name": {
                            "required": False,
                            "type": "str"
                        }
                    }
                },
                "log_header_change": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "strip_encoding": {
                    "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_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)
コード例 #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},
        "router_multicast6": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "interface": {"required": False, "type": "list",
                              "options": {
                                  "hello_holdtime": {"required": False, "type": "int"},
                                  "hello_interval": {"required": False, "type": "int"},
                                  "name": {"required": True, "type": "str"}
                              }},
                "multicast_pmtu": {"required": False, "type": "str",
                                   "choices": ["enable", "disable"]},
                "multicast_routing": {"required": False, "type": "str",
                                      "choices": ["enable", "disable"]},
                "pim_sm_global": {"required": False, "type": "dict",
                                  "options": {
                                      "register_rate_limit": {"required": False, "type": "int"},
                                      "rp_address": {"required": False, "type": "list",
                                                     "options": {
                                                         "id": {"required": True, "type": "int"},
                                                         "ip6_address": {"required": False, "type": "str"}
                                                     }}
                                  }}

            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
try:
    from ansible_collections.notmintest.not_a_real_collection.plugins.modules import fortios_system_dns_database
except ImportError:
    pytest.skip("Could not load required modules for testing",
                allow_module_level=True)


@pytest.fixture(autouse=True)
def connection_mock(mocker):
    connection_class_mock = mocker.patch(
        'ansible_collections.notmintest.not_a_real_collection.plugins.modules.fortios_system_dns_database.Connection'
    )
    return connection_class_mock


fos_instance = FortiOSHandler(connection_mock)


def test_system_dns_database_creation(mocker):
    schema_method_mock = mocker.patch(
        'ansible_collections.notmintest.not_a_real_collection.plugins.module_utils.network.fortios.fortios.FortiOSHandler.schema'
    )

    set_method_result = {
        'status': 'success',
        'http_method': 'POST',
        'http_status': 200
    }
    set_method_mock = mocker.patch(
        'ansible_collections.notmintest.not_a_real_collection.plugins.module_utils.network.fortios.fortios.FortiOSHandler.set',
        return_value=set_method_result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "log_fortianalyzer_override_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"
                },
                "override": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "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"
                },
                "use_management_vdom": {
                    "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)
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_alarm": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "audible": {"required": False, "type": "str",
                            "choices": ["enable", "disable"]},
                "groups": {"required": False, "type": "list",
                           "options": {
                               "admin_auth_failure_threshold": {"required": False, "type": "int"},
                               "admin_auth_lockout_threshold": {"required": False, "type": "int"},
                               "decryption_failure_threshold": {"required": False, "type": "int"},
                               "encryption_failure_threshold": {"required": False, "type": "int"},
                               "fw_policy_id": {"required": False, "type": "int"},
                               "fw_policy_id_threshold": {"required": False, "type": "int"},
                               "fw_policy_violations": {"required": False, "type": "list",
                                                        "options": {
                                                            "dst_ip": {"required": False, "type": "str"},
                                                            "dst_port": {"required": False, "type": "int"},
                                                            "id": {"required": True, "type": "int"},
                                                            "src_ip": {"required": False, "type": "str"},
                                                            "src_port": {"required": False, "type": "int"},
                                                            "threshold": {"required": False, "type": "int"}
                                                        }},
                               "id": {"required": True, "type": "int"},
                               "log_full_warning_threshold": {"required": False, "type": "int"},
                               "period": {"required": False, "type": "int"},
                               "replay_attempt_threshold": {"required": False, "type": "int"},
                               "self_test_failure_threshold": {"required": False, "type": "int"},
                               "user_auth_failure_threshold": {"required": False, "type": "int"},
                               "user_auth_lockout_threshold": {"required": False, "type": "int"}
                           }},
                "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)
コード例 #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"]
        },
        "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)
コード例 #29
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_wccp": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "assignment_bucket_format": {
                    "required": False,
                    "type": "str",
                    "choices": ["wccp-v2", "cisco-implementation"]
                },
                "assignment_dstaddr_mask": {
                    "required": False,
                    "type": "str"
                },
                "assignment_method": {
                    "required": False,
                    "type": "str",
                    "choices": ["HASH", "MASK", "any"]
                },
                "assignment_srcaddr_mask": {
                    "required": False,
                    "type": "str"
                },
                "assignment_weight": {
                    "required": False,
                    "type": "int"
                },
                "authentication": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "cache_engine_method": {
                    "required": False,
                    "type": "str",
                    "choices": ["GRE", "L2"]
                },
                "cache_id": {
                    "required": False,
                    "type": "str"
                },
                "forward_method": {
                    "required": False,
                    "type": "str",
                    "choices": ["GRE", "L2", "any"]
                },
                "group_address": {
                    "required": False,
                    "type": "str"
                },
                "password": {
                    "required": False,
                    "type": "str"
                },
                "ports": {
                    "required": False,
                    "type": "str"
                },
                "ports_defined": {
                    "required": False,
                    "type": "str",
                    "choices": ["source", "destination"]
                },
                "primary_hash": {
                    "required": False,
                    "type": "str",
                    "choices": ["src-ip", "dst-ip", "src-port", "dst-port"]
                },
                "priority": {
                    "required": False,
                    "type": "int"
                },
                "protocol": {
                    "required": False,
                    "type": "int"
                },
                "return_method": {
                    "required": False,
                    "type": "str",
                    "choices": ["GRE", "L2", "any"]
                },
                "router_id": {
                    "required": False,
                    "type": "str"
                },
                "router_list": {
                    "required": False,
                    "type": "str"
                },
                "server_list": {
                    "required": False,
                    "type": "str"
                },
                "server_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["forward", "proxy"]
                },
                "service_id": {
                    "required": False,
                    "type": "str"
                },
                "service_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["auto", "standard", "dynamic"]
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "log_eventfilter": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "compliance_check": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "endpoint": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "event": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "ha": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "router": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "security_rating": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "system": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "user": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "vpn": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "wan_opt": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "wireless_activity": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)