Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_webproxy_forwardserver.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
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_forwardserver
15 short_description: Configure forward-server addresses.
16 version_added: "2.0.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_forwardserver:
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', 'ip', 'ipv6']
38 comment:
39 type: str
40 description: Comment.
41 fqdn:
42 type: str
43 description: Forward server Fully Qualified Domain Name
44 healthcheck:
45 type: str
46 description: Enable/disable forward server health checking.
47 choices: ['disable', 'enable']
48 ip:
49 type: str
50 description: Forward proxy server IP address.
51 monitor:
52 type: str
53 description: URL for forward server health check monitoring
54 name:
55 type: str
56 description: Server name.
57 required: true
58 port:
59 type: int
60 description: Port number that the forwarding server expects to receive HTTP sessions on
61 server_down_option:
62 aliases: ['server-down-option']
63 type: str
64 description: Action to take when the forward server is found to be down
65 choices: ['block', 'pass']
66 password:
67 type: raw
68 description: (list) HTTP authentication password.
69 username:
70 type: str
71 description: HTTP authentication user name.
72 ipv6:
73 type: str
74 description: Forward proxy server IPv6 address.
75 masquerade:
76 type: str
77 description: Enable/disable use of the of the IP address of the outgoing interface as the client IP address
78 choices: ['disable', 'enable']
79 interface:
80 type: raw
81 description: (list) Specify outgoing interface to reach server.
82 interface_select_method:
83 aliases: ['interface-select-method']
84 type: str
85 description: Specify how to select outgoing interface to reach server.
86 choices: ['auto', 'sdwan', 'specify']
87 vrf_select:
88 aliases: ['vrf-select']
89 type: int
90 description: VRF ID used for connection to server.
91 ippool:
92 type: raw
93 description: (list) Ippool.
94 protocol:
95 type: list
96 elements: str
97 description: Protocol.
98 choices: ['http', 'ftp', 'socks']
99 authentication:
100 type: str
101 description: Authentication type.
102 choices: ['disabled', 'immediately', 'upon-challenge']
103 user:
104 type: str
105 description: User name of basic proxy authentication.
106 '''
107
108 EXAMPLES = '''
109 - name: Example playbook (generated based on argument schema)
110 hosts: fortimanagers
111 connection: httpapi
112 gather_facts: false
113 tasks:
114 - name: Configure forward-server addresses.
115 fortinet.fortimanager.fmgr_webproxy_forwardserver:
116 # workspace_locking_adom: <global or your adom name>
117 adom: <your own value>
118 state: present # <value in [present, absent]>
119 webproxy_forwardserver:
120 name: "your value" # Required variable, string
121 # addr_type: <value in [fqdn, ip, ipv6]>
122 # comment: <string>
123 # fqdn: <string>
124 # healthcheck: <value in [disable, enable]>
125 # ip: <string>
126 # monitor: <string>
127 # port: <integer>
128 # server_down_option: <value in [block, pass]>
129 # password: <list or string>
130 # username: <string>
131 # ipv6: <string>
132 # masquerade: <value in [disable, enable]>
133 # interface: <list or string>
134 # interface_select_method: <value in [auto, sdwan, specify]>
135 # vrf_select: <integer>
136 # ippool: <list or string>
137 # protocol: ["http", "ftp", "socks"]
138 # authentication: <value in [disabled, immediately, upon-challenge]>
139 # user: <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/web-proxy/forward-server',
190 '/pm/config/global/obj/web-proxy/forward-server'
191 ]
192 module_arg_spec = {
193 'adom': {'required': True, 'type': 'str'},
194 'revision_note': {'type': 'str'},
195 'webproxy_forwardserver': {
196 'type': 'dict', 'v_range': [['6.0.0', '']],
197 'options': {
198 'addr-type': {'choices': ['fqdn', 'ip', 'ipv6'], 'type': 'str'},
199 'comment': {'type': 'str'},
200 'fqdn': {'type': 'str'},
201 'healthcheck': {'choices': ['disable', 'enable'], 'type': 'str'},
202 'ip': {'type': 'str'},
203 'monitor': {'type': 'str'},
204 'name': {'required': True, 'type': 'str'},
205 'port': {'type': 'int'},
206 'server-down-option': {'choices': ['block', 'pass'], 'type': 'str'},
207 'password': {'v_range': [['6.4.0', '']], 'no_log': True, 'type': 'raw'},
208 'username': {'v_range': [['6.4.0', '']], 'type': 'str'},
209 'ipv6': {'v_range': [['7.4.1', '']], 'type': 'str'},
210 'masquerade': {'v_range': [['7.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
211 'interface': {'v_range': [['7.6.2', '']], 'type': 'raw'},
212 'interface-select-method': {'v_range': [['7.6.2', '']], 'choices': ['auto', 'sdwan', 'specify'], 'type': 'str'},
213 'vrf-select': {'v_range': [['7.6.2', '']], 'type': 'int'},
214 'ippool': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'raw'},
215 'protocol': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'choices': ['http', 'ftp', 'socks'], 'elements': 'str'},
216 'authentication': {'v_range': [['7.4.8', '7.4.10']], 'choices': ['disabled', 'immediately', 'upon-challenge'], 'type': 'str'},
217 'user': {'v_range': [['7.4.8', '7.4.10']], 'type': 'str'}
218 }
219 }
220 }
221
222 module_option_spec = get_module_arg_spec('full crud')
223 module_arg_spec.update(module_option_spec)
224 check_galaxy_version(module_arg_spec)
225 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'webproxy_forwardserver'),
226 supports_check_mode=True)
227 if not module._socket_path:
228 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
229 connection = Connection(module._socket_path)
230 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
231 'name', 'data', module, connection)
232 fmgr.process_crud()
233 module.exit_json(meta=module.params)
234
235
236 if __name__ == '__main__':
237 main()