Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_multicastaddress.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_firewall_multicastaddress
15 short_description: Configure multicast addresses.
16 version_added: "1.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 firewall_multicastaddress:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 associated_interface:
34 aliases: ['associated-interface']
35 type: str
36 description: Interface associated with the address object.
37 color:
38 type: int
39 description: Integer value to determine the color of the icon in the GUI
40 comment:
41 type: str
42 description: Comment.
43 end_ip:
44 aliases: ['end-ip']
45 type: str
46 description: Final IPv4 address
47 name:
48 type: str
49 description: Multicast address name.
50 required: true
51 start_ip:
52 aliases: ['start-ip']
53 type: str
54 description: First IPv4 address
55 subnet:
56 type: str
57 description: Broadcast address and subnet.
58 tagging:
59 type: list
60 elements: dict
61 description: Tagging.
62 suboptions:
63 category:
64 type: str
65 description: Tag category.
66 name:
67 type: str
68 description: Tagging entry name.
69 tags:
70 type: raw
71 description: (list) Tags.
72 type:
73 type: str
74 description: Type of address object
75 choices: ['multicastrange', 'broadcastmask']
76 visibility:
77 type: str
78 description: Enable/disable visibility of the multicast address on the GUI.
79 choices: ['disable', 'enable']
80 tags:
81 type: str
82 description: Names of object-tags
83 '''
84
85 EXAMPLES = '''
86 - name: Example playbook
87 hosts: fortimanagers
88 gather_facts: false
89 connection: httpapi
90 vars:
91 ansible_httpapi_use_ssl: true
92 ansible_httpapi_validate_certs: false
93 ansible_httpapi_port: 443
94 tasks:
95 - name: Configure multicast addresses.
96 fortinet.fortimanager.fmgr_firewall_multicastaddress:
97 bypass_validation: false
98 adom: ansible
99 state: present
100 firewall_multicastaddress:
101 color: 0
102 comment: "ansible-comment"
103 name: "ansible-test"
104 subnet: "222.222.221.0/24"
105 type: broadcastmask # <value in [multicastrange, broadcastmask]>
106 visibility: disable
107
108 - name: Gathering fortimanager facts
109 hosts: fortimanagers
110 gather_facts: false
111 connection: httpapi
112 vars:
113 ansible_httpapi_use_ssl: true
114 ansible_httpapi_validate_certs: false
115 ansible_httpapi_port: 443
116 tasks:
117 - name: Retrieve all the IPv4 multicast addresses
118 fortinet.fortimanager.fmgr_fact:
119 facts:
120 selector: "firewall_multicastaddress"
121 params:
122 adom: "ansible"
123 multicast_address: "your_value"
124 '''
125
126 RETURN = '''
127 meta:
128 description: The result of the request.
129 type: dict
130 returned: always
131 contains:
132 request_url:
133 description: The full url requested.
134 returned: always
135 type: str
136 sample: /sys/login/user
137 response_code:
138 description: The status of api request.
139 returned: always
140 type: int
141 sample: 0
142 response_data:
143 description: The api response.
144 type: list
145 returned: always
146 response_message:
147 description: The descriptive message of the api response.
148 type: str
149 returned: always
150 sample: OK.
151 system_information:
152 description: The information of the target system.
153 type: dict
154 returned: always
155 rc:
156 description: The status the request.
157 type: int
158 returned: always
159 sample: 0
160 version_check_warning:
161 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
162 type: list
163 returned: complex
164 '''
165 from ansible.module_utils.basic import AnsibleModule
166 from ansible.module_utils.connection import Connection
167 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
168 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
169
170
171 def main():
172 urls_list = [
173 '/pm/config/adom/{adom}/obj/firewall/multicast-address',
174 '/pm/config/global/obj/firewall/multicast-address'
175 ]
176 module_arg_spec = {
177 'adom': {'required': True, 'type': 'str'},
178 'revision_note': {'type': 'str'},
179 'firewall_multicastaddress': {
180 'type': 'dict', 'v_range': [['6.0.0', '']],
181 'options': {
182 'associated-interface': {'type': 'str'},
183 'color': {'type': 'int'},
184 'comment': {'type': 'str'},
185 'end-ip': {'type': 'str'},
186 'name': {'required': True, 'type': 'str'},
187 'start-ip': {'type': 'str'},
188 'subnet': {'type': 'str'},
189 'tagging': {
190 'type': 'list',
191 'options': {'category': {'type': 'str'}, 'name': {'type': 'str'}, 'tags': {'type': 'raw'}},
192 'elements': 'dict'
193 },
194 'type': {'choices': ['multicastrange', 'broadcastmask'], 'type': 'str'},
195 'visibility': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'},
196 'tags': {'v_range': [['6.2.0', '6.4.15']], 'type': 'str'}
197 }
198 }
199 }
200
201 module_option_spec = get_module_arg_spec('full crud')
202 module_arg_spec.update(module_option_spec)
203 check_galaxy_version(module_arg_spec)
204 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_multicastaddress'),
205 supports_check_mode=True)
206 if not module._socket_path:
207 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
208 connection = Connection(module._socket_path)
209 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
210 'name', 'data', module, connection)
211 fmgr.process_crud()
212 module.exit_json(meta=module.params)
213
214
215 if __name__ == '__main__':
216 main()