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)
Example #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
        },
        "state": {
            "required": False,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "firewall_DoS_policy": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "anomaly": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "action": {
                            "required": False,
                            "type": "str",
                            "choices": ["pass", "block"]
                        },
                        "log": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "name": {
                            "required": True,
                            "type": "str"
                        },
                        "quarantine": {
                            "required": False,
                            "type": "str",
                            "choices": ["none", "attacker"]
                        },
                        "quarantine_expiry": {
                            "required": False,
                            "type": "str"
                        },
                        "quarantine_log": {
                            "required": False,
                            "type": "str",
                            "choices": ["disable", "enable"]
                        },
                        "status": {
                            "required": False,
                            "type": "str",
                            "choices": ["disable", "enable"]
                        },
                        "threshold": {
                            "required": False,
                            "type": "int"
                        },
                        "threshold(default)": {
                            "required": False,
                            "type": "int"
                        }
                    }
                },
                "comments": {
                    "required": False,
                    "type": "str"
                },
                "dstaddr": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "interface": {
                    "required": False,
                    "type": "str"
                },
                "policyid": {
                    "required": True,
                    "type": "int"
                },
                "service": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "srcaddr": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": True,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "system_replacemsg_alertmail": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "buffer": {
                    "required": False,
                    "type": "str"
                },
                "format": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "text", "html", "wml"]
                },
                "header": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "http", "8bit"]
                },
                "msg_type": {
                    "required": False,
                    "type": "str"
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {"required": False, "type": "str"},
        "username": {"required": False, "type": "str"},
        "password": {"required": False, "type": "str", "default": "", "no_log": True},
        "vdom": {"required": False, "type": "str", "default": "root"},
        "https": {"required": False, "type": "bool", "default": True},
        "ssl_verify": {"required": False, "type": "bool", "default": True},
        "state": {"required": False, "type": "str",
                  "choices": ["present", "absent"]},
        "ips_sensor": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "state": {"required": False, "type": "str",
                          "choices": ["present", "absent"]},
                "block_malicious_url": {"required": False, "type": "str",
                                        "choices": ["disable", "enable"]},
                "comment": {"required": False, "type": "str"},
                "entries": {"required": False, "type": "list",
                            "options": {
                                "action": {"required": False, "type": "str",
                                           "choices": ["pass", "block", "reset",
                                                       "default"]},
                                "application": {"required": False, "type": "str"},
                                "exempt_ip": {"required": False, "type": "list",
                                              "options": {
                                                  "dst_ip": {"required": False, "type": "str"},
                                                  "id": {"required": True, "type": "int"},
                                                  "src_ip": {"required": False, "type": "str"}
                                              }},
                                "id": {"required": True, "type": "int"},
                                "location": {"required": False, "type": "str"},
                                "log": {"required": False, "type": "str",
                                        "choices": ["disable", "enable"]},
                                "log_attack_context": {"required": False, "type": "str",
                                                       "choices": ["disable", "enable"]},
                                "log_packet": {"required": False, "type": "str",
                                               "choices": ["disable", "enable"]},
                                "os": {"required": False, "type": "str"},
                                "protocol": {"required": False, "type": "str"},
                                "quarantine": {"required": False, "type": "str",
                                               "choices": ["none", "attacker"]},
                                "quarantine_expiry": {"required": False, "type": "str"},
                                "quarantine_log": {"required": False, "type": "str",
                                                   "choices": ["disable", "enable"]},
                                "rate_count": {"required": False, "type": "int"},
                                "rate_duration": {"required": False, "type": "int"},
                                "rate_mode": {"required": False, "type": "str",
                                              "choices": ["periodical", "continuous"]},
                                "rate_track": {"required": False, "type": "str",
                                               "choices": ["none", "src-ip", "dest-ip",
                                                           "dhcp-client-mac", "dns-domain"]},
                                "rule": {"required": False, "type": "list",
                                         "options": {
                                             "id": {"required": True, "type": "int"}
                                         }},
                                "severity": {"required": False, "type": "str"},
                                "status": {"required": False, "type": "str",
                                           "choices": ["disable", "enable", "default"]}
                            }},
                "extended_log": {"required": False, "type": "str",
                                 "choices": ["enable", "disable"]},
                "filter": {"required": False, "type": "list",
                           "options": {
                               "action": {"required": False, "type": "str",
                                          "choices": ["pass", "block", "reset",
                                                      "default"]},
                               "application": {"required": False, "type": "str"},
                               "location": {"required": False, "type": "str"},
                               "log": {"required": False, "type": "str",
                                       "choices": ["disable", "enable"]},
                               "log_packet": {"required": False, "type": "str",
                                              "choices": ["disable", "enable"]},
                               "name": {"required": True, "type": "str"},
                               "os": {"required": False, "type": "str"},
                               "protocol": {"required": False, "type": "str"},
                               "quarantine": {"required": False, "type": "str",
                                              "choices": ["none", "attacker"]},
                               "quarantine_expiry": {"required": False, "type": "int"},
                               "quarantine_log": {"required": False, "type": "str",
                                                  "choices": ["disable", "enable"]},
                               "severity": {"required": False, "type": "str"},
                               "status": {"required": False, "type": "str",
                                          "choices": ["disable", "enable", "default"]}
                           }},
                "name": {"required": True, "type": "str"},
                "override": {"required": False, "type": "list",
                             "options": {
                                 "action": {"required": False, "type": "str",
                                            "choices": ["pass", "block", "reset"]},
                                 "exempt_ip": {"required": False, "type": "list",
                                               "options": {
                                                   "dst_ip": {"required": False, "type": "str"},
                                                   "id": {"required": True, "type": "int"},
                                                   "src_ip": {"required": False, "type": "str"}
                                               }},
                                 "log": {"required": False, "type": "str",
                                         "choices": ["disable", "enable"]},
                                 "log_packet": {"required": False, "type": "str",
                                                "choices": ["disable", "enable"]},
                                 "quarantine": {"required": False, "type": "str",
                                                "choices": ["none", "attacker"]},
                                 "quarantine_expiry": {"required": False, "type": "int"},
                                 "quarantine_log": {"required": False, "type": "str",
                                                    "choices": ["disable", "enable"]},
                                 "rule_id": {"required": False, "type": "int"},
                                 "status": {"required": False, "type": "str",
                                            "choices": ["disable", "enable"]}
                             }},
                "replacemsg_group": {"required": False, "type": "str"}

            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
Example #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
        },
        "state": {
            "required": False,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "router_access_list": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "comments": {
                    "required": False,
                    "type": "str"
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "rule": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "action": {
                            "required": False,
                            "type": "str",
                            "choices": ["permit", "deny"]
                        },
                        "exact_match": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        },
                        "flags": {
                            "required": False,
                            "type": "int"
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "prefix": {
                            "required": False,
                            "type": "str"
                        },
                        "wildcard": {
                            "required": False,
                            "type": "str"
                        }
                    }
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "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)
Example #7
0
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "firewall_ssl_setting": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "abbreviate_handshake": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "cert_cache_capacity": {
                    "required": False,
                    "type": "int"
                },
                "cert_cache_timeout": {
                    "required": False,
                    "type": "int"
                },
                "kxp_queue_threshold": {
                    "required": False,
                    "type": "int"
                },
                "no_matching_cipher_action": {
                    "required": False,
                    "type": "str",
                    "choices": ["bypass", "drop"]
                },
                "proxy_connect_timeout": {
                    "required": False,
                    "type": "int"
                },
                "session_cache_capacity": {
                    "required": False,
                    "type": "int"
                },
                "session_cache_timeout": {
                    "required": False,
                    "type": "int"
                },
                "ssl_dh_bits": {
                    "required": False,
                    "type": "str",
                    "choices": ["768", "1024", "1536", "2048"]
                },
                "ssl_queue_threshold": {
                    "required": False,
                    "type": "int"
                },
                "ssl_send_empty_frags": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {"required": False, "type": "str"},
        "username": {"required": False, "type": "str"},
        "password": {"required": False, "type": "str", "default": "", "no_log": True},
        "vdom": {"required": False, "type": "str", "default": "root"},
        "https": {"required": False, "type": "bool", "default": True},
        "ssl_verify": {"required": False, "type": "bool", "default": True},
        "state": {"required": False, "type": "str",
                  "choices": ["present", "absent"]},
        "firewall_policy46": {
            "required": False, "type": "dict", "default": None,
            "options": {
                "state": {"required": False, "type": "str",
                          "choices": ["present", "absent"]},
                "action": {"required": False, "type": "str",
                           "choices": ["accept", "deny"]},
                "comments": {"required": False, "type": "str"},
                "dstaddr": {"required": False, "type": "list",
                            "options": {
                                "name": {"required": True, "type": "str"}
                            }},
                "dstintf": {"required": False, "type": "str"},
                "fixedport": {"required": False, "type": "str",
                              "choices": ["enable", "disable"]},
                "ippool": {"required": False, "type": "str",
                           "choices": ["enable", "disable"]},
                "logtraffic": {"required": False, "type": "str",
                               "choices": ["enable", "disable"]},
                "per_ip_shaper": {"required": False, "type": "str"},
                "permit_any_host": {"required": False, "type": "str",
                                    "choices": ["enable", "disable"]},
                "policyid": {"required": True, "type": "int"},
                "poolname": {"required": False, "type": "list",
                             "options": {
                                 "name": {"required": True, "type": "str"}
                             }},
                "schedule": {"required": False, "type": "str"},
                "service": {"required": False, "type": "list",
                            "options": {
                                "name": {"required": True, "type": "str"}
                            }},
                "srcaddr": {"required": False, "type": "list",
                            "options": {
                                "name": {"required": True, "type": "str"}
                            }},
                "srcintf": {"required": False, "type": "str"},
                "status": {"required": False, "type": "str",
                           "choices": ["enable", "disable"]},
                "tcp_mss_receiver": {"required": False, "type": "int"},
                "tcp_mss_sender": {"required": False, "type": "int"},
                "traffic_shaper": {"required": False, "type": "str"},
                "traffic_shaper_reverse": {"required": False, "type": "str"},
                "uuid": {"required": False, "type": "str"}

            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
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)
Example #10
0
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": False,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "dlp_fp_doc_source": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "date": {
                    "required": False,
                    "type": "int"
                },
                "file_path": {
                    "required": False,
                    "type": "str"
                },
                "file_pattern": {
                    "required": False,
                    "type": "str"
                },
                "keep_modified": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "password": {
                    "required": False,
                    "type": "str"
                },
                "period": {
                    "required": False,
                    "type": "str",
                    "choices": ["none", "daily", "weekly", "monthly"]
                },
                "remove_deleted": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "scan_on_creation": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "scan_subdirectories": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "sensitivity": {
                    "required": False,
                    "type": "str"
                },
                "server": {
                    "required": False,
                    "type": "str"
                },
                "server_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["samba"]
                },
                "tod_hour": {
                    "required": False,
                    "type": "int"
                },
                "tod_min": {
                    "required": False,
                    "type": "int"
                },
                "username": {
                    "required": False,
                    "type": "str"
                },
                "vdom": {
                    "required": False,
                    "type": "str",
                    "choices": ["mgmt", "current"]
                },
                "weekday": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "sunday", "monday", "tuesday", "wednesday", "thursday",
                        "friday", "saturday"
                    ]
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": False,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "firewall_interface_policy": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "address_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["ipv4", "ipv6"]
                },
                "application_list": {
                    "required": False,
                    "type": "str"
                },
                "application_list_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "av_profile": {
                    "required": False,
                    "type": "str"
                },
                "av_profile_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "comments": {
                    "required": False,
                    "type": "str"
                },
                "dlp_sensor": {
                    "required": False,
                    "type": "str"
                },
                "dlp_sensor_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "dsri": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "dstaddr": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "interface": {
                    "required": False,
                    "type": "str"
                },
                "ips_sensor": {
                    "required": False,
                    "type": "str"
                },
                "ips_sensor_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "label": {
                    "required": False,
                    "type": "str"
                },
                "logtraffic": {
                    "required": False,
                    "type": "str",
                    "choices": ["all", "utm", "disable"]
                },
                "policyid": {
                    "required": True,
                    "type": "int"
                },
                "scan_botnet_connections": {
                    "required": False,
                    "type": "str",
                    "choices": ["disable", "block", "monitor"]
                },
                "service": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "spamfilter_profile": {
                    "required": False,
                    "type": "str"
                },
                "spamfilter_profile_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "srcaddr": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "webfilter_profile": {
                    "required": False,
                    "type": "str"
                },
                "webfilter_profile_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "system_password_policy": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "apply_to": {
                    "required": False,
                    "type": "str",
                    "choices": ["admin-password", "ipsec-preshared-key"]
                },
                "change_4_characters": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "expire_day": {
                    "required": False,
                    "type": "int"
                },
                "expire_status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "min_lower_case_letter": {
                    "required": False,
                    "type": "int"
                },
                "min_non_alphanumeric": {
                    "required": False,
                    "type": "int"
                },
                "min_number": {
                    "required": False,
                    "type": "int"
                },
                "min_upper_case_letter": {
                    "required": False,
                    "type": "int"
                },
                "minimum_length": {
                    "required": False,
                    "type": "int"
                },
                "reuse_password": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": False,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "user_tacacsplus": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "authen_type": {
                    "required": False,
                    "type": "str",
                    "choices": ["mschap", "chap", "pap", "ascii", "auto"]
                },
                "authorization": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "key": {
                    "required": False,
                    "type": "str"
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "port": {
                    "required": False,
                    "type": "int"
                },
                "secondary_key": {
                    "required": False,
                    "type": "str"
                },
                "secondary_server": {
                    "required": False,
                    "type": "str"
                },
                "server": {
                    "required": False,
                    "type": "str"
                },
                "source_ip": {
                    "required": False,
                    "type": "str"
                },
                "tertiary_key": {
                    "required": False,
                    "type": "str"
                },
                "tertiary_server": {
                    "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_user(module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "router_ripng": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "aggregate_address": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "prefix6": {
                            "required": False,
                            "type": "str"
                        }
                    }
                },
                "default_information_originate": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "default_metric": {
                    "required": False,
                    "type": "int"
                },
                "distance": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "access_list6": {
                            "required": False,
                            "type": "str"
                        },
                        "distance": {
                            "required": False,
                            "type": "int"
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "prefix6": {
                            "required": False,
                            "type": "str"
                        }
                    }
                },
                "distribute_list": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "direction": {
                            "required": False,
                            "type": "str",
                            "choices": ["in", "out"]
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "interface": {
                            "required": False,
                            "type": "str"
                        },
                        "listname": {
                            "required": False,
                            "type": "str"
                        },
                        "status": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        }
                    }
                },
                "garbage_timer": {
                    "required": False,
                    "type": "int"
                },
                "interface": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "flags": {
                            "required": False,
                            "type": "int"
                        },
                        "name": {
                            "required": True,
                            "type": "str"
                        },
                        "split_horizon": {
                            "required": False,
                            "type": "str",
                            "choices": ["poisoned", "regular"]
                        },
                        "split_horizon_status": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        }
                    }
                },
                "max_out_metric": {
                    "required": False,
                    "type": "int"
                },
                "neighbor": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "interface": {
                            "required": False,
                            "type": "str"
                        },
                        "ip6": {
                            "required": False,
                            "type": "str"
                        }
                    }
                },
                "network": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "prefix": {
                            "required": False,
                            "type": "str"
                        }
                    }
                },
                "offset_list": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "access_list6": {
                            "required": False,
                            "type": "str"
                        },
                        "direction": {
                            "required": False,
                            "type": "str",
                            "choices": ["in", "out"]
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "interface": {
                            "required": False,
                            "type": "str"
                        },
                        "offset": {
                            "required": False,
                            "type": "int"
                        },
                        "status": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        }
                    }
                },
                "passive_interface": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "name": {
                            "required": True,
                            "type": "str"
                        }
                    }
                },
                "redistribute": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "metric": {
                            "required": False,
                            "type": "int"
                        },
                        "name": {
                            "required": True,
                            "type": "str"
                        },
                        "routemap": {
                            "required": False,
                            "type": "str"
                        },
                        "status": {
                            "required": False,
                            "type": "str",
                            "choices": ["enable", "disable"]
                        }
                    }
                },
                "timeout_timer": {
                    "required": False,
                    "type": "int"
                },
                "update_timer": {
                    "required": False,
                    "type": "int"
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
Example #15
0
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "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)
Example #16
0
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "log_memory_filter": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "admin": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "anomaly": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "auth": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "cpu_memory_usage": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "dhcp": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "dns": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "event": {
                    "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"]
                },
                "ha": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "ipsec": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "ldb_monitor": {
                    "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"
                },
                "pattern": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "ppp": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "radius": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "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"]
                },
                "sslvpn_log_adm": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "sslvpn_log_auth": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "sslvpn_log_session": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "system": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "vip_ssl": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "voip": {
                    "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_memory(
                module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "log_syslogd3_setting": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "certificate": {
                    "required": False,
                    "type": "str"
                },
                "custom_field_name": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "custom": {
                            "required": False,
                            "type": "str"
                        },
                        "id": {
                            "required": True,
                            "type": "int"
                        },
                        "name": {
                            "required": False,
                            "type": "str"
                        }
                    }
                },
                "enc_algorithm": {
                    "required": False,
                    "type": "str",
                    "choices": ["high-medium", "high", "low", "disable"]
                },
                "facility": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "kernel", "user", "mail", "daemon", "auth", "syslog",
                        "lpr", "news", "uucp", "cron", "authpriv", "ftp",
                        "ntp", "audit", "alert", "clock", "local0", "local1",
                        "local2", "local3", "local4", "local5", "local6",
                        "local7"
                    ]
                },
                "format": {
                    "required": False,
                    "type": "str",
                    "choices": ["default", "csv", "cef"]
                },
                "mode": {
                    "required": False,
                    "type": "str",
                    "choices": ["udp", "legacy-reliable", "reliable"]
                },
                "port": {
                    "required": False,
                    "type": "int"
                },
                "server": {
                    "required": False,
                    "type": "str"
                },
                "source_ip": {
                    "required": False,
                    "type": "str"
                },
                "ssl_min_proto_version": {
                    "required": False,
                    "type": "str",
                    "choices":
                    ["default", "SSLv3", "TLSv1", "TLSv1-1", "TLSv1-2"]
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                }
            }
        }
    }

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

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

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

            is_error, has_changed, result = fortios_log_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)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "system_netflow": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "active_flow_timeout": {
                    "required": False,
                    "type": "int"
                },
                "collector_ip": {
                    "required": False,
                    "type": "str"
                },
                "collector_port": {
                    "required": False,
                    "type": "int"
                },
                "inactive_flow_timeout": {
                    "required": False,
                    "type": "int"
                },
                "source_ip": {
                    "required": False,
                    "type": "str"
                },
                "template_tx_counter": {
                    "required": False,
                    "type": "int"
                },
                "template_tx_timeout": {
                    "required": False,
                    "type": "int"
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
Example #19
0
def main():
    fields = {
        "host": {"required": False, "type": "str"},
        "username": {"required": False, "type": "str"},
        "password": {"required": False, "type": "str", "default": "", "no_log": True},
        "vdom": {"required": False, "type": "str", "default": "root"},
        "https": {"required": False, "type": "bool", "default": True},
        "ssl_verify": {"required": False, "type": "bool", "default": True},
        "system_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)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": False,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "firewall_shaper_per_ip_shaper": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "state": {
                    "required": False,
                    "type": "str",
                    "choices": ["present", "absent"]
                },
                "bandwidth_unit": {
                    "required": False,
                    "type": "str",
                    "choices": ["kbps", "mbps", "gbps"]
                },
                "diffserv_forward": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "diffserv_reverse": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "diffservcode_forward": {
                    "required": False,
                    "type": "str"
                },
                "diffservcode_rev": {
                    "required": False,
                    "type": "str"
                },
                "max_bandwidth": {
                    "required": False,
                    "type": "int"
                },
                "max_concurrent_session": {
                    "required": False,
                    "type": "int"
                },
                "name": {
                    "required": True,
                    "type": "str"
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
Example #21
0
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": True,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "system_switch_interface": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "intra_switch_policy": {
                    "required": False,
                    "type": "str",
                    "choices": ["implicit", "explicit"]
                },
                "member": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "interface_name": {
                            "required": False,
                            "type": "str"
                        }
                    }
                },
                "name": {
                    "required": True,
                    "type": "str"
                },
                "span": {
                    "required": False,
                    "type": "str",
                    "choices": ["disable", "enable"]
                },
                "span_dest_port": {
                    "required": False,
                    "type": "str"
                },
                "span_direction": {
                    "required": False,
                    "type": "str",
                    "choices": ["rx", "tx", "both"]
                },
                "span_source_port": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "interface_name": {
                            "required": False,
                            "type": "str"
                        }
                    }
                },
                "type": {
                    "required": False,
                    "type": "str",
                    "choices": ["switch", "hub"]
                },
                "vdom": {
                    "required": False,
                    "type": "str"
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
Example #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},
        "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)
Example #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
        },
        "switch_controller_802_1X_settings": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "link_down_auth": {
                    "required": False,
                    "type": "str",
                    "choices": ["set-unauth", "no-action"]
                },
                "max_reauth_attempt": {
                    "required": False,
                    "type": "int"
                },
                "reauth_period": {
                    "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_switch_controller(
                module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "system_autoupdate_schedule": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "day": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
                        "Friday", "Saturday"
                    ]
                },
                "frequency": {
                    "required": False,
                    "type": "str",
                    "choices": ["every", "daily", "weekly"]
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "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_system_autoupdate(
                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_autoupdate(
            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)
Example #25
0
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "system_fips_cc": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "entropy_token": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable", "dynamic"]
                },
                "key_generation_self_test": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "self_test_period": {
                    "required": False,
                    "type": "int"
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": True,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "user_device": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "alias": {
                    "required": True,
                    "type": "str"
                },
                "avatar": {
                    "required": False,
                    "type": "str"
                },
                "category": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "none", "amazon-device", "android-device",
                        "blackberry-device", "fortinet-device", "ios-device",
                        "windows-device"
                    ]
                },
                "comment": {
                    "required": False,
                    "type": "str"
                },
                "mac": {
                    "required": False,
                    "type": "str"
                },
                "master_device": {
                    "required": False,
                    "type": "str"
                },
                "tagging": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "category": {
                            "required": False,
                            "type": "str"
                        },
                        "name": {
                            "required": True,
                            "type": "str"
                        },
                        "tags": {
                            "required": False,
                            "type": "list",
                            "options": {
                                "name": {
                                    "required": True,
                                    "type": "str"
                                }
                            }
                        }
                    }
                },
                "type": {
                    "required":
                    False,
                    "type":
                    "str",
                    "choices": [
                        "unknown", "android-phone", "android-tablet",
                        "blackberry-phone", "blackberry-playbook", "forticam",
                        "fortifone", "fortinet-device", "gaming-console",
                        "ip-phone", "ipad", "iphone", "linux-pc", "mac",
                        "media-streaming", "printer", "router-nat-device",
                        "windows-pc", "windows-phone", "windows-tablet",
                        "other-network-device"
                    ]
                },
                "user": {
                    "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_user(module.params, fos)
        else:
            module.fail_json(**FAIL_SOCKET_MSG)
    else:
        try:
            from fortiosapi import FortiOSAPI
        except ImportError:
            module.fail_json(msg="fortiosapi module is required")

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": True,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "wireless_controller_hotspot20_icon": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "icon_list": {
                    "required": False,
                    "type": "list",
                    "options": {
                        "file": {
                            "required": False,
                            "type": "str"
                        },
                        "height": {
                            "required": False,
                            "type": "int"
                        },
                        "lang": {
                            "required": False,
                            "type": "str"
                        },
                        "name": {
                            "required": True,
                            "type": "str"
                        },
                        "type": {
                            "required": False,
                            "type": "str",
                            "choices": ["bmp", "gif", "jpeg", "png", "tiff"]
                        },
                        "width": {
                            "required": False,
                            "type": "int"
                        }
                    }
                },
                "name": {
                    "required": True,
                    "type": "str"
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "system_snmp_sysinfo": {
            "required": False,
            "type": "dict",
            "default": None,
            "options": {
                "contact_info": {
                    "required": False,
                    "type": "str"
                },
                "description": {
                    "required": False,
                    "type": "str"
                },
                "engine_id": {
                    "required": False,
                    "type": "str"
                },
                "location": {
                    "required": False,
                    "type": "str"
                },
                "status": {
                    "required": False,
                    "type": "str",
                    "choices": ["enable", "disable"]
                },
                "trap_high_cpu_threshold": {
                    "required": False,
                    "type": "int"
                },
                "trap_log_full_threshold": {
                    "required": False,
                    "type": "int"
                },
                "trap_low_memory_threshold": {
                    "required": False,
                    "type": "int"
                }
            }
        }
    }

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

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

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

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

        fos = FortiOSAPI()

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

    if not is_error:
        module.exit_json(changed=has_changed, meta=result)
    else:
        module.fail_json(msg="Error in repo", meta=result)
