Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_geoipoverride.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_geoipoverride
15 short_description: Configure geographical location mapping for IP address
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 system_geoipoverride:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 description:
34 type: str
35 description: Description.
36 ip_range:
37 aliases: ['ip-range']
38 type: list
39 elements: dict
40 description: Ip range.
41 suboptions:
42 end_ip:
43 aliases: ['end-ip']
44 type: str
45 description: Final IP address, inclusive, of the address range
46 id:
47 type: int
48 description: ID number for individual entry in the IP-Range table.
49 start_ip:
50 aliases: ['start-ip']
51 type: str
52 description: Starting IP address, inclusive, of the address range
53 name:
54 type: str
55 description: Location name.
56 required: true
57 ip6_range:
58 aliases: ['ip6-range']
59 type: list
60 elements: dict
61 description: Ip6 range.
62 suboptions:
63 end_ip:
64 aliases: ['end-ip']
65 type: str
66 description: Ending IP address, inclusive, of the address range
67 id:
68 type: int
69 description: ID of individual entry in the IPv6 range table.
70 start_ip:
71 aliases: ['start-ip']
72 type: str
73 description: Starting IP address, inclusive, of the address range
74 '''
75
76 EXAMPLES = '''
77 - name: Example playbook
78 hosts: fortimanagers
79 gather_facts: false
80 connection: httpapi
81 vars:
82 ansible_httpapi_use_ssl: true
83 ansible_httpapi_validate_certs: false
84 ansible_httpapi_port: 443
85 tasks:
86 - name: Create the geoip
87 fortinet.fortimanager.fmgr_system_geoipoverride:
88 adom: ansible
89 state: present
90 system_geoipoverride:
91 name: ansible-test-geoipoverride
92
93 - name: Table of IP ranges assigned to country.
94 fortinet.fortimanager.fmgr_system_geoipoverride_iprange:
95 bypass_validation: false
96 adom: ansible
97 geoip_override: ansible-test-geoipoverride # name
98 state: present
99 system_geoipoverride_iprange:
100 end_ip: 222.222.222.25
101 id: 1
102 start_ip: 222.222.222.2
103 '''
104
105 RETURN = '''
106 meta:
107 description: The result of the request.
108 type: dict
109 returned: always
110 contains:
111 request_url:
112 description: The full url requested.
113 returned: always
114 type: str
115 sample: /sys/login/user
116 response_code:
117 description: The status of api request.
118 returned: always
119 type: int
120 sample: 0
121 response_data:
122 description: The api response.
123 type: list
124 returned: always
125 response_message:
126 description: The descriptive message of the api response.
127 type: str
128 returned: always
129 sample: OK.
130 system_information:
131 description: The information of the target system.
132 type: dict
133 returned: always
134 rc:
135 description: The status the request.
136 type: int
137 returned: always
138 sample: 0
139 version_check_warning:
140 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
141 type: list
142 returned: complex
143 '''
144 from ansible.module_utils.basic import AnsibleModule
145 from ansible.module_utils.connection import Connection
146 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
147 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
148
149
150 def main():
151 urls_list = [
152 '/pm/config/adom/{adom}/obj/system/geoip-override',
153 '/pm/config/global/obj/system/geoip-override'
154 ]
155 module_arg_spec = {
156 'adom': {'required': True, 'type': 'str'},
157 'revision_note': {'type': 'str'},
158 'system_geoipoverride': {
159 'type': 'dict', 'v_range': [['6.0.0', '']],
160 'options': {
161 'description': {'type': 'str'},
162 'ip-range': {
163 'type': 'list',
164 'options': {'end-ip': {'type': 'str'}, 'id': {'type': 'int'}, 'start-ip': {'type': 'str'}},
165 'elements': 'dict'
166 },
167 'name': {'required': True, 'type': 'str'},
168 'ip6-range': {
169 'v_range': [['6.4.0', '']],
170 'type': 'list',
171 'options': {
172 'end-ip': {'v_range': [['6.4.0', '']], 'type': 'str'},
173 'id': {'v_range': [['6.4.0', '']], 'type': 'int'},
174 'start-ip': {'v_range': [['6.4.0', '']], 'type': 'str'}
175 },
176 'elements': 'dict'
177 }
178 }
179 }
180 }
181
182 module_option_spec = get_module_arg_spec('full crud')
183 module_arg_spec.update(module_option_spec)
184 check_galaxy_version(module_arg_spec)
185 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_geoipoverride'),
186 supports_check_mode=True)
187 if not module._socket_path:
188 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
189 connection = Connection(module._socket_path)
190 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
191 'name', 'data', module, connection)
192 fmgr.process_crud()
193 module.exit_json(meta=module.params)
194
195
196 if __name__ == '__main__':
197 main()