Debian Codegraph @

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