Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_vip46_dynamicmapping.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_vip46_dynamicmapping
15 short_description: Configure IPv4 to IPv6 virtual IPs.
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 vip46:
29 description: The parameter (vip46) in requested url.
30 type: str
31 required: true
32 firewall_vip46_dynamicmapping:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 _scope:
38 type: list
39 elements: dict
40 description: Scope.
41 suboptions:
42 name:
43 type: str
44 description: Name.
45 vdom:
46 type: str
47 description: Vdom.
48 arp_reply:
49 aliases: ['arp-reply']
50 type: str
51 description: Arp reply.
52 choices: ['disable', 'enable']
53 color:
54 type: int
55 description: Color.
56 comment:
57 type: str
58 description: Comment.
59 extip:
60 type: str
61 description: Extip.
62 extport:
63 type: str
64 description: Extport.
65 id:
66 type: int
67 description: Id.
68 ldb_method:
69 aliases: ['ldb-method']
70 type: str
71 description: Ldb method.
72 choices: ['static', 'round-robin', 'weighted', 'least-session', 'least-rtt',
73 'first-alive']
74 mappedip:
75 type: str
76 description: Mappedip.
77 mappedport:
78 type: str
79 description: Mappedport.
80 monitor:
81 type: raw
82 description: (list or str) Monitor.
83 portforward:
84 type: str
85 description: Portforward.
86 choices: ['disable', 'enable']
87 protocol:
88 type: str
89 description: Protocol.
90 choices: ['tcp', 'udp']
91 server_type:
92 aliases: ['server-type']
93 type: str
94 description: Server type.
95 choices: ['http', 'tcp', 'udp', 'ip']
96 src_filter:
97 aliases: ['src-filter']
98 type: raw
99 description: (list) Src filter.
100 type:
101 type: str
102 description: Type.
103 choices: ['static-nat', 'server-load-balance']
104 uuid:
105 type: str
106 description: Uuid.
107 srcintf_filter:
108 aliases: ['srcintf-filter']
109 type: raw
110 description: (list or str) Interfaces to which the VIP46 applies.
111 '''
112
113 EXAMPLES = '''
114 - name: Example playbook
115 hosts: fortimanagers
116 gather_facts: false
117 connection: httpapi
118 vars:
119 ansible_httpapi_use_ssl: true
120 ansible_httpapi_validate_certs: false
121 ansible_httpapi_port: 443
122 tasks:
123 - name: Configure dynamic mappings of IPv4 to IPv6 virtual IPs
124 fortinet.fortimanager.fmgr_firewall_vip46_dynamicmapping:
125 bypass_validation: false
126 adom: ansible
127 vip46: "ansible-test-vip46" # name
128 state: present
129 firewall_vip46_dynamicmapping:
130 _scope:
131 - name: FGT_AWS # need a valid device name
132 vdom: root # need a valid vdom name under the device
133 arp_reply: disable
134 color: 1
135 comment: "ansible-comment"
136 id: 1
137 ldb_method: static # <value in [static, round-robin, weighted, ...]>
138
139 - name: Gathering fortimanager facts
140 hosts: fortimanagers
141 gather_facts: false
142 connection: httpapi
143 vars:
144 ansible_httpapi_use_ssl: true
145 ansible_httpapi_validate_certs: false
146 ansible_httpapi_port: 443
147 tasks:
148 - name: Retrieve all the dynamic mappings of IPv4 to IPv6 virtual IPs
149 fortinet.fortimanager.fmgr_fact:
150 facts:
151 selector: "firewall_vip46_dynamicmapping"
152 params:
153 adom: "ansible"
154 vip46: "ansible-test-vip46" # name
155 dynamic_mapping: "your_value"
156 '''
157
158 RETURN = '''
159 meta:
160 description: The result of the request.
161 type: dict
162 returned: always
163 contains:
164 request_url:
165 description: The full url requested.
166 returned: always
167 type: str
168 sample: /sys/login/user
169 response_code:
170 description: The status of api request.
171 returned: always
172 type: int
173 sample: 0
174 response_data:
175 description: The api response.
176 type: list
177 returned: always
178 response_message:
179 description: The descriptive message of the api response.
180 type: str
181 returned: always
182 sample: OK.
183 system_information:
184 description: The information of the target system.
185 type: dict
186 returned: always
187 rc:
188 description: The status the request.
189 type: int
190 returned: always
191 sample: 0
192 version_check_warning:
193 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
194 type: list
195 returned: complex
196 '''
197 from ansible.module_utils.basic import AnsibleModule
198 from ansible.module_utils.connection import Connection
199 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
200 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
201
202
203 def main():
204 urls_list = [
205 '/pm/config/adom/{adom}/obj/firewall/vip46/{vip46}/dynamic_mapping',
206 '/pm/config/global/obj/firewall/vip46/{vip46}/dynamic_mapping'
207 ]
208 module_arg_spec = {
209 'adom': {'required': True, 'type': 'str'},
210 'vip46': {'required': True, 'type': 'str'},
211 'revision_note': {'type': 'str'},
212 'firewall_vip46_dynamicmapping': {
213 'type': 'dict', 'v_range': [['6.0.0', '']],
214 'options': {
215 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
216 'arp-reply': {'choices': ['disable', 'enable'], 'type': 'str'},
217 'color': {'type': 'int'},
218 'comment': {'type': 'str'},
219 'extip': {'type': 'str'},
220 'extport': {'type': 'str'},
221 'id': {'type': 'int'},
222 'ldb-method': {'choices': ['static', 'round-robin', 'weighted', 'least-session', 'least-rtt', 'first-alive'], 'type': 'str'},
223 'mappedip': {'type': 'str'},
224 'mappedport': {'type': 'str'},
225 'monitor': {'type': 'raw'},
226 'portforward': {'choices': ['disable', 'enable'], 'type': 'str'},
227 'protocol': {'choices': ['tcp', 'udp'], 'type': 'str'},
228 'server-type': {'choices': ['http', 'tcp', 'udp', 'ip'], 'type': 'str'},
229 'src-filter': {'type': 'raw'},
230 'type': {'choices': ['static-nat', 'server-load-balance'], 'type': 'str'},
231 'uuid': {'type': 'str'},
232 'srcintf-filter': {'v_range': [['6.2.7', '6.2.13'], ['6.4.4', '']], 'type': 'raw'}
233 }
234 }
235 }
236
237 module_option_spec = get_module_arg_spec('full crud')
238 module_arg_spec.update(module_option_spec)
239 check_galaxy_version(module_arg_spec)
240 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_vip46_dynamicmapping'),
241 supports_check_mode=True)
242 if not module._socket_path:
243 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
244 connection = Connection(module._socket_path)
245 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
246 'complex:{{module}}["_scope"][0]["name"]+"/"+{{module}}["_scope"][0]["vdom"]', 'data', module, connection)
247 fmgr.process_crud()
248 module.exit_json(meta=module.params)
249
250
251 if __name__ == '__main__':
252 main()