Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_address_range.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Ansible module to manage Check Point Firewall (c) 2019
5 #
6 # Ansible is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Ansible is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 from __future__ import absolute_import, division, print_function
21
22 __metaclass__ = type
23
24 ANSIBLE_METADATA = {
25 "metadata_version": "1.1",
26 "status": ["preview"],
27 "supported_by": "community",
28 }
29
30 DOCUMENTATION = """
31 ---
32 module: cp_mgmt_address_range
33 short_description: Manages address-range objects on Check Point over Web Services API
34 description:
35 - Manages address-range objects on Check Point devices including creating, updating and removing objects.
36 - All operations are performed over Web Services API.
37 - Available from R80 management version.
38 version_added: "1.0.0"
39 author: "Or Soffer (@chkp-orso)"
40 options:
41 name:
42 description:
43 - Object name.
44 type: str
45 required: True
46 ip_address_first:
47 description:
48 - First IP address in the range. If both IPv4 and IPv6 address ranges are required, use the ipv4-address-first and the ipv6-address-first fields instead.
49 type: str
50 ipv4_address_first:
51 description:
52 - First IPv4 address in the range.
53 type: str
54 ipv6_address_first:
55 description:
56 - First IPv6 address in the range.
57 type: str
58 ip_address_last:
59 description:
60 - Last IP address in the range. If both IPv4 and IPv6 address ranges are required, use the ipv4-address-first and the ipv6-address-first fields instead.
61 type: str
62 ipv4_address_last:
63 description:
64 - Last IPv4 address in the range.
65 type: str
66 ipv6_address_last:
67 description:
68 - Last IPv6 address in the range.
69 type: str
70 nat_settings:
71 description:
72 - NAT settings.
73 type: dict
74 suboptions:
75 auto_rule:
76 description:
77 - Whether to add automatic address translation rules.
78 type: bool
79 ip_address:
80 description:
81 - IPv4 or IPv6 address. If both addresses are required use ipv4-address and ipv6-address fields explicitly. This parameter is not
82 required in case "method" parameter is "hide" and "hide-behind" parameter is "gateway".
83 type: str
84 ipv4_address:
85 description:
86 - IPv4 address.
87 type: str
88 ipv6_address:
89 description:
90 - IPv6 address.
91 type: str
92 hide_behind:
93 description:
94 - Hide behind method. This parameter is not required in case "method" parameter is "static".
95 type: str
96 choices: ['gateway', 'ip-address']
97 install_on:
98 description:
99 - Which gateway should apply the NAT translation.
100 type: str
101 method:
102 description:
103 - NAT translation method.
104 type: str
105 choices: ['hide', 'static']
106 tags:
107 description:
108 - Collection of tag identifiers.
109 type: list
110 elements: str
111 color:
112 description:
113 - Color of the object. Should be one of existing colors.
114 type: str
115 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
116 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
117 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
118 comments:
119 description:
120 - Comments string.
121 type: str
122 details_level:
123 description:
124 - The level of detail for some of the fields in the response can vary from showing only the UID value of the object to a fully detailed
125 representation of the object.
126 type: str
127 choices: ['uid', 'standard', 'full']
128 groups:
129 description:
130 - Collection of group identifiers.
131 type: list
132 elements: str
133 ignore_warnings:
134 description:
135 - Apply changes ignoring warnings.
136 type: bool
137 ignore_errors:
138 description:
139 - Apply changes ignoring errors. You won't be able to publish such a changes. If ignore-warnings flag was omitted - warnings will also be ignored.
140 type: bool
141 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
142 """
143
144 EXAMPLES = """
145 - name: add-address-range
146 cp_mgmt_address_range:
147 ip_address_first: 192.0.2.1
148 ip_address_last: 192.0.2.10
149 name: New Address Range 1
150 state: present
151
152 - name: set-address-range
153 cp_mgmt_address_range:
154 color: green
155 ip_address_first: 192.0.2.1
156 ip_address_last: 192.0.2.1
157 name: New Address Range 1
158 new_name: New Address Range 2
159 state: present
160
161 - name: delete-address-range
162 cp_mgmt_address_range:
163 name: New Address Range 2
164 state: absent
165 """
166
167 RETURN = """
168 cp_mgmt_address_range:
169 description: The checkpoint object created or updated.
170 returned: always, except when deleting the object.
171 type: dict
172 """
173
174 from ansible.module_utils.basic import AnsibleModule
175 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
176 checkpoint_argument_spec_for_objects,
177 api_call,
178 )
179
180
181 def main():
182 argument_spec = dict(
183 name=dict(type="str", required=True),
184 ip_address_first=dict(type="str"),
185 ipv4_address_first=dict(type="str"),
186 ipv6_address_first=dict(type="str"),
187 ip_address_last=dict(type="str"),
188 ipv4_address_last=dict(type="str"),
189 ipv6_address_last=dict(type="str"),
190 nat_settings=dict(
191 type="dict",
192 options=dict(
193 auto_rule=dict(type="bool"),
194 ip_address=dict(type="str"),
195 ipv4_address=dict(type="str"),
196 ipv6_address=dict(type="str"),
197 hide_behind=dict(
198 type="str", choices=["gateway", "ip-address"]
199 ),
200 install_on=dict(type="str"),
201 method=dict(type="str", choices=["hide", "static"]),
202 ),
203 ),
204 tags=dict(type="list", elements="str"),
205 color=dict(
206 type="str",
207 choices=[
208 "aquamarine",
209 "black",
210 "blue",
211 "crete blue",
212 "burlywood",
213 "cyan",
214 "dark green",
215 "khaki",
216 "orchid",
217 "dark orange",
218 "dark sea green",
219 "pink",
220 "turquoise",
221 "dark blue",
222 "firebrick",
223 "brown",
224 "forest green",
225 "gold",
226 "dark gold",
227 "gray",
228 "dark gray",
229 "light green",
230 "lemon chiffon",
231 "coral",
232 "sea green",
233 "sky blue",
234 "magenta",
235 "purple",
236 "slate blue",
237 "violet red",
238 "navy blue",
239 "olive",
240 "orange",
241 "red",
242 "sienna",
243 "yellow",
244 ],
245 ),
246 comments=dict(type="str"),
247 details_level=dict(type="str", choices=["uid", "standard", "full"]),
248 groups=dict(type="list", elements="str"),
249 ignore_warnings=dict(type="bool"),
250 ignore_errors=dict(type="bool"),
251 )
252 argument_spec.update(checkpoint_argument_spec_for_objects)
253
254 module = AnsibleModule(
255 argument_spec=argument_spec, supports_check_mode=True
256 )
257 api_call_object = "address-range"
258
259 result = api_call(module, api_call_object)
260 module.exit_json(**result)
261
262
263 if __name__ == "__main__":
264 main()