| 1 |
|
| 2 |
from __future__ import absolute_import, division, print_function |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
__metaclass__ = type |
| 7 |
|
| 8 |
ANSIBLE_METADATA = {'status': ['preview'], |
| 9 |
'supported_by': 'community', |
| 10 |
'metadata_version': '1.1'} |
| 11 |
|
| 12 |
DOCUMENTATION = ''' |
| 13 |
--- |
| 14 |
module: fmgr_fmupdate_service |
| 15 |
short_description: Enable/disable services provided by the built-in FortiGuard. |
| 16 |
version_added: "2.0.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.partial_crud |
| 20 |
options: |
| 21 |
fmupdate_service: |
| 22 |
description: The top level parameters set. |
| 23 |
required: false |
| 24 |
type: dict |
| 25 |
suboptions: |
| 26 |
avips: |
| 27 |
type: str |
| 28 |
description: |
| 29 |
- Enable/disable the built-in FortiGuard to provide FortiGuard antivirus and IPS updates |
| 30 |
- disable - Disable setting. |
| 31 |
- enable - Enable setting. |
| 32 |
choices: ['disable', 'enable'] |
| 33 |
query_antispam: |
| 34 |
aliases: ['query-antispam'] |
| 35 |
type: str |
| 36 |
description: |
| 37 |
- Enable/disable antispam service |
| 38 |
- disable - Disable setting. |
| 39 |
- enable - Enable setting. |
| 40 |
choices: ['disable', 'enable'] |
| 41 |
query_antivirus: |
| 42 |
aliases: ['query-antivirus'] |
| 43 |
type: str |
| 44 |
description: |
| 45 |
- Enable/disable antivirus query service |
| 46 |
- disable - Disable setting. |
| 47 |
- enable - Enable setting. |
| 48 |
choices: ['disable', 'enable'] |
| 49 |
query_filequery: |
| 50 |
aliases: ['query-filequery'] |
| 51 |
type: str |
| 52 |
description: |
| 53 |
- Enable/disable file query service |
| 54 |
- disable - Disable setting. |
| 55 |
- enable - Enable setting. |
| 56 |
choices: ['disable', 'enable'] |
| 57 |
query_geoip: |
| 58 |
aliases: ['query-geoip'] |
| 59 |
type: str |
| 60 |
description: |
| 61 |
- Enable/disable geoip service |
| 62 |
- disable - Disable setting. |
| 63 |
- enable - Enable setting. |
| 64 |
choices: ['disable', 'enable'] |
| 65 |
query_outbreak_prevention: |
| 66 |
aliases: ['query-outbreak-prevention'] |
| 67 |
type: str |
| 68 |
description: |
| 69 |
- Enable/disable outbreak prevention query service |
| 70 |
- disable - Disable setting. |
| 71 |
- enable - Enable setting. |
| 72 |
choices: ['disable', 'enable'] |
| 73 |
query_webfilter: |
| 74 |
aliases: ['query-webfilter'] |
| 75 |
type: str |
| 76 |
description: |
| 77 |
- Enable/disable Web Filter service |
| 78 |
- disable - Disable setting. |
| 79 |
- enable - Enable setting. |
| 80 |
choices: ['disable', 'enable'] |
| 81 |
webfilter_https_traversal: |
| 82 |
aliases: ['webfilter-https-traversal'] |
| 83 |
type: str |
| 84 |
description: |
| 85 |
- Enable/disable Web Filter HTTPS traversal |
| 86 |
- disable - Disable setting. |
| 87 |
- enable - Enable setting. |
| 88 |
choices: ['disable', 'enable'] |
| 89 |
query_iot: |
| 90 |
aliases: ['query-iot'] |
| 91 |
type: str |
| 92 |
description: |
| 93 |
- Enable/disable file query service |
| 94 |
- disable - Disable setting. |
| 95 |
- enable - Enable setting. |
| 96 |
choices: ['disable', 'enable'] |
| 97 |
query_iot_collection: |
| 98 |
aliases: ['query-iot-collection'] |
| 99 |
type: str |
| 100 |
description: |
| 101 |
- Enable/disable IoT Collection Query service |
| 102 |
- disable - Disable setting. |
| 103 |
- enable - Enable setting. |
| 104 |
choices: ['disable', 'enable'] |
| 105 |
query_iot_vulnerability: |
| 106 |
aliases: ['query-iot-vulnerability'] |
| 107 |
type: str |
| 108 |
description: |
| 109 |
- Enable/disable IoT Vulnerability Query service |
| 110 |
- disable - Disable setting. |
| 111 |
- enable - Enable setting. |
| 112 |
choices: ['disable', 'enable'] |
| 113 |
query_ioc: |
| 114 |
aliases: ['query-ioc'] |
| 115 |
type: str |
| 116 |
description: |
| 117 |
- Enable/disable the built-in FortiGuard to provide IoC query |
| 118 |
- disable - Disable setting. |
| 119 |
- enable - Enable setting. |
| 120 |
choices: ['disable', 'enable'] |
| 121 |
''' |
| 122 |
|
| 123 |
EXAMPLES = ''' |
| 124 |
- name: Example playbook (generated based on argument schema) |
| 125 |
hosts: fortimanagers |
| 126 |
connection: httpapi |
| 127 |
gather_facts: false |
| 128 |
tasks: |
| 129 |
- name: Enable/disable services provided by the built-in FortiGuard. |
| 130 |
fortinet.fortimanager.fmgr_fmupdate_service: |
| 131 |
# workspace_locking_adom: <global or your adom name> |
| 132 |
fmupdate_service: |
| 133 |
# avips: <value in [disable, enable]> |
| 134 |
# query_antispam: <value in [disable, enable]> |
| 135 |
# query_antivirus: <value in [disable, enable]> |
| 136 |
# query_filequery: <value in [disable, enable]> |
| 137 |
# query_geoip: <value in [disable, enable]> |
| 138 |
# query_outbreak_prevention: <value in [disable, enable]> |
| 139 |
# query_webfilter: <value in [disable, enable]> |
| 140 |
# webfilter_https_traversal: <value in [disable, enable]> |
| 141 |
# query_iot: <value in [disable, enable]> |
| 142 |
# query_iot_collection: <value in [disable, enable]> |
| 143 |
# query_iot_vulnerability: <value in [disable, enable]> |
| 144 |
# query_ioc: <value in [disable, enable]> |
| 145 |
''' |
| 146 |
|
| 147 |
RETURN = ''' |
| 148 |
meta: |
| 149 |
description: The result of the request. |
| 150 |
type: dict |
| 151 |
returned: always |
| 152 |
contains: |
| 153 |
request_url: |
| 154 |
description: The full url requested. |
| 155 |
returned: always |
| 156 |
type: str |
| 157 |
sample: /sys/login/user |
| 158 |
response_code: |
| 159 |
description: The status of api request. |
| 160 |
returned: always |
| 161 |
type: int |
| 162 |
sample: 0 |
| 163 |
response_data: |
| 164 |
description: The api response. |
| 165 |
type: list |
| 166 |
returned: always |
| 167 |
response_message: |
| 168 |
description: The descriptive message of the api response. |
| 169 |
type: str |
| 170 |
returned: always |
| 171 |
sample: OK. |
| 172 |
system_information: |
| 173 |
description: The information of the target system. |
| 174 |
type: dict |
| 175 |
returned: always |
| 176 |
rc: |
| 177 |
description: The status the request. |
| 178 |
type: int |
| 179 |
returned: always |
| 180 |
sample: 0 |
| 181 |
version_check_warning: |
| 182 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 183 |
type: list |
| 184 |
returned: complex |
| 185 |
''' |
| 186 |
from ansible.module_utils.basic import AnsibleModule |
| 187 |
from ansible.module_utils.connection import Connection |
| 188 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 189 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 190 |
|
| 191 |
|
| 192 |
def main(): |
| 193 |
urls_list = [ |
| 194 |
'/cli/global/fmupdate/service' |
| 195 |
] |
| 196 |
module_arg_spec = { |
| 197 |
'fmupdate_service': { |
| 198 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 199 |
'options': { |
| 200 |
'avips': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 201 |
'query-antispam': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 202 |
'query-antivirus': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 203 |
'query-filequery': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 204 |
'query-geoip': {'v_range': [['6.0.0', '6.4.1']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 205 |
'query-outbreak-prevention': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 206 |
'query-webfilter': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 207 |
'webfilter-https-traversal': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 208 |
'query-iot': {'v_range': [['6.4.6', '6.4.15'], ['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 209 |
'query-iot-collection': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 210 |
'query-iot-vulnerability': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 211 |
'query-ioc': {'v_range': [['7.6.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'} |
| 212 |
} |
| 213 |
} |
| 214 |
} |
| 215 |
|
| 216 |
module_option_spec = get_module_arg_spec('partial crud') |
| 217 |
module_arg_spec.update(module_option_spec) |
| 218 |
check_galaxy_version(module_arg_spec) |
| 219 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'fmupdate_service'), |
| 220 |
supports_check_mode=True) |
| 221 |
if not module._socket_path: |
| 222 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 223 |
connection = Connection(module._socket_path) |
| 224 |
fmgr = NAPIManager('partial crud', module_arg_spec, urls_list, |
| 225 |
None, 'data', module, connection) |
| 226 |
fmgr.process_partial_crud() |
| 227 |
module.exit_json(meta=module.params) |
| 228 |
|
| 229 |
|
| 230 |
if __name__ == '__main__': |
| 231 |
main() |