Debian Codegraph @

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