Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_dnsdatabase.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_system_dnsdatabase
15 short_description: Configure DNS databases.
16 version_added: "2.12.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 system_dnsdatabase:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 allow_transfer:
34 aliases: ['allow-transfer']
35 type: list
36 elements: str
37 description: DNS zone transfer IP address list.
38 authoritative:
39 type: str
40 description: Enable/disable authoritative zone.
41 choices: ['disable', 'enable']
42 contact:
43 type: str
44 description: Email address of the administrator for this zone.
45 dns_entry:
46 aliases: ['dns-entry']
47 type: list
48 elements: dict
49 description: Dns entry.
50 suboptions:
51 canonical_name:
52 aliases: ['canonical-name']
53 type: str
54 description: Canonical name of the host.
55 hostname:
56 type: str
57 description: Name of the host.
58 id:
59 type: int
60 description: DNS entry ID.
61 ip:
62 type: str
63 description: IPv4 address of the host.
64 ipv6:
65 type: str
66 description: IPv6 address of the host.
67 preference:
68 type: int
69 description: DNS entry preference
70 status:
71 type: str
72 description: Enable/disable resource record status.
73 choices: ['disable', 'enable']
74 ttl:
75 type: int
76 description: Time-to-live for this entry
77 type:
78 type: str
79 description: Resource record type.
80 choices: ['NS', 'MX', 'CNAME', 'A', 'AAAA', 'PTR', 'PTR_V6']
81 domain:
82 type: str
83 description: Domain name.
84 forwarder:
85 type: list
86 elements: str
87 description: DNS zone forwarder IP address list.
88 forwarder6:
89 type: str
90 description: Forwarder IPv6 address.
91 ip_primary:
92 aliases: ['ip-primary']
93 type: str
94 description: IP address of primary DNS server.
95 name:
96 type: str
97 description: Zone name.
98 required: true
99 primary_name:
100 aliases: ['primary-name']
101 type: str
102 description: Domain name of the default DNS server for this zone.
103 rr_max:
104 aliases: ['rr-max']
105 type: int
106 description: Maximum number of resource records
107 source_ip:
108 aliases: ['source-ip']
109 type: str
110 description: Source IP for forwarding to DNS server.
111 source_ip6:
112 aliases: ['source-ip6']
113 type: str
114 description: IPv6 source IP address for forwarding to DNS server.
115 status:
116 type: str
117 description: Enable/disable this DNS zone.
118 choices: ['disable', 'enable']
119 ttl:
120 type: int
121 description: Default time-to-live value for the entries of this DNS zone
122 type:
123 type: str
124 description: Zone type
125 choices: ['primary', 'secondary', 'master', 'slave']
126 view:
127 type: str
128 description: Zone view
129 choices: ['shadow', 'public', 'shadow-ztna', 'proxy']
130 interface_select_method:
131 aliases: ['interface-select-method']
132 type: str
133 description: Specify how to select outgoing interface to reach server.
134 choices: ['auto', 'sdwan', 'specify']
135 interface:
136 type: list
137 elements: str
138 description: Specify outgoing interface to reach server.
139 source_ip_interface:
140 aliases: ['source-ip-interface']
141 type: list
142 elements: str
143 description: IP address of the specified interface as the source IP address.
144 vrf_select:
145 aliases: ['vrf-select']
146 type: int
147 description: VRF ID used for connection to server.
148 ip_master:
149 aliases: ['ip-master']
150 type: str
151 description: IP address of master DNS server.
152 '''
153
154 EXAMPLES = '''
155 - name: Example playbook (generated based on argument schema)
156 hosts: fortimanagers
157 connection: httpapi
158 gather_facts: false
159 tasks:
160 - name: Configure DNS databases.
161 fortinet.fortimanager.fmgr_system_dnsdatabase:
162 # workspace_locking_adom: <global or your adom name>
163 adom: <your own value>
164 state: present # <value in [present, absent]>
165 system_dnsdatabase:
166 name: "your value" # Required variable, string
167 # allow_transfer: <list or string>
168 # authoritative: <value in [disable, enable]>
169 # contact: <string>
170 # dns_entry:
171 # - canonical_name: <string>
172 # hostname: <string>
173 # id: <integer>
174 # ip: <string>
175 # ipv6: <string>
176 # preference: <integer>
177 # status: <value in [disable, enable]>
178 # ttl: <integer>
179 # type: <value in [NS, MX, CNAME, ...]>
180 # domain: <string>
181 # forwarder: <list or string>
182 # forwarder6: <string>
183 # ip_primary: <string>
184 # primary_name: <string>
185 # rr_max: <integer>
186 # source_ip: <string>
187 # source_ip6: <string>
188 # status: <value in [disable, enable]>
189 # ttl: <integer>
190 # type: <value in [primary, secondary, master, ...]>
191 # view: <value in [shadow, public, shadow-ztna, ...]>
192 # interface_select_method: <value in [auto, sdwan, specify]>
193 # interface: <list or string>
194 # source_ip_interface: <list or string>
195 # vrf_select: <integer>
196 # ip_master: <string>
197 '''
198
199 RETURN = '''
200 meta:
201 description: The result of the request.
202 type: dict
203 returned: always
204 contains:
205 request_url:
206 description: The full url requested.
207 returned: always
208 type: str
209 sample: /sys/login/user
210 response_code:
211 description: The status of api request.
212 returned: always
213 type: int
214 sample: 0
215 response_data:
216 description: The api response.
217 type: list
218 returned: always
219 response_message:
220 description: The descriptive message of the api response.
221 type: str
222 returned: always
223 sample: OK.
224 system_information:
225 description: The information of the target system.
226 type: dict
227 returned: always
228 rc:
229 description: The status the request.
230 type: int
231 returned: always
232 sample: 0
233 version_check_warning:
234 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
235 type: list
236 returned: complex
237 '''
238 from ansible.module_utils.basic import AnsibleModule
239 from ansible.module_utils.connection import Connection
240 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
241 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
242
243
244 def main():
245 urls_list = [
246 '/pm/config/adom/{adom}/obj/system/dns-database',
247 '/pm/config/global/obj/system/dns-database'
248 ]
249 module_arg_spec = {
250 'adom': {'required': True, 'type': 'str'},
251 'revision_note': {'type': 'str'},
252 'system_dnsdatabase': {
253 'type': 'dict', 'v_range': [['7.6.4', '7.6.4']],
254 'options': {
255 'allow-transfer': {'v_range': [['7.6.4', '7.6.4']], 'type': 'list', 'elements': 'str'},
256 'authoritative': {'v_range': [['7.6.4', '7.6.4']], 'choices': ['disable', 'enable'], 'type': 'str'},
257 'contact': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
258 'dns-entry': {
259 'v_range': [['7.6.4', '7.6.4']],
260 'type': 'list',
261 'options': {
262 'canonical-name': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
263 'hostname': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
264 'id': {'v_range': [['7.6.4', '7.6.4']], 'type': 'int'},
265 'ip': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
266 'ipv6': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
267 'preference': {'v_range': [['7.6.4', '7.6.4']], 'type': 'int'},
268 'status': {'v_range': [['7.6.4', '7.6.4']], 'choices': ['disable', 'enable'], 'type': 'str'},
269 'ttl': {'v_range': [['7.6.4', '7.6.4']], 'type': 'int'},
270 'type': {'v_range': [['7.6.4', '7.6.4']], 'choices': ['NS', 'MX', 'CNAME', 'A', 'AAAA', 'PTR', 'PTR_V6'], 'type': 'str'}
271 },
272 'elements': 'dict'
273 },
274 'domain': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
275 'forwarder': {'v_range': [['7.6.4', '7.6.4']], 'type': 'list', 'elements': 'str'},
276 'forwarder6': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
277 'ip-primary': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
278 'name': {'v_range': [['7.6.4', '7.6.4']], 'required': True, 'type': 'str'},
279 'primary-name': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
280 'rr-max': {'v_range': [['7.6.4', '7.6.4']], 'type': 'int'},
281 'source-ip': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
282 'source-ip6': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
283 'status': {'v_range': [['7.6.4', '7.6.4']], 'choices': ['disable', 'enable'], 'type': 'str'},
284 'ttl': {'v_range': [['7.6.4', '7.6.4']], 'type': 'int'},
285 'type': {'v_range': [['7.6.4', '7.6.4']], 'choices': ['primary', 'secondary', 'master', 'slave'], 'type': 'str'},
286 'view': {'v_range': [['7.6.4', '7.6.4']], 'choices': ['shadow', 'public', 'shadow-ztna', 'proxy'], 'type': 'str'},
287 'interface-select-method': {'v_range': [['7.6.4', '7.6.4']], 'choices': ['auto', 'sdwan', 'specify'], 'type': 'str'},
288 'interface': {'v_range': [['7.6.4', '7.6.4']], 'type': 'list', 'elements': 'str'},
289 'source-ip-interface': {'v_range': [['7.6.4', '7.6.4']], 'type': 'list', 'elements': 'str'},
290 'vrf-select': {'v_range': [['7.6.4', '7.6.4']], 'type': 'int'},
291 'ip-master': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'}
292 }
293 }
294 }
295
296 module_option_spec = get_module_arg_spec('full crud')
297 module_arg_spec.update(module_option_spec)
298 check_galaxy_version(module_arg_spec)
299 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_dnsdatabase'),
300 supports_check_mode=True)
301 if not module._socket_path:
302 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
303 connection = Connection(module._socket_path)
304 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
305 'name', 'data', module, connection)
306 fmgr.process_crud()
307 module.exit_json(meta=module.params)
308
309
310 if __name__ == '__main__':
311 main()