Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_externalresource.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_system_externalresource
15 short_description: Configure external resource.
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 system_externalresource:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 category:
34 type: int
35 description: User resource category.
36 comments:
37 type: str
38 description: Comment.
39 name:
40 type: str
41 description: External resource name.
42 required: true
43 refresh_rate:
44 aliases: ['refresh-rate']
45 type: int
46 description: Time interval to refresh external resource
47 resource:
48 type: str
49 description: URI of external resource.
50 status:
51 type: str
52 description: Enable/disable user resource.
53 choices: ['disable', 'enable']
54 type:
55 type: str
56 description: User resource type.
57 choices: ['category', 'address', 'domain', 'malware', 'url', 'mac-address',
58 'data', 'generic-address']
59 password:
60 type: raw
61 description: (list) HTTP basic authentication password.
62 source_ip:
63 aliases: ['source-ip']
64 type: str
65 description: Source IPv4 address used to communicate with server.
66 username:
67 type: str
68 description: HTTP basic authentication user name.
69 interface:
70 type: str
71 description: Specify outgoing interface to reach server.
72 interface_select_method:
73 aliases: ['interface-select-method']
74 type: str
75 description: Specify how to select outgoing interface to reach server.
76 choices: ['auto', 'sdwan', 'specify']
77 user_agent:
78 aliases: ['user-agent']
79 type: str
80 description: Override HTTP User-Agent header used when retrieving this external resource.
81 uuid:
82 type: str
83 description: Universally Unique Identifier
84 server_identity_check:
85 aliases: ['server-identity-check']
86 type: str
87 description: Certificate verification option.
88 choices: ['none', 'basic', 'full']
89 update_method:
90 aliases: ['update-method']
91 type: str
92 description: External resource update method.
93 choices: ['feed', 'push']
94 address_comment_field:
95 aliases: ['address-comment-field']
96 type: str
97 description: JSON Path to address description in generic address entry.
98 address_data_field:
99 aliases: ['address-data-field']
100 type: str
101 description: JSON Path to address data in generic address entry.
102 address_name_field:
103 aliases: ['address-name-field']
104 type: str
105 description: JSON Path to address name in generic address entry.
106 client_cert:
107 aliases: ['client-cert']
108 type: raw
109 description: (list) Client certificate name.
110 client_cert_auth:
111 aliases: ['client-cert-auth']
112 type: str
113 description: Enable/disable using client certificate for TLS authentication.
114 choices: ['disable', 'enable']
115 dynamic_mapping:
116 type: list
117 elements: dict
118 description: Dynamic mapping.
119 suboptions:
120 _scope:
121 type: list
122 elements: dict
123 description: Scope.
124 suboptions:
125 name:
126 type: str
127 description: Name.
128 vdom:
129 type: str
130 description: Vdom.
131 source_ip:
132 aliases: ['source-ip']
133 type: str
134 description: Source ip.
135 namespace:
136 type: str
137 description: Generic external connector address namespace.
138 object_array_path:
139 aliases: ['object-array-path']
140 type: str
141 description: JSON Path to array of generic addresses in resource.
142 vrf_select:
143 aliases: ['vrf-select']
144 type: int
145 description: VRF ID used for connection to server.
146 proxy:
147 type: str
148 description: Proxy.
149 proxy_password:
150 aliases: ['proxy-password']
151 type: raw
152 description: (list) Proxy password.
153 proxy_port:
154 aliases: ['proxy-port']
155 type: int
156 description: Proxy port.
157 proxy_username:
158 aliases: ['proxy-username']
159 type: str
160 description: Proxy username.
161 source_ip_interface:
162 aliases: ['source-ip-interface']
163 type: raw
164 description: (list) IPv4 Source interface for communication with the server.
165 '''
166
167 EXAMPLES = '''
168 - name: Example playbook
169 hosts: fortimanagers
170 gather_facts: false
171 connection: httpapi
172 vars:
173 ansible_httpapi_use_ssl: true
174 ansible_httpapi_validate_certs: false
175 ansible_httpapi_port: 443
176 tasks:
177 - name: Configure external resource.
178 fortinet.fortimanager.fmgr_system_externalresource:
179 bypass_validation: false
180 adom: ansible
181 state: present
182 system_externalresource:
183 category: 0
184 comments: string
185 name: string
186 refresh_rate: 1
187 resource: string
188 status: disable
189 type: category # <value in [category, address, domain, ...]>
190
191 - name: Gathering fortimanager facts
192 hosts: fortimanagers
193 gather_facts: false
194 connection: httpapi
195 vars:
196 ansible_httpapi_use_ssl: true
197 ansible_httpapi_validate_certs: false
198 ansible_httpapi_port: 443
199 tasks:
200 - name: Retrieve all the external resources
201 fortinet.fortimanager.fmgr_fact:
202 facts:
203 selector: "system_externalresource"
204 params:
205 adom: "ansible"
206 external_resource: "your_value"
207 '''
208
209 RETURN = '''
210 meta:
211 description: The result of the request.
212 type: dict
213 returned: always
214 contains:
215 request_url:
216 description: The full url requested.
217 returned: always
218 type: str
219 sample: /sys/login/user
220 response_code:
221 description: The status of api request.
222 returned: always
223 type: int
224 sample: 0
225 response_data:
226 description: The api response.
227 type: list
228 returned: always
229 response_message:
230 description: The descriptive message of the api response.
231 type: str
232 returned: always
233 sample: OK.
234 system_information:
235 description: The information of the target system.
236 type: dict
237 returned: always
238 rc:
239 description: The status the request.
240 type: int
241 returned: always
242 sample: 0
243 version_check_warning:
244 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
245 type: list
246 returned: complex
247 '''
248 from ansible.module_utils.basic import AnsibleModule
249 from ansible.module_utils.connection import Connection
250 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
251 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
252
253
254 def main():
255 urls_list = [
256 '/pm/config/adom/{adom}/obj/system/external-resource',
257 '/pm/config/global/obj/system/external-resource'
258 ]
259 module_arg_spec = {
260 'adom': {'required': True, 'type': 'str'},
261 'revision_note': {'type': 'str'},
262 'system_externalresource': {
263 'type': 'dict', 'v_range': [['6.0.0', '']],
264 'options': {
265 'category': {'type': 'int'},
266 'comments': {'type': 'str'},
267 'name': {'required': True, 'type': 'str'},
268 'refresh-rate': {'type': 'int'},
269 'resource': {'type': 'str'},
270 'status': {'choices': ['disable', 'enable'], 'type': 'str'},
271 'type': {'choices': ['category', 'address', 'domain', 'malware', 'url', 'mac-address', 'data', 'generic-address'], 'type': 'str'},
272 'password': {'v_range': [['6.2.0', '']], 'no_log': True, 'type': 'raw'},
273 'source-ip': {'v_range': [['6.2.1', '']], 'type': 'str'},
274 'username': {'v_range': [['6.2.0', '']], 'type': 'str'},
275 'interface': {'v_range': [['6.4.2', '']], 'type': 'str'},
276 'interface-select-method': {'v_range': [['6.4.2', '']], 'choices': ['auto', 'sdwan', 'specify'], 'type': 'str'},
277 'user-agent': {'v_range': [['6.4.2', '']], 'type': 'str'},
278 'uuid': {'v_range': [['7.0.0', '']], 'type': 'str'},
279 'server-identity-check': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'choices': ['none', 'basic', 'full'], 'type': 'str'},
280 'update-method': {'v_range': [['7.2.1', '']], 'choices': ['feed', 'push'], 'type': 'str'},
281 'address-comment-field': {'v_range': [['7.6.2', '']], 'type': 'str'},
282 'address-data-field': {'v_range': [['7.6.2', '']], 'type': 'str'},
283 'address-name-field': {'v_range': [['7.6.2', '']], 'type': 'str'},
284 'client-cert': {'v_range': [['7.6.2', '']], 'type': 'raw'},
285 'client-cert-auth': {'v_range': [['7.6.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
286 'dynamic_mapping': {
287 'v_range': [['7.6.2', '']],
288 'type': 'list',
289 'options': {
290 '_scope': {
291 'v_range': [['7.6.2', '']],
292 'type': 'list',
293 'options': {'name': {'v_range': [['7.6.2', '']], 'type': 'str'}, 'vdom': {'v_range': [['7.6.2', '']], 'type': 'str'}},
294 'elements': 'dict'
295 },
296 'source-ip': {'v_range': [['7.6.2', '']], 'type': 'str'}
297 },
298 'elements': 'dict'
299 },
300 'namespace': {'v_range': [['7.6.2', '']], 'type': 'str'},
301 'object-array-path': {'v_range': [['7.6.2', '']], 'type': 'str'},
302 'vrf-select': {'v_range': [['7.6.2', '']], 'type': 'int'},
303 'proxy': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
304 'proxy-password': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'no_log': True, 'type': 'raw'},
305 'proxy-port': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
306 'proxy-username': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
307 'source-ip-interface': {'v_range': [['7.6.4', '']], 'type': 'raw'}
308 }
309 }
310 }
311
312 module_option_spec = get_module_arg_spec('full crud')
313 module_arg_spec.update(module_option_spec)
314 check_galaxy_version(module_arg_spec)
315 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_externalresource'),
316 supports_check_mode=True)
317 if not module._socket_path:
318 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
319 connection = Connection(module._socket_path)
320 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
321 'name', 'data', module, connection)
322 fmgr.process_crud()
323 module.exit_json(meta=module.params)
324
325
326 if __name__ == '__main__':
327 main()