Debian Codegraph @

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