| 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_webproxy_isolatorserver |
| 15 |
short_description: Configure forward-server addresses. |
| 16 |
version_added: "2.14.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 |
webproxy_isolatorserver: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
addr_type: |
| 34 |
aliases: ['addr-type'] |
| 35 |
type: str |
| 36 |
description: Address type of the forwarding proxy server |
| 37 |
choices: ['fqdn', 'ipv6', 'ip'] |
| 38 |
comment: |
| 39 |
type: str |
| 40 |
description: Comment. |
| 41 |
fqdn: |
| 42 |
type: str |
| 43 |
description: Forward server Fully Qualified Domain Name |
| 44 |
interface: |
| 45 |
type: list |
| 46 |
elements: str |
| 47 |
description: Specify outgoing interface to reach server. |
| 48 |
interface_select_method: |
| 49 |
aliases: ['interface-select-method'] |
| 50 |
type: str |
| 51 |
description: Specify how to select outgoing interface to reach server. |
| 52 |
choices: ['auto', 'sdwan', 'specify'] |
| 53 |
ip: |
| 54 |
type: str |
| 55 |
description: Forward proxy server IP address. |
| 56 |
ipv6: |
| 57 |
type: str |
| 58 |
description: Forward proxy server IPv6 address. |
| 59 |
name: |
| 60 |
type: str |
| 61 |
description: Server name. |
| 62 |
required: true |
| 63 |
port: |
| 64 |
type: int |
| 65 |
description: Port number that the forwarding server expects to receive HTTP sessions on |
| 66 |
vrf_select: |
| 67 |
aliases: ['vrf-select'] |
| 68 |
type: int |
| 69 |
description: VRF ID used for connection to server. |
| 70 |
masquerade: |
| 71 |
type: str |
| 72 |
description: Enable/disable use of the of the IP address of the outgoing interface as the client IP address |
| 73 |
choices: ['disable', 'enable'] |
| 74 |
ippool: |
| 75 |
type: list |
| 76 |
elements: str |
| 77 |
description: Ippool. |
| 78 |
protocol: |
| 79 |
type: list |
| 80 |
elements: str |
| 81 |
description: Protocol. |
| 82 |
choices: ['http', 'ftp', 'socks'] |
| 83 |
''' |
| 84 |
|
| 85 |
EXAMPLES = ''' |
| 86 |
- name: Example playbook (generated based on argument schema) |
| 87 |
hosts: fortimanagers |
| 88 |
connection: httpapi |
| 89 |
gather_facts: false |
| 90 |
tasks: |
| 91 |
- name: Configure forward-server addresses. |
| 92 |
fortinet.fortimanager.fmgr_webproxy_isolatorserver: |
| 93 |
# workspace_locking_adom: <global or your adom name> |
| 94 |
adom: <your own value> |
| 95 |
state: present # <value in [present, absent]> |
| 96 |
webproxy_isolatorserver: |
| 97 |
name: "your value" # Required variable, string |
| 98 |
# addr_type: <value in [fqdn, ipv6, ip]> |
| 99 |
# comment: <string> |
| 100 |
# fqdn: <string> |
| 101 |
# interface: <list or string> |
| 102 |
# interface_select_method: <value in [auto, sdwan, specify]> |
| 103 |
# ip: <string> |
| 104 |
# ipv6: <string> |
| 105 |
# port: <integer> |
| 106 |
# vrf_select: <integer> |
| 107 |
# masquerade: <value in [disable, enable]> |
| 108 |
# ippool: <list or string> |
| 109 |
# protocol: ["http", "ftp", "socks"] |
| 110 |
''' |
| 111 |
|
| 112 |
RETURN = ''' |
| 113 |
meta: |
| 114 |
description: The result of the request. |
| 115 |
type: dict |
| 116 |
returned: always |
| 117 |
contains: |
| 118 |
request_url: |
| 119 |
description: The full url requested. |
| 120 |
returned: always |
| 121 |
type: str |
| 122 |
sample: /sys/login/user |
| 123 |
response_code: |
| 124 |
description: The status of api request. |
| 125 |
returned: always |
| 126 |
type: int |
| 127 |
sample: 0 |
| 128 |
response_data: |
| 129 |
description: The api response. |
| 130 |
type: list |
| 131 |
returned: always |
| 132 |
response_message: |
| 133 |
description: The descriptive message of the api response. |
| 134 |
type: str |
| 135 |
returned: always |
| 136 |
sample: OK. |
| 137 |
system_information: |
| 138 |
description: The information of the target system. |
| 139 |
type: dict |
| 140 |
returned: always |
| 141 |
rc: |
| 142 |
description: The status the request. |
| 143 |
type: int |
| 144 |
returned: always |
| 145 |
sample: 0 |
| 146 |
version_check_warning: |
| 147 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 148 |
type: list |
| 149 |
returned: complex |
| 150 |
''' |
| 151 |
from ansible.module_utils.basic import AnsibleModule |
| 152 |
from ansible.module_utils.connection import Connection |
| 153 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 154 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 155 |
|
| 156 |
|
| 157 |
def main(): |
| 158 |
urls_list = [ |
| 159 |
'/pm/config/adom/{adom}/obj/web-proxy/isolator-server', |
| 160 |
'/pm/config/global/obj/web-proxy/isolator-server' |
| 161 |
] |
| 162 |
module_arg_spec = { |
| 163 |
'adom': {'required': True, 'type': 'str'}, |
| 164 |
'revision_note': {'type': 'str'}, |
| 165 |
'webproxy_isolatorserver': { |
| 166 |
'type': 'dict', 'v_range': [['7.4.8', '7.4.10'], ['7.6.2', '']], |
| 167 |
'options': { |
| 168 |
'addr-type': {'v_range': [['7.4.8', '7.4.10'], ['7.6.2', '']], 'choices': ['fqdn', 'ipv6', 'ip'], 'type': 'str'}, |
| 169 |
'comment': {'v_range': [['7.4.8', '7.4.10'], ['7.6.2', '']], 'type': 'str'}, |
| 170 |
'fqdn': {'v_range': [['7.4.8', '7.4.10'], ['7.6.2', '']], 'type': 'str'}, |
| 171 |
'interface': {'v_range': [['7.6.2', '']], 'type': 'list', 'elements': 'str'}, |
| 172 |
'interface-select-method': {'v_range': [['7.6.2', '']], 'choices': ['auto', 'sdwan', 'specify'], 'type': 'str'}, |
| 173 |
'ip': {'v_range': [['7.4.8', '7.4.10'], ['7.6.2', '']], 'type': 'str'}, |
| 174 |
'ipv6': {'v_range': [['7.4.8', '7.4.10'], ['7.6.2', '']], 'type': 'str'}, |
| 175 |
'name': {'v_range': [['7.4.8', '7.4.10'], ['7.6.2', '']], 'required': True, 'type': 'str'}, |
| 176 |
'port': {'v_range': [['7.4.8', '7.4.10'], ['7.6.2', '']], 'type': 'int'}, |
| 177 |
'vrf-select': {'v_range': [['7.6.2', '']], 'type': 'int'}, |
| 178 |
'masquerade': {'v_range': [['7.4.8', '7.4.10'], ['7.6.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 179 |
'ippool': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'}, |
| 180 |
'protocol': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'choices': ['http', 'ftp', 'socks'], 'elements': 'str'} |
| 181 |
} |
| 182 |
} |
| 183 |
} |
| 184 |
|
| 185 |
module_option_spec = get_module_arg_spec('full crud') |
| 186 |
module_arg_spec.update(module_option_spec) |
| 187 |
check_galaxy_version(module_arg_spec) |
| 188 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'webproxy_isolatorserver'), |
| 189 |
supports_check_mode=True) |
| 190 |
if not module._socket_path: |
| 191 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 192 |
connection = Connection(module._socket_path) |
| 193 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 194 |
'name', 'data', module, connection) |
| 195 |
fmgr.process_crud() |
| 196 |
module.exit_json(meta=module.params) |
| 197 |
|
| 198 |
|
| 199 |
if __name__ == '__main__': |
| 200 |
main() |