Debian Codegraph @

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

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Ansible module to manage CheckPoint 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 = {'metadata_version': '1.1',
25 'status': ['preview'],
26 'supported_by': 'community'}
27
28 DOCUMENTATION = """
29 ---
30 module: cp_mgmt_resource_tcp
31 short_description: Manages resource-tcp objects on Checkpoint over Web Services API
32 description:
33 - Manages resource-tcp objects on Checkpoint devices including creating, updating and removing objects.
34 - All operations are performed over Web Services API.
35 - Available from R82 JHF management version.
36 version_added: "6.5.0"
37 author: "Dor Berenstein (@chkp-dorbe)"
38 options:
39 name:
40 description:
41 - Object name.
42 type: str
43 required: True
44 resource_type:
45 description:
46 - The type of the TCP resource.
47 type: str
48 choices: ['cvp', 'ufp']
49 exception_track:
50 description:
51 - Configures how to track connections that match this rule but fail the content security checks. An example of an exception is a connection with
52 an unsupported scheme or method.
53 type: str
54 choices: ['none', 'exception log', 'exception alert']
55 ufp_settings:
56 description:
57 - UFP settings.
58 type: dict
59 suboptions:
60 server:
61 description:
62 - UFP server identified by name or UID. The UFP server must already be defined as an OPSEC Application.
63 type: str
64 caching_control:
65 description:
66 - Specifies if and how caching is to be enabled.
67 type: str
68 choices: ['security_gateway_one_request', 'security_gateway_two_requests', 'no_caching', 'ufp_server']
69 ignore_ufp_server_after_failure:
70 description:
71 - The UFP server will be ignored after numerous UFP server connections were unsuccessful.
72 type: bool
73 number_of_failures_before_ignore:
74 description:
75 - Signifies at what point the UFP server should be ignored, Applicable only if 'ignore after fail' is enabled.
76 type: int
77 timeout_before_reconnecting:
78 description:
79 - The amount of time, in seconds, that must pass before a UFP server connection should be attempted, Applicable only if 'ignore after
80 fail' is enabled.
81 type: int
82 cvp_settings:
83 description:
84 - CVP settings.
85 type: dict
86 suboptions:
87 server:
88 description:
89 - CVP server identified by name or UID. The CVP server must already be defined as an OPSEC Application.
90 type: str
91 allowed_to_modify_content:
92 description:
93 - Configures the CVP server to inspect but not modify content.
94 type: bool
95 reply_order:
96 description:
97 - Designates when the CVP server returns data to the Security Gateway security server.
98 type: str
99 choices: ['return_data_after_content_is_approved', 'return_data_before_content_is_approved']
100 color:
101 description:
102 - Color of the object. Should be one of existing colors.
103 type: str
104 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
105 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
106 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
107 comments:
108 description:
109 - Comments string.
110 type: str
111 details_level:
112 description:
113 - 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
114 representation of the object.
115 type: str
116 choices: ['uid', 'standard', 'full']
117 domains_to_process:
118 description:
119 - Indicates which domains to process the commands on. It cannot be used with the details-level full, must be run from the System Domain only and
120 with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
121 type: list
122 elements: str
123 tags:
124 description:
125 - Collection of tag identifiers.
126 type: list
127 elements: str
128 ignore_warnings:
129 description:
130 - Apply changes ignoring warnings.
131 type: bool
132 ignore_errors:
133 description:
134 - 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.
135 type: bool
136 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
137 """
138
139 EXAMPLES = """
140 - name: add-resource-tcp
141 cp_mgmt_resource_tcp:
142 name: newTcpResource
143 state: present
144 ufp_settings:
145 caching_control: security_gateway_one_request
146 ignore_ufp_server_after_failure: true
147 number_of_failures_before_ignore: 3
148 server: ufpServer
149
150 - name: set-resource-tcp
151 cp_mgmt_resource_tcp:
152 cvp_settings:
153 server: cvpServer
154 name: newTcpResource
155 state: present
156 ufp_settings:
157 caching_control: ufp_server
158 ignore_ufp_server_after_failure: false
159 number_of_failures_before_ignore: 0
160
161 - name: delete-resource-tcp
162 cp_mgmt_resource_tcp:
163 name: tcpResource
164 state: absent
165 """
166
167 RETURN = """
168 cp_mgmt_resource_tcp:
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 checkpoint_argument_spec_for_objects, api_call
176
177
178 def main():
179 argument_spec = dict(
180 name=dict(type='str', required=True),
181 resource_type=dict(type='str', choices=['cvp', 'ufp']),
182 exception_track=dict(type='str', choices=['none', 'exception log', 'exception alert']),
183 ufp_settings=dict(type='dict', options=dict(
184 server=dict(type='str'),
185 caching_control=dict(type='str', choices=['security_gateway_one_request', 'security_gateway_two_requests', 'no_caching', 'ufp_server']),
186 ignore_ufp_server_after_failure=dict(type='bool'),
187 number_of_failures_before_ignore=dict(type='int'),
188 timeout_before_reconnecting=dict(type='int')
189 )),
190 cvp_settings=dict(type='dict', options=dict(
191 server=dict(type='str'),
192 allowed_to_modify_content=dict(type='bool'),
193 reply_order=dict(type='str', choices=['return_data_after_content_is_approved', 'return_data_before_content_is_approved'])
194 )),
195 color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
196 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown',
197 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green',
198 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna',
199 'yellow']),
200 comments=dict(type='str'),
201 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
202 domains_to_process=dict(type='list', elements='str'),
203 tags=dict(type='list', elements='str'),
204 ignore_warnings=dict(type='bool'),
205 ignore_errors=dict(type='bool')
206 )
207 argument_spec.update(checkpoint_argument_spec_for_objects)
208
209 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
210 api_call_object = 'resource-tcp'
211
212 result = api_call(module, api_call_object)
213 module.exit_json(**result)
214
215
216 if __name__ == '__main__':
217 main()