Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_service_tcp.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_service_tcp
33 short_description: Manages service-tcp objects on Check Point over Web Services API
34 description:
35 - Manages service-tcp 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 aggressive_aging:
47 description:
48 - Sets short (aggressive) timeouts for idle connections.
49 type: dict
50 suboptions:
51 default_timeout:
52 description:
53 - Default aggressive aging timeout in seconds.
54 type: int
55 enable:
56 description:
57 - N/A
58 type: bool
59 timeout:
60 description:
61 - Aggressive aging timeout in seconds.
62 type: int
63 use_default_timeout:
64 description:
65 - N/A
66 type: bool
67 keep_connections_open_after_policy_installation:
68 description:
69 - Keep connections open after policy has been installed even if they are not allowed under the new policy. This overrides the settings in the
70 Connection Persistence page. If you change this property, the change will not affect open connections, but only future connections.
71 type: bool
72 match_by_protocol_signature:
73 description:
74 - A value of true enables matching by the selected protocol's signature - the signature identifies the protocol as genuine. Select this option
75 to limit the port to the specified protocol. If the selected protocol does not support matching by signature, this field cannot be set to true.
76 - Available from R80.10 management version.
77 type: bool
78 match_for_any:
79 description:
80 - Indicates whether this service is used when 'Any' is set as the rule's service and there are several service objects with the same source port
81 and protocol.
82 type: bool
83 override_default_settings:
84 description:
85 - Indicates whether this service is a Data Domain service which has been overridden.
86 - Available from R80.10 management version.
87 type: bool
88 port:
89 description:
90 - The number of the port used to provide this service. To specify a port range, place a hyphen between the lowest and highest port numbers, for
91 example 44-55.
92 type: str
93 protocol:
94 description:
95 - Select the protocol type associated with the service, and by implication, the management server (if any) that enforces Content Security and
96 Authentication for the service. Selecting a Protocol Type invokes the specific protocol handlers for each protocol type, thus enabling higher level of
97 security by parsing the protocol, and higher level of connectivity by tracking dynamic actions (such as opening of ports).
98 - Available from R80.10 management version.
99 type: str
100 session_timeout:
101 description:
102 - Time (in seconds) before the session times out.
103 type: int
104 source_port:
105 description:
106 - Port number for the client side service. If specified, only those Source port Numbers will be Accepted, Dropped, or Rejected during packet
107 inspection. Otherwise, the source port is not inspected.
108 type: str
109 sync_connections_on_cluster:
110 description:
111 - Enables state-synchronized High Availability or Load Sharing on a ClusterXL or OPSEC-certified cluster.
112 type: bool
113 tags:
114 description:
115 - Collection of tag identifiers.
116 type: list
117 elements: str
118 use_default_session_timeout:
119 description:
120 - Use default virtual session timeout.
121 - Available from R80.10 management version.
122 type: bool
123 color:
124 description:
125 - Color of the object. Should be one of existing colors.
126 type: str
127 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
128 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
129 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
130 comments:
131 description:
132 - Comments string.
133 type: str
134 details_level:
135 description:
136 - 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
137 representation of the object.
138 type: str
139 choices: ['uid', 'standard', 'full']
140 groups:
141 description:
142 - Collection of group identifiers.
143 type: list
144 elements: str
145 ignore_warnings:
146 description:
147 - Apply changes ignoring warnings.
148 type: bool
149 ignore_errors:
150 description:
151 - 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.
152 type: bool
153 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
154 """
155
156 EXAMPLES = """
157 - name: add-service-tcp
158 cp_mgmt_service_tcp:
159 aggressive_aging:
160 enable: true
161 timeout: 360
162 use_default_timeout: false
163 keep_connections_open_after_policy_installation: false
164 match_for_any: true
165 name: New_TCP_Service_1
166 port: 5669
167 session_timeout: 0
168 state: present
169 sync_connections_on_cluster: true
170
171 - name: set-service-tcp
172 cp_mgmt_service_tcp:
173 aggressive_aging:
174 default_timeout: 3600
175 color: green
176 name: New_TCP_Service_1
177 port: 5656
178 state: present
179
180 - name: delete-service-tcp
181 cp_mgmt_service_tcp:
182 name: New_TCP_Service_1
183 state: absent
184 """
185
186 RETURN = """
187 cp_mgmt_service_tcp:
188 description: The checkpoint object created or updated.
189 returned: always, except when deleting the object.
190 type: dict
191 """
192
193 from ansible.module_utils.basic import AnsibleModule
194 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
195 checkpoint_argument_spec_for_objects,
196 api_call,
197 )
198
199
200 def main():
201 argument_spec = dict(
202 name=dict(type="str", required=True),
203 aggressive_aging=dict(
204 type="dict",
205 options=dict(
206 default_timeout=dict(type="int"),
207 enable=dict(type="bool"),
208 timeout=dict(type="int"),
209 use_default_timeout=dict(type="bool"),
210 ),
211 ),
212 keep_connections_open_after_policy_installation=dict(type="bool"),
213 match_by_protocol_signature=dict(type="bool"),
214 match_for_any=dict(type="bool"),
215 override_default_settings=dict(type="bool"),
216 port=dict(type="str"),
217 protocol=dict(type="str"),
218 session_timeout=dict(type="int"),
219 source_port=dict(type="str"),
220 sync_connections_on_cluster=dict(type="bool"),
221 tags=dict(type="list", elements="str"),
222 use_default_session_timeout=dict(type="bool"),
223 color=dict(
224 type="str",
225 choices=[
226 "aquamarine",
227 "black",
228 "blue",
229 "crete blue",
230 "burlywood",
231 "cyan",
232 "dark green",
233 "khaki",
234 "orchid",
235 "dark orange",
236 "dark sea green",
237 "pink",
238 "turquoise",
239 "dark blue",
240 "firebrick",
241 "brown",
242 "forest green",
243 "gold",
244 "dark gold",
245 "gray",
246 "dark gray",
247 "light green",
248 "lemon chiffon",
249 "coral",
250 "sea green",
251 "sky blue",
252 "magenta",
253 "purple",
254 "slate blue",
255 "violet red",
256 "navy blue",
257 "olive",
258 "orange",
259 "red",
260 "sienna",
261 "yellow",
262 ],
263 ),
264 comments=dict(type="str"),
265 details_level=dict(type="str", choices=["uid", "standard", "full"]),
266 groups=dict(type="list", elements="str"),
267 ignore_warnings=dict(type="bool"),
268 ignore_errors=dict(type="bool"),
269 )
270 argument_spec.update(checkpoint_argument_spec_for_objects)
271
272 module = AnsibleModule(
273 argument_spec=argument_spec, supports_check_mode=True
274 )
275 api_call_object = "service-tcp"
276
277 result = api_call(module, api_call_object)
278 module.exit_json(**result)
279
280
281 if __name__ == "__main__":
282 main()