Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_pkg_firewall_multicastpolicy.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_multicastpolicy
15 short_description: Configure multicast NAT 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_multicastpolicy:
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 auto_asic_offload:
42 aliases: ['auto-asic-offload']
43 type: str
44 description: Enable/disable offloading policy traffic for hardware acceleration.
45 choices: ['disable', 'enable']
46 dnat:
47 type: str
48 description: IPv4 DNAT address used for multicast destination addresses.
49 dstaddr:
50 type: raw
51 description: (list or str) Destination address objects.
52 dstintf:
53 type: str
54 description: Destination interface name.
55 end_port:
56 aliases: ['end-port']
57 type: int
58 description: Integer value for ending TCP/UDP/SCTP destination port in range
59 id:
60 type: int
61 description: Policy ID.
62 required: true
63 logtraffic:
64 type: str
65 description: Enable/disable logging traffic accepted by this policy.
66 choices: ['disable', 'enable', 'all', 'utm']
67 protocol:
68 type: int
69 description: Integer value for the protocol type as defined by IANA
70 snat:
71 type: str
72 description: Enable/disable substitution of the outgoing interface IP address for the original source IP address
73 choices: ['disable', 'enable']
74 snat_ip:
75 aliases: ['snat-ip']
76 type: str
77 description: IPv4 address to be used as the source address for NATed traffic.
78 srcaddr:
79 type: raw
80 description: (list or str) Source address objects.
81 srcintf:
82 type: str
83 description: Source interface name.
84 start_port:
85 aliases: ['start-port']
86 type: int
87 description: Integer value for starting TCP/UDP/SCTP destination port in range
88 status:
89 type: str
90 description: Enable/disable this policy.
91 choices: ['disable', 'enable']
92 comments:
93 type: str
94 description: Comment.
95 uuid:
96 type: str
97 description: Universally Unique Identifier
98 name:
99 type: str
100 description: Policy name.
101 traffic_shaper:
102 aliases: ['traffic-shaper']
103 type: str
104 description: Traffic shaper to apply to traffic forwarded by the multicast policy.
105 ips_sensor:
106 aliases: ['ips-sensor']
107 type: str
108 description: Name of an existing IPS sensor.
109 utm_status:
110 aliases: ['utm-status']
111 type: str
112 description: Enable to add an IPS security profile to the policy.
113 choices: ['disable', 'enable']
114 '''
115
116 EXAMPLES = '''
117 - name: Example playbook
118 hosts: fortimanagers
119 gather_facts: false
120 connection: httpapi
121 vars:
122 ansible_httpapi_use_ssl: true
123 ansible_httpapi_validate_certs: false
124 ansible_httpapi_port: 443
125 tasks:
126 - name: Configure multicast NAT policies.
127 fortinet.fortimanager.fmgr_pkg_firewall_multicastpolicy:
128 bypass_validation: false
129 adom: ansible
130 pkg: ansible # package name
131 state: present
132 pkg_firewall_multicastpolicy:
133 action: accept # <value in [deny, accept]>
134 dstaddr: all
135 dstintf: any
136 id: 2
137 srcaddr: all
138 srcintf: any
139 status: disable
140
141 - name: Gathering fortimanager facts
142 hosts: fortimanagers
143 gather_facts: false
144 connection: httpapi
145 vars:
146 ansible_httpapi_use_ssl: true
147 ansible_httpapi_validate_certs: false
148 ansible_httpapi_port: 443
149 tasks:
150 - name: Retrieve all the multicast NAT policies
151 fortinet.fortimanager.fmgr_fact:
152 facts:
153 selector: "pkg_firewall_multicastpolicy"
154 params:
155 adom: "ansible"
156 pkg: "ansible" # package name
157 multicast_policy: "your_value"
158 '''
159
160 RETURN = '''
161 meta:
162 description: The result of the request.
163 type: dict
164 returned: always
165 contains:
166 request_url:
167 description: The full url requested.
168 returned: always
169 type: str
170 sample: /sys/login/user
171 response_code:
172 description: The status of api request.
173 returned: always
174 type: int
175 sample: 0
176 response_data:
177 description: The api response.
178 type: list
179 returned: always
180 response_message:
181 description: The descriptive message of the api response.
182 type: str
183 returned: always
184 sample: OK.
185 system_information:
186 description: The information of the target system.
187 type: dict
188 returned: always
189 rc:
190 description: The status the request.
191 type: int
192 returned: always
193 sample: 0
194 version_check_warning:
195 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
196 type: list
197 returned: complex
198 '''
199 from ansible.module_utils.basic import AnsibleModule
200 from ansible.module_utils.connection import Connection
201 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
202 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
203
204
205 def main():
206 urls_list = [
207 '/pm/config/adom/{adom}/pkg/{pkg}/firewall/multicast-policy'
208 ]
209 module_arg_spec = {
210 'adom': {'required': True, 'type': 'str'},
211 'pkg': {'required': True, 'type': 'str'},
212 'revision_note': {'type': 'str'},
213 'pkg_firewall_multicastpolicy': {
214 'type': 'dict', 'v_range': [['6.0.0', '']],
215 'options': {
216 'action': {'choices': ['deny', 'accept'], 'type': 'str'},
217 'auto-asic-offload': {
218 'v_range': [['6.0.0', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
219 'choices': ['disable', 'enable'],
220 'type': 'str'
221 },
222 'dnat': {'type': 'str'},
223 'dstaddr': {'type': 'raw'},
224 'dstintf': {'type': 'str'},
225 'end-port': {'type': 'int'},
226 'id': {'required': True, 'type': 'int'},
227 'logtraffic': {'choices': ['disable', 'enable', 'all', 'utm'], 'type': 'str'},
228 'protocol': {'type': 'int'},
229 'snat': {'choices': ['disable', 'enable'], 'type': 'str'},
230 'snat-ip': {'type': 'str'},
231 'srcaddr': {'type': 'raw'},
232 'srcintf': {'type': 'str'},
233 'start-port': {'type': 'int'},
234 'status': {'choices': ['disable', 'enable'], 'type': 'str'},
235 'comments': {'v_range': [['6.4.0', '']], 'type': 'str'},
236 'uuid': {'v_range': [['6.4.0', '']], 'type': 'str'},
237 'name': {'v_range': [['6.4.2', '']], 'type': 'str'},
238 'traffic-shaper': {'v_range': [['7.2.0', '']], 'type': 'str'},
239 'ips-sensor': {'v_range': [['7.4.2', '']], 'type': 'str'},
240 'utm-status': {'v_range': [['7.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
241 }
242 }
243 }
244
245 module_option_spec = get_module_arg_spec('full crud')
246 module_arg_spec.update(module_option_spec)
247 check_galaxy_version(module_arg_spec)
248 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'pkg_firewall_multicastpolicy'),
249 supports_check_mode=True)
250 if not module._socket_path:
251 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
252 connection = Connection(module._socket_path)
253 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
254 'id', 'data', module, connection)
255 fmgr.process_crud()
256 module.exit_json(meta=module.params)
257
258
259 if __name__ == '__main__':
260 main()