from mock import ANY
from ansible_collections.ansible.fortios.plugins.module_utils.network.fortios.fortios import FortiOSHandler

try:
    from ansible_collections.ansible.fortios.plugins.modules import fortios_log_fortiguard_override_setting
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.ansible.fortios.plugins.modules.fortios_log_fortiguard_override_setting.Connection')
    return connection_class_mock


fos_instance = FortiOSHandler(connection_mock)


def test_log_fortiguard_override_setting_creation(mocker):
    schema_method_mock = mocker.patch('ansible_collections.ansible.fortios.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.ansible.fortios.plugins.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)

    input_data = {
        'username': '******',
        'state': 'present',
        'log_fortiguard_override_setting': {
            'override': 'enable',
            'status': 'enable',
            'upload_day': 'test_value_5',
Example #30
0
def main():
    fields = {
        "host": {
            "required": False,
            "type": "str"
        },
        "username": {
            "required": False,
            "type": "str"
        },
        "password": {
            "required": False,
            "type": "str",
            "default": "",
            "no_log": True
        },
        "vdom": {
            "required": False,
            "type": "str",
            "default": "root"
        },
        "https": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "ssl_verify": {
            "required": False,
            "type": "bool",
            "default": True
        },
        "state": {
            "required": False,
            "type": "str",
            "choices": ["present", "absent"]
        },
        "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)