Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_service_other.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_other
33 short_description: Manages service-other objects on Check Point over Web Services API
34 description:
35 - Manages service-other 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 accept_replies:
47 description:
48 - Specifies whether Other Service replies are to be accepted.
49 type: bool
50 action:
51 description:
52 - Contains an INSPECT expression that defines the action to take if a rule containing this service is matched.
53 Example, set r_mhandler &open_ssl_handler sets a handler on the connection.
54 - Available from R80.10 management version.
55 type: str
56 aggressive_aging:
57 description:
58 - Sets short (aggressive) timeouts for idle connections.
59 type: dict
60 suboptions:
61 default_timeout:
62 description:
63 - Default aggressive aging timeout in seconds.
64 type: int
65 enable:
66 description:
67 - N/A
68 type: bool
69 timeout:
70 description:
71 - Aggressive aging timeout in seconds.
72 type: int
73 use_default_timeout:
74 description:
75 - N/A
76 type: bool
77 ip_protocol:
78 description:
79 - IP protocol number.
80 type: int
81 keep_connections_open_after_policy_installation:
82 description:
83 - Keep connections open after policy has been installed even if they are not allowed under the new policy. This overrides the settings in the
84 Connection Persistence page. If you change this property, the change will not affect open connections, but only future connections.
85 type: bool
86 match:
87 description:
88 - Contains an INSPECT expression that defines the matching criteria. The connection is examined against the expression during the first packet.
89 Example, tcp, dport = 21, direction = 0 matches incoming FTP control connections.
90 - Available from R80.10 management version.
91 type: str
92 match_for_any:
93 description:
94 - 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
95 and protocol.
96 type: bool
97 override_default_settings:
98 description:
99 - Indicates whether this service is a Data Domain service which has been overridden.
100 - Available from R80.10 management version.
101 type: bool
102 session_timeout:
103 description:
104 - Time (in seconds) before the session times out.
105 type: int
106 sync_connections_on_cluster:
107 description:
108 - Enables state-synchronized High Availability or Load Sharing on a ClusterXL or OPSEC-certified cluster.
109 type: bool
110 tags:
111 description:
112 - Collection of tag identifiers.
113 type: list
114 elements: str
115 use_default_session_timeout:
116 description:
117 - Use default virtual session timeout.
118 - Available from R80.10 management version.
119 type: bool
120 color:
121 description:
122 - Color of the object. Should be one of existing colors.
123 type: str
124 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
125 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
126 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
127 comments:
128 description:
129 - Comments string.
130 type: str
131 details_level:
132 description:
133 - 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
134 representation of the object.
135 type: str
136 choices: ['uid', 'standard', 'full']
137 groups:
138 description:
139 - Collection of group identifiers.
140 type: list
141 elements: str
142 ignore_warnings:
143 description:
144 - Apply changes ignoring warnings.
145 type: bool
146 ignore_errors:
147 description:
148 - 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.
149 type: bool
150 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
151 """
152
153 EXAMPLES = """
154 - name: add-service-other
155 cp_mgmt_service_other:
156 aggressive_aging:
157 enable: true
158 timeout: 360
159 use_default_timeout: false
160 ip_protocol: 51
161 keep_connections_open_after_policy_installation: false
162 match_for_any: true
163 name: New_Service_1
164 session_timeout: 0
165 state: present
166 sync_connections_on_cluster: true
167
168 - name: set-service-other
169 cp_mgmt_service_other:
170 aggressive_aging:
171 default_timeout: 3600
172 color: green
173 name: New_Service_1
174 state: present
175
176 - name: delete-service-other
177 cp_mgmt_service_other:
178 name: New_Service_2
179 state: absent
180 """
181
182 RETURN = """
183 cp_mgmt_service_other:
184 description: The checkpoint object created or updated.
185 returned: always, except when deleting the object.
186 type: dict
187 """
188
189 from ansible.module_utils.basic import AnsibleModule
190 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
191 checkpoint_argument_spec_for_objects,
192 api_call,
193 )
194
195
196 def main():
197 argument_spec = dict(
198 name=dict(type="str", required=True),
199 accept_replies=dict(type="bool"),
200 action=dict(type="str"),
201 aggressive_aging=dict(
202 type="dict",
203 options=dict(
204 default_timeout=dict(type="int"),
205 enable=dict(type="bool"),
206 timeout=dict(type="int"),
207 use_default_timeout=dict(type="bool"),
208 ),
209 ),
210 ip_protocol=dict(type="int"),
211 keep_connections_open_after_policy_installation=dict(type="bool"),
212 match=dict(type="str"),
213 match_for_any=dict(type="bool"),
214 override_default_settings=dict(type="bool"),
215 session_timeout=dict(type="int"),
216 sync_connections_on_cluster=dict(type="bool"),
217 tags=dict(type="list", elements="str"),
218 use_default_session_timeout=dict(type="bool"),
219 color=dict(
220 type="str",
221 choices=[
222 "aquamarine",
223 "black",
224 "blue",
225 "crete blue",
226 "burlywood",
227 "cyan",
228 "dark green",
229 "khaki",
230 "orchid",
231 "dark orange",
232 "dark sea green",
233 "pink",
234 "turquoise",
235 "dark blue",
236 "firebrick",
237 "brown",
238 "forest green",
239 "gold",
240 "dark gold",
241 "gray",
242 "dark gray",
243 "light green",
244 "lemon chiffon",
245 "coral",
246 "sea green",
247 "sky blue",
248 "magenta",
249 "purple",
250 "slate blue",
251 "violet red",
252 "navy blue",
253 "olive",
254 "orange",
255 "red",
256 "sienna",
257 "yellow",
258 ],
259 ),
260 comments=dict(type="str"),
261 details_level=dict(type="str", choices=["uid", "standard", "full"]),
262 groups=dict(type="list", elements="str"),
263 ignore_warnings=dict(type="bool"),
264 ignore_errors=dict(type="bool"),
265 )
266 argument_spec.update(checkpoint_argument_spec_for_objects)
267
268 module = AnsibleModule(
269 argument_spec=argument_spec, supports_check_mode=True
270 )
271 api_call_object = "service-other"
272
273 result = api_call(module, api_call_object)
274 module.exit_json(**result)
275
276
277 if __name__ == "__main__":
278 main()