Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_pkg_firewall_policy64.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_pkg_firewall_policy64
15 short_description: Configure IPv6 to IPv4 policies.
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 pkg:
29 description: The parameter (pkg) in requested url.
30 type: str
31 required: true
32 pkg_firewall_policy64:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 action:
38 type: str
39 description: Policy action.
40 choices: ['deny', 'accept']
41 comments:
42 type: str
43 description: Comment.
44 dstaddr:
45 type: raw
46 description: (list or str) Destination address name.
47 dstintf:
48 type: str
49 description: Destination interface name.
50 fixedport:
51 type: str
52 description: Enable/disable policy fixed port.
53 choices: ['disable', 'enable']
54 ippool:
55 type: str
56 description: Enable/disable policy64 IP pool.
57 choices: ['disable', 'enable']
58 logtraffic:
59 type: str
60 description: Enable/disable policy log traffic.
61 choices: ['disable', 'enable']
62 per_ip_shaper:
63 aliases: ['per-ip-shaper']
64 type: str
65 description: Per-IP traffic shaper.
66 permit_any_host:
67 aliases: ['permit-any-host']
68 type: str
69 description: Enable/disable permit any host in.
70 choices: ['disable', 'enable']
71 policyid:
72 type: int
73 description: Policy ID.
74 required: true
75 poolname:
76 type: raw
77 description: (list or str) Policy IP pool names.
78 schedule:
79 type: str
80 description: Schedule name.
81 service:
82 type: raw
83 description: (list or str) Service name.
84 srcaddr:
85 type: raw
86 description: (list or str) Source address name.
87 srcintf:
88 type: str
89 description: Source interface name.
90 status:
91 type: str
92 description: Enable/disable policy status.
93 choices: ['disable', 'enable']
94 tags:
95 type: str
96 description: Applied object tags.
97 tcp_mss_receiver:
98 aliases: ['tcp-mss-receiver']
99 type: int
100 description: TCP MSS value of receiver.
101 tcp_mss_sender:
102 aliases: ['tcp-mss-sender']
103 type: int
104 description: TCP MSS value of sender.
105 traffic_shaper:
106 aliases: ['traffic-shaper']
107 type: str
108 description: Traffic shaper.
109 traffic_shaper_reverse:
110 aliases: ['traffic-shaper-reverse']
111 type: str
112 description: Reverse traffic shaper.
113 uuid:
114 type: str
115 description: Universally Unique Identifier
116 logtraffic_start:
117 aliases: ['logtraffic-start']
118 type: str
119 description: Record logs when a session starts and ends.
120 choices: ['disable', 'enable']
121 name:
122 type: str
123 description: Policy name.
124 policy_offload:
125 aliases: ['policy-offload']
126 type: str
127 description: Enable/disable hardware session setup for CGNAT.
128 choices: ['disable', 'enable']
129 cgn_session_quota:
130 aliases: ['cgn-session-quota']
131 type: int
132 description: Session quota
133 cgn_eif:
134 aliases: ['cgn-eif']
135 type: str
136 description: Enable/disable CGN endpoint independent filtering.
137 choices: ['disable', 'enable']
138 cgn_log_server_grp:
139 aliases: ['cgn-log-server-grp']
140 type: str
141 description: NP log server group name
142 cgn_resource_quota:
143 aliases: ['cgn-resource-quota']
144 type: int
145 description: Resource quota
146 cgn_eim:
147 aliases: ['cgn-eim']
148 type: str
149 description: Enable/disable CGN endpoint independent mapping.
150 choices: ['disable', 'enable']
151 '''
152
153 EXAMPLES = '''
154 - name: Example playbook
155 hosts: fortimanagers
156 gather_facts: false
157 connection: httpapi
158 vars:
159 ansible_httpapi_use_ssl: true
160 ansible_httpapi_validate_certs: false
161 ansible_httpapi_port: 443
162 tasks:
163 - name: Configure IPv6 to IPv4 policies.
164 fortinet.fortimanager.fmgr_pkg_firewall_policy64:
165 bypass_validation: false
166 adom: ansible
167 pkg: ansible # package name
168 state: present
169 pkg_firewall_policy64:
170 action: accept # <value in [deny, accept]>
171 comments: ansible-comment
172 dstaddr: all
173 dstintf: any
174 policyid: 1
175 schedule: always
176 service: ALL
177 srcaddr: all
178 srcintf: any
179 status: disable
180
181 - name: Gathering fortimanager facts
182 hosts: fortimanagers
183 gather_facts: false
184 connection: httpapi
185 vars:
186 ansible_httpapi_use_ssl: true
187 ansible_httpapi_validate_certs: false
188 ansible_httpapi_port: 443
189 tasks:
190 - name: Retrieve all the IPv6 to IPv4 policies
191 fortinet.fortimanager.fmgr_fact:
192 facts:
193 selector: "pkg_firewall_policy64"
194 params:
195 adom: "ansible"
196 pkg: "ansible" # package name
197 policy64: "your_value"
198 '''
199
200 RETURN = '''
201 meta:
202 description: The result of the request.
203 type: dict
204 returned: always
205 contains:
206 request_url:
207 description: The full url requested.
208 returned: always
209 type: str
210 sample: /sys/login/user
211 response_code:
212 description: The status of api request.
213 returned: always
214 type: int
215 sample: 0
216 response_data:
217 description: The api response.
218 type: list
219 returned: always
220 response_message:
221 description: The descriptive message of the api response.
222 type: str
223 returned: always
224 sample: OK.
225 system_information:
226 description: The information of the target system.
227 type: dict
228 returned: always
229 rc:
230 description: The status the request.
231 type: int
232 returned: always
233 sample: 0
234 version_check_warning:
235 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
236 type: list
237 returned: complex
238 '''
239 from ansible.module_utils.basic import AnsibleModule
240 from ansible.module_utils.connection import Connection
241 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
242 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
243
244
245 def main():
246 urls_list = [
247 '/pm/config/adom/{adom}/pkg/{pkg}/firewall/policy64'
248 ]
249 module_arg_spec = {
250 'adom': {'required': True, 'type': 'str'},
251 'pkg': {'required': True, 'type': 'str'},
252 'revision_note': {'type': 'str'},
253 'pkg_firewall_policy64': {
254 'type': 'dict', 'v_range': [['6.0.0', '']],
255 'options': {
256 'action': {'choices': ['deny', 'accept'], 'type': 'str'},
257 'comments': {'type': 'str'},
258 'dstaddr': {'type': 'raw'},
259 'dstintf': {'type': 'str'},
260 'fixedport': {'choices': ['disable', 'enable'], 'type': 'str'},
261 'ippool': {'choices': ['disable', 'enable'], 'type': 'str'},
262 'logtraffic': {'choices': ['disable', 'enable'], 'type': 'str'},
263 'per-ip-shaper': {'type': 'str'},
264 'permit-any-host': {'choices': ['disable', 'enable'], 'type': 'str'},
265 'policyid': {'required': True, 'type': 'int'},
266 'poolname': {'type': 'raw'},
267 'schedule': {'type': 'str'},
268 'service': {'type': 'raw'},
269 'srcaddr': {'type': 'raw'},
270 'srcintf': {'type': 'str'},
271 'status': {'choices': ['disable', 'enable'], 'type': 'str'},
272 'tags': {'v_range': [['6.0.0', '6.4.15']], 'type': 'str'},
273 'tcp-mss-receiver': {'type': 'int'},
274 'tcp-mss-sender': {'type': 'int'},
275 'traffic-shaper': {'type': 'str'},
276 'traffic-shaper-reverse': {'type': 'str'},
277 'uuid': {'type': 'str'},
278 'logtraffic-start': {'v_range': [['6.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
279 'name': {'v_range': [['6.4.2', '']], 'type': 'str'},
280 'policy-offload': {'v_range': [['6.2.7', '6.2.13'], ['6.4.3', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'},
281 'cgn-session-quota': {'v_range': [['6.2.7', '6.2.13'], ['6.4.3', '7.6.2']], 'type': 'int'},
282 'cgn-eif': {'v_range': [['6.2.7', '6.2.13'], ['6.4.3', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'},
283 'cgn-log-server-grp': {'v_range': [['6.2.7', '6.2.13'], ['6.4.3', '7.6.2']], 'type': 'str'},
284 'cgn-resource-quota': {'v_range': [['6.2.7', '6.2.13'], ['6.4.3', '7.6.2']], 'type': 'int'},
285 'cgn-eim': {'v_range': [['6.2.7', '6.2.13'], ['6.4.3', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'}
286 }
287 }
288 }
289
290 module_option_spec = get_module_arg_spec('full crud')
291 module_arg_spec.update(module_option_spec)
292 check_galaxy_version(module_arg_spec)
293 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'pkg_firewall_policy64'),
294 supports_check_mode=True)
295 if not module._socket_path:
296 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
297 connection = Connection(module._socket_path)
298 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
299 'policyid', 'data', module, connection)
300 fmgr.process_crud()
301 module.exit_json(meta=module.params)
302
303
304 if __name__ == '__main__':
305 main()