Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_pm_pkg.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_pm_pkg
15 short_description: Policy package or folder.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 adom:
22 description: The parameter (adom) in requested url.
23 type: str
24 required: true
25 pkg_path:
26 description: The parameter (pkg_path) in requested url.
27 type: str
28 required: true
29 pm_pkg:
30 description: The top level parameters set.
31 required: false
32 type: dict
33 suboptions:
34 name:
35 type: str
36 description: Name.
37 required: true
38 obj_ver:
39 aliases: ['obj ver']
40 type: int
41 description: Obj ver.
42 oid:
43 type: int
44 description: Oid.
45 package_setting:
46 aliases: ['package setting']
47 type: dict
48 description: Package setting.
49 suboptions:
50 central_nat:
51 aliases: ['central-nat']
52 type: str
53 description: Central nat.
54 choices: ['disable', 'enable']
55 consolidated_firewall_mode:
56 aliases: ['consolidated-firewall-mode']
57 type: str
58 description: Consolidated firewall mode.
59 choices: ['disable', 'enable']
60 fwpolicy_implicit_log:
61 aliases: ['fwpolicy-implicit-log']
62 type: str
63 description: Fwpolicy implicit log.
64 choices: ['disable', 'enable']
65 fwpolicy6_implicit_log:
66 aliases: ['fwpolicy6-implicit-log']
67 type: str
68 description: Fwpolicy6 implicit log.
69 choices: ['disable', 'enable']
70 inspection_mode:
71 aliases: ['inspection-mode']
72 type: str
73 description: Inspection mode.
74 choices: ['proxy', 'flow']
75 ngfw_mode:
76 aliases: ['ngfw-mode']
77 type: str
78 description: Ngfw mode.
79 choices: ['profile-based', 'policy-based']
80 ssl_ssh_profile:
81 aliases: ['ssl-ssh-profile']
82 type: str
83 description: Ssl ssh profile.
84 scope_member:
85 aliases: ['scope member']
86 type: list
87 elements: dict
88 description: Scope member.
89 suboptions:
90 name:
91 type: str
92 description: Name.
93 vdom:
94 type: str
95 description: Vdom.
96 type:
97 type: str
98 description: Type.
99 choices: ['pkg', 'folder']
100 package_settings:
101 aliases: ['package settings']
102 type: dict
103 description: Package settings.
104 suboptions:
105 central_nat:
106 aliases: ['central-nat']
107 type: str
108 description:
109 - disable -
110 - enable -
111 choices: ['disable', 'enable']
112 consolidated_firewall_mode:
113 aliases: ['consolidated-firewall-mode']
114 type: str
115 description:
116 - For flow-based policy package.
117 - disable -
118 - enable -
119 choices: ['disable', 'enable']
120 fwpolicy_implicit_log:
121 aliases: ['fwpolicy-implicit-log']
122 type: str
123 description:
124 - disable -
125 - enable -
126 choices: ['disable', 'enable']
127 fwpolicy6_implicit_log:
128 aliases: ['fwpolicy6-implicit-log']
129 type: str
130 description:
131 - disable -
132 - enable -
133 choices: ['disable', 'enable']
134 inspection_mode:
135 aliases: ['inspection-mode']
136 type: str
137 description:
138 - proxy -
139 - flow -
140 choices: ['proxy', 'flow']
141 ngfw_mode:
142 aliases: ['ngfw-mode']
143 type: str
144 description:
145 - For flow-based policy package.
146 - profile-based -
147 - policy-based -
148 choices: ['profile-based', 'policy-based']
149 policy_offload_level:
150 aliases: ['policy-offload-level']
151 type: str
152 description:
153 - disable -
154 - default -
155 - dos-offload -
156 - full-offload -
157 choices: ['disable', 'default', 'dos-offload', 'full-offload']
158 ssl_ssh_profile:
159 aliases: ['ssl-ssh-profile']
160 type: str
161 description: SSL-SSH profile required for NGFW-mode policy package.
162 '''
163
164 EXAMPLES = '''
165 - name: Example playbook (generated based on argument schema)
166 hosts: fortimanagers
167 connection: httpapi
168 gather_facts: false
169 tasks:
170 - name: Policy package or folder.
171 fortinet.fortimanager.fmgr_pm_pkg:
172 # workspace_locking_adom: <global or your adom name>
173 adom: <your own value>
174 pkg_path: <your own value>
175 state: present # <value in [present, absent]>
176 pm_pkg:
177 name: "your value" # Required variable, string
178 # obj_ver: <integer>
179 # oid: <integer>
180 # package_setting:
181 # central_nat: <value in [disable, enable]>
182 # consolidated_firewall_mode: <value in [disable, enable]>
183 # fwpolicy_implicit_log: <value in [disable, enable]>
184 # fwpolicy6_implicit_log: <value in [disable, enable]>
185 # inspection_mode: <value in [proxy, flow]>
186 # ngfw_mode: <value in [profile-based, policy-based]>
187 # ssl_ssh_profile: <string>
188 # scope_member:
189 # - name: <string>
190 # vdom: <string>
191 # type: <value in [pkg, folder]>
192 # package_settings:
193 # central_nat: <value in [disable, enable]>
194 # consolidated_firewall_mode: <value in [disable, enable]>
195 # fwpolicy_implicit_log: <value in [disable, enable]>
196 # fwpolicy6_implicit_log: <value in [disable, enable]>
197 # inspection_mode: <value in [proxy, flow]>
198 # ngfw_mode: <value in [profile-based, policy-based]>
199 # policy_offload_level: <value in [disable, default, dos-offload, ...]>
200 # ssl_ssh_profile: <string>
201 '''
202
203 RETURN = '''
204 meta:
205 description: The result of the request.
206 type: dict
207 returned: always
208 contains:
209 request_url:
210 description: The full url requested.
211 returned: always
212 type: str
213 sample: /sys/login/user
214 response_code:
215 description: The status of api request.
216 returned: always
217 type: int
218 sample: 0
219 response_data:
220 description: The api response.
221 type: list
222 returned: always
223 response_message:
224 description: The descriptive message of the api response.
225 type: str
226 returned: always
227 sample: OK.
228 system_information:
229 description: The information of the target system.
230 type: dict
231 returned: always
232 rc:
233 description: The status the request.
234 type: int
235 returned: always
236 sample: 0
237 version_check_warning:
238 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
239 type: list
240 returned: complex
241 '''
242 from ansible.module_utils.basic import AnsibleModule
243 from ansible.module_utils.connection import Connection
244 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
245 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
246
247
248 def main():
249 urls_list = [
250 '/pm/pkg/adom/{adom}/{pkg_path}',
251 '/pm/pkg/global/{pkg_path}'
252 ]
253 module_arg_spec = {
254 'adom': {'required': True, 'type': 'str'},
255 'pkg_path': {'required': True, 'type': 'str'},
256 'pm_pkg': {
257 'type': 'dict', 'v_range': [['6.0.0', '']],
258 'options': {
259 'name': {'required': True, 'type': 'str'},
260 'obj ver': {'type': 'int'},
261 'oid': {'type': 'int'},
262 'package setting': {
263 'v_range': [['6.0.0', '6.4.6'], ['7.0.0', '7.0.0']],
264 'type': 'dict',
265 'options': {
266 'central-nat': {'v_range': [['6.0.0', '6.4.6'], ['7.0.0', '7.0.0']], 'choices': ['disable', 'enable'], 'type': 'str'},
267 'consolidated-firewall-mode': {
268 'v_range': [['6.0.0', '6.4.6'], ['7.0.0', '7.0.0']],
269 'choices': ['disable', 'enable'],
270 'type': 'str'
271 },
272 'fwpolicy-implicit-log': {'v_range': [['6.0.0', '6.4.6'], ['7.0.0', '7.0.0']], 'choices': ['disable', 'enable'], 'type': 'str'},
273 'fwpolicy6-implicit-log': {'v_range': [['6.0.0', '6.4.6'], ['7.0.0', '7.0.0']], 'choices': ['disable', 'enable'], 'type': 'str'},
274 'inspection-mode': {'v_range': [['6.0.0', '6.4.6'], ['7.0.0', '7.0.0']], 'choices': ['proxy', 'flow'], 'type': 'str'},
275 'ngfw-mode': {'v_range': [['6.0.0', '6.4.6'], ['7.0.0', '7.0.0']], 'choices': ['profile-based', 'policy-based'], 'type': 'str'},
276 'ssl-ssh-profile': {'v_range': [['6.0.0', '6.4.6'], ['7.0.0', '7.0.0']], 'type': 'str'}
277 }
278 },
279 'scope member': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
280 'type': {'choices': ['pkg', 'folder'], 'type': 'str'},
281 'package settings': {
282 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']],
283 'type': 'dict',
284 'options': {
285 'central-nat': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
286 'consolidated-firewall-mode': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
287 'fwpolicy-implicit-log': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
288 'fwpolicy6-implicit-log': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
289 'inspection-mode': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'choices': ['proxy', 'flow'], 'type': 'str'},
290 'ngfw-mode': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'choices': ['profile-based', 'policy-based'], 'type': 'str'},
291 'policy-offload-level': {
292 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']],
293 'choices': ['disable', 'default', 'dos-offload', 'full-offload'],
294 'type': 'str'
295 },
296 'ssl-ssh-profile': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'str'}
297 }
298 }
299 }
300 }
301 }
302
303 module_option_spec = get_module_arg_spec('full crud')
304 module_arg_spec.update(module_option_spec)
305 check_galaxy_version(module_arg_spec)
306 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'pm_pkg'),
307 supports_check_mode=True)
308 if not module._socket_path:
309 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
310 connection = Connection(module._socket_path)
311 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
312 'name', 'data', module, connection)
313 fmgr.process_crud()
314 module.exit_json(meta=module.params)
315
316
317 if __name__ == '__main__':
318 main()