Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_vipgrp.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_vipgrp
15 short_description: Configure IPv4 virtual IP groups.
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 firewall_vipgrp:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 color:
34 type: int
35 description: Integer value to determine the color of the icon in the GUI
36 comments:
37 type: str
38 description: Comment.
39 dynamic_mapping:
40 type: list
41 elements: dict
42 description: Dynamic mapping.
43 suboptions:
44 _scope:
45 type: list
46 elements: dict
47 description: Scope.
48 suboptions:
49 name:
50 type: str
51 description: Name.
52 vdom:
53 type: str
54 description: Vdom.
55 color:
56 type: int
57 description: Color.
58 comments:
59 type: str
60 description: Comments.
61 interface:
62 type: str
63 description: Interface.
64 member:
65 type: raw
66 description: (list or str) Member.
67 uuid:
68 type: str
69 description: Uuid.
70 interface:
71 type: str
72 description: Interface.
73 member:
74 type: raw
75 description: (list or str) Member VIP objects of the group
76 name:
77 type: str
78 description: VIP group name.
79 required: true
80 uuid:
81 type: str
82 description: Universally Unique Identifier
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 IPv4 virtual IP groups.
96 fortinet.fortimanager.fmgr_firewall_vipgrp:
97 bypass_validation: false
98 adom: ansible
99 state: present
100 firewall_vipgrp:
101 color: 2
102 comments: "ansible-test-vipgrp"
103 member: "ansible-test-vip"
104 name: "ansible-test-vipgrp"
105
106 - name: Gathering fortimanager facts
107 hosts: fortimanagers
108 gather_facts: false
109 connection: httpapi
110 vars:
111 ansible_httpapi_use_ssl: true
112 ansible_httpapi_validate_certs: false
113 ansible_httpapi_port: 443
114 tasks:
115 - name: Retrieve all the IPv4 virtual IP groups
116 fortinet.fortimanager.fmgr_fact:
117 facts:
118 selector: "firewall_vipgrp"
119 params:
120 adom: "ansible"
121 vipgrp: "your_value"
122 '''
123
124 RETURN = '''
125 meta:
126 description: The result of the request.
127 type: dict
128 returned: always
129 contains:
130 request_url:
131 description: The full url requested.
132 returned: always
133 type: str
134 sample: /sys/login/user
135 response_code:
136 description: The status of api request.
137 returned: always
138 type: int
139 sample: 0
140 response_data:
141 description: The api response.
142 type: list
143 returned: always
144 response_message:
145 description: The descriptive message of the api response.
146 type: str
147 returned: always
148 sample: OK.
149 system_information:
150 description: The information of the target system.
151 type: dict
152 returned: always
153 rc:
154 description: The status the request.
155 type: int
156 returned: always
157 sample: 0
158 version_check_warning:
159 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
160 type: list
161 returned: complex
162 '''
163 from ansible.module_utils.basic import AnsibleModule
164 from ansible.module_utils.connection import Connection
165 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
166 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
167
168
169 def main():
170 urls_list = [
171 '/pm/config/adom/{adom}/obj/firewall/vipgrp',
172 '/pm/config/global/obj/firewall/vipgrp'
173 ]
174 module_arg_spec = {
175 'adom': {'required': True, 'type': 'str'},
176 'revision_note': {'type': 'str'},
177 'firewall_vipgrp': {
178 'type': 'dict', 'v_range': [['6.0.0', '']],
179 'options': {
180 'color': {'type': 'int'},
181 'comments': {'type': 'str'},
182 'dynamic_mapping': {
183 'type': 'list',
184 'options': {
185 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
186 'color': {'type': 'int'},
187 'comments': {'type': 'str'},
188 'interface': {'type': 'str'},
189 'member': {'type': 'raw'},
190 'uuid': {'type': 'str'}
191 },
192 'elements': 'dict'
193 },
194 'interface': {'type': 'str'},
195 'member': {'type': 'raw'},
196 'name': {'required': True, 'type': 'str'},
197 'uuid': {'type': 'str'}
198 }
199 }
200 }
201
202 module_option_spec = get_module_arg_spec('full crud')
203 module_arg_spec.update(module_option_spec)
204 check_galaxy_version(module_arg_spec)
205 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_vipgrp'),
206 supports_check_mode=True)
207 if not module._socket_path:
208 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
209 connection = Connection(module._socket_path)
210 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
211 'name', 'data', module, connection)
212 fmgr.process_crud()
213 module.exit_json(meta=module.params)
214
215
216 if __name__ == '__main__':
217 main()