| 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_application_internetservicecustom |
| 15 |
short_description: Configure custom Internet service applications. |
| 16 |
version_added: "2.2.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.full_crud |
| 20 |
options: |
| 21 |
revision_note: |
| 22 |
description: The change note that can be specified when an object is created or updated. |
| 23 |
type: str |
| 24 |
adom: |
| 25 |
description: The parameter (adom) in requested url. |
| 26 |
type: str |
| 27 |
required: true |
| 28 |
application_internetservicecustom: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
comment: |
| 34 |
type: str |
| 35 |
description: Comment. |
| 36 |
disable_entry: |
| 37 |
aliases: ['disable-entry'] |
| 38 |
type: list |
| 39 |
elements: dict |
| 40 |
description: Disable entry. |
| 41 |
suboptions: |
| 42 |
id: |
| 43 |
type: int |
| 44 |
description: Disable entry ID. |
| 45 |
ip_range: |
| 46 |
aliases: ['ip-range'] |
| 47 |
type: list |
| 48 |
elements: dict |
| 49 |
description: Ip range. |
| 50 |
suboptions: |
| 51 |
end_ip: |
| 52 |
aliases: ['end-ip'] |
| 53 |
type: str |
| 54 |
description: End IP address. |
| 55 |
id: |
| 56 |
type: int |
| 57 |
description: Disable entry range ID. |
| 58 |
start_ip: |
| 59 |
aliases: ['start-ip'] |
| 60 |
type: str |
| 61 |
description: Start IP address. |
| 62 |
port: |
| 63 |
type: raw |
| 64 |
description: (list) Port. |
| 65 |
protocol: |
| 66 |
type: int |
| 67 |
description: Protocol number. |
| 68 |
entry: |
| 69 |
type: list |
| 70 |
elements: dict |
| 71 |
description: Entry. |
| 72 |
suboptions: |
| 73 |
dst: |
| 74 |
type: str |
| 75 |
description: Destination address name. |
| 76 |
id: |
| 77 |
type: int |
| 78 |
description: Entry ID |
| 79 |
port_range: |
| 80 |
aliases: ['port-range'] |
| 81 |
type: list |
| 82 |
elements: dict |
| 83 |
description: Port range. |
| 84 |
suboptions: |
| 85 |
end_port: |
| 86 |
aliases: ['end-port'] |
| 87 |
type: int |
| 88 |
description: End destination port number |
| 89 |
id: |
| 90 |
type: int |
| 91 |
description: Custom entry port range ID. |
| 92 |
start_port: |
| 93 |
aliases: ['start-port'] |
| 94 |
type: int |
| 95 |
description: Start destination port number |
| 96 |
protocol: |
| 97 |
type: int |
| 98 |
description: Protocol number. |
| 99 |
master_service_id: |
| 100 |
aliases: ['master-service-id'] |
| 101 |
type: str |
| 102 |
description: Internet service database application ID. |
| 103 |
name: |
| 104 |
type: str |
| 105 |
description: Application name. |
| 106 |
required: true |
| 107 |
''' |
| 108 |
|
| 109 |
EXAMPLES = ''' |
| 110 |
- name: Example playbook (generated based on argument schema) |
| 111 |
hosts: fortimanagers |
| 112 |
connection: httpapi |
| 113 |
gather_facts: false |
| 114 |
tasks: |
| 115 |
- name: Configure custom Internet service applications. |
| 116 |
fortinet.fortimanager.fmgr_application_internetservicecustom: |
| 117 |
# workspace_locking_adom: <global or your adom name> |
| 118 |
adom: <your own value> |
| 119 |
state: present # <value in [present, absent]> |
| 120 |
application_internetservicecustom: |
| 121 |
name: "your value" # Required variable, string |
| 122 |
# comment: <string> |
| 123 |
# disable_entry: |
| 124 |
# - id: <integer> |
| 125 |
# ip_range: |
| 126 |
# - end_ip: <string> |
| 127 |
# id: <integer> |
| 128 |
# start_ip: <string> |
| 129 |
# port: <list or integer> |
| 130 |
# protocol: <integer> |
| 131 |
# entry: |
| 132 |
# - dst: <string> |
| 133 |
# id: <integer> |
| 134 |
# port_range: |
| 135 |
# - end_port: <integer> |
| 136 |
# id: <integer> |
| 137 |
# start_port: <integer> |
| 138 |
# protocol: <integer> |
| 139 |
# master_service_id: <string> |
| 140 |
''' |
| 141 |
|
| 142 |
RETURN = ''' |
| 143 |
meta: |
| 144 |
description: The result of the request. |
| 145 |
type: dict |
| 146 |
returned: always |
| 147 |
contains: |
| 148 |
request_url: |
| 149 |
description: The full url requested. |
| 150 |
returned: always |
| 151 |
type: str |
| 152 |
sample: /sys/login/user |
| 153 |
response_code: |
| 154 |
description: The status of api request. |
| 155 |
returned: always |
| 156 |
type: int |
| 157 |
sample: 0 |
| 158 |
response_data: |
| 159 |
description: The api response. |
| 160 |
type: list |
| 161 |
returned: always |
| 162 |
response_message: |
| 163 |
description: The descriptive message of the api response. |
| 164 |
type: str |
| 165 |
returned: always |
| 166 |
sample: OK. |
| 167 |
system_information: |
| 168 |
description: The information of the target system. |
| 169 |
type: dict |
| 170 |
returned: always |
| 171 |
rc: |
| 172 |
description: The status the request. |
| 173 |
type: int |
| 174 |
returned: always |
| 175 |
sample: 0 |
| 176 |
version_check_warning: |
| 177 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 178 |
type: list |
| 179 |
returned: complex |
| 180 |
''' |
| 181 |
from ansible.module_utils.basic import AnsibleModule |
| 182 |
from ansible.module_utils.connection import Connection |
| 183 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 184 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 185 |
|
| 186 |
|
| 187 |
def main(): |
| 188 |
urls_list = [ |
| 189 |
'/pm/config/adom/{adom}/obj/application/internet-service-custom', |
| 190 |
'/pm/config/global/obj/application/internet-service-custom' |
| 191 |
] |
| 192 |
module_arg_spec = { |
| 193 |
'adom': {'required': True, 'type': 'str'}, |
| 194 |
'revision_note': {'type': 'str'}, |
| 195 |
'application_internetservicecustom': { |
| 196 |
'type': 'dict', 'v_range': [['6.2.0', '6.2.13']], |
| 197 |
'options': { |
| 198 |
'comment': {'v_range': [['6.2.0', '6.2.13']], 'type': 'str'}, |
| 199 |
'disable-entry': { |
| 200 |
'v_range': [['6.2.0', '6.2.13']], |
| 201 |
'type': 'list', |
| 202 |
'options': { |
| 203 |
'id': {'v_range': [['6.2.0', '6.2.13']], 'type': 'int'}, |
| 204 |
'ip-range': { |
| 205 |
'v_range': [['6.2.0', '6.2.13']], |
| 206 |
'type': 'list', |
| 207 |
'options': { |
| 208 |
'end-ip': {'v_range': [['6.2.0', '6.2.13']], 'type': 'str'}, |
| 209 |
'id': {'v_range': [['6.2.0', '6.2.13']], 'type': 'int'}, |
| 210 |
'start-ip': {'v_range': [['6.2.0', '6.2.13']], 'type': 'str'} |
| 211 |
}, |
| 212 |
'elements': 'dict' |
| 213 |
}, |
| 214 |
'port': {'v_range': [['6.2.0', '6.2.13']], 'type': 'raw'}, |
| 215 |
'protocol': {'v_range': [['6.2.0', '6.2.13']], 'type': 'int'} |
| 216 |
}, |
| 217 |
'elements': 'dict' |
| 218 |
}, |
| 219 |
'entry': { |
| 220 |
'v_range': [['6.2.0', '6.2.13']], |
| 221 |
'type': 'list', |
| 222 |
'options': { |
| 223 |
'dst': {'v_range': [['6.2.0', '6.2.13']], 'type': 'str'}, |
| 224 |
'id': {'v_range': [['6.2.0', '6.2.13']], 'type': 'int'}, |
| 225 |
'port-range': { |
| 226 |
'v_range': [['6.2.0', '6.2.13']], |
| 227 |
'type': 'list', |
| 228 |
'options': { |
| 229 |
'end-port': {'v_range': [['6.2.0', '6.2.13']], 'type': 'int'}, |
| 230 |
'id': {'v_range': [['6.2.0', '6.2.13']], 'type': 'int'}, |
| 231 |
'start-port': {'v_range': [['6.2.0', '6.2.13']], 'type': 'int'} |
| 232 |
}, |
| 233 |
'elements': 'dict' |
| 234 |
}, |
| 235 |
'protocol': {'v_range': [['6.2.0', '6.2.13']], 'type': 'int'} |
| 236 |
}, |
| 237 |
'elements': 'dict' |
| 238 |
}, |
| 239 |
'master-service-id': {'v_range': [['6.2.0', '6.2.13']], 'type': 'str'}, |
| 240 |
'name': {'v_range': [['6.2.0', '6.2.13']], 'required': True, 'type': 'str'} |
| 241 |
} |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
module_option_spec = get_module_arg_spec('full crud') |
| 246 |
module_arg_spec.update(module_option_spec) |
| 247 |
check_galaxy_version(module_arg_spec) |
| 248 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'application_internetservicecustom'), |
| 249 |
supports_check_mode=True) |
| 250 |
if not module._socket_path: |
| 251 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 252 |
connection = Connection(module._socket_path) |
| 253 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 254 |
'name', 'data', module, connection) |
| 255 |
fmgr.process_crud() |
| 256 |
module.exit_json(meta=module.params) |
| 257 |
|
| 258 |
|
| 259 |
if __name__ == '__main__': |
| 260 |
main() |