Debian Codegraph @

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