Skip to content

Commit b55d150

Browse files
Merge pull request #60 from chkp-shirango/master
Add lsm modules
2 parents 4fb91a2 + f90b5aa commit b55d150

File tree

4 files changed

+748
-0
lines changed

4 files changed

+748
-0
lines changed
Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
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_lsm_cluster
31+
short_description: Manages lsm-cluster objects on Checkpoint over Web Services API
32+
description:
33+
- Manages lsm-cluster objects on Checkpoint devices including creating, updating and removing objects.
34+
- All operations are performed over Web Services API.
35+
version_added: "2.9"
36+
author: "Shiran Golzar (@chkp-shirango)"
37+
options:
38+
main_ip_address:
39+
description:
40+
- Main IP address.
41+
type: str
42+
name_prefix:
43+
description:
44+
- A prefix added to the profile name and creates the LSM cluster name.
45+
type: str
46+
name_suffix:
47+
description:
48+
- A suffix added to the profile name and creates the LSM cluster name.
49+
type: str
50+
security_profile:
51+
description:
52+
- LSM profile.
53+
type: str
54+
interfaces:
55+
description:
56+
- Interfaces.
57+
type: list
58+
suboptions:
59+
name:
60+
description:
61+
- Interface name.
62+
type: str
63+
ip_address_override:
64+
description:
65+
- IP address override. Net mask is defined by the attached LSM profile.
66+
type: str
67+
member_network_override:
68+
description:
69+
- Member network override. Net mask is defined by the attached LSM profile.
70+
type: str
71+
members:
72+
description:
73+
- Members.
74+
type: list
75+
suboptions:
76+
name:
77+
description:
78+
- Object name.
79+
type: str
80+
provisioning_settings:
81+
description:
82+
- Provisioning settings. This field is relevant just for SMB clusters.
83+
type: dict
84+
suboptions:
85+
provisioning_profile:
86+
description:
87+
- Provisioning profile.
88+
type: str
89+
provisioning_state:
90+
description:
91+
- Provisioning state. This field is relevant just for SMB clusters. By default the state is 'manual'- enable provisioning but not attach
92+
to profile.If 'using-profile' state is provided a provisioning profile must be provided in provisioning-settings.
93+
type: str
94+
choices: ['off', 'manual', 'using-profile']
95+
sic:
96+
description:
97+
- Secure Internal Communication.
98+
type: dict
99+
suboptions:
100+
ip_address:
101+
description:
102+
- IP address. When IP address is provided- initiate trusted communication immediately using this IP address.
103+
type: str
104+
one_time_password:
105+
description:
106+
- One-time password. When one-time password is provided without ip-address- trusted communication is
107+
automatically initiated when the gateway connects to the Security Management server for the first time.
108+
type: str
109+
tags:
110+
description:
111+
- Collection of tag identifiers.
112+
type: list
113+
color:
114+
description:
115+
- Color of the object. Should be one of existing colors.
116+
type: str
117+
choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange',
118+
'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray',
119+
'light green', 'lemon chiffon', 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive',
120+
'orange', 'red', 'sienna', 'yellow']
121+
comments:
122+
description:
123+
- Comments string.
124+
type: str
125+
color:
126+
description:
127+
- Color of the object. Should be one of existing colors.
128+
type: str
129+
choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
130+
'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
131+
'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
132+
comments:
133+
description:
134+
- Comments string.
135+
type: str
136+
details_level:
137+
description:
138+
- 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
139+
representation of the object.
140+
type: str
141+
choices: ['uid', 'standard', 'full']
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-lsm-cluster
155+
cp_mgmt_lsm_cluster:
156+
interfaces:
157+
- ip_address_override: 192.168.8.197
158+
member_network_override: 192.168.8.0
159+
name: eth0
160+
new_name: WAN
161+
- ip_address_override: 10.8.197.1
162+
member_network_override: 10.8.197.0
163+
name: eth1
164+
new_name: LAN1
165+
- member_network_override: 10.10.10.0
166+
name: eth2
167+
main_ip_address: 192.168.8.197
168+
members:
169+
- name: Gaia_gw1
170+
sic:
171+
ip_address: 192.168.8.200
172+
one_time_password: aaaa
173+
- name: Gaia_gw2
174+
sic:
175+
ip_address: 192.168.8.202
176+
one_time_password: aaaa
177+
name_prefix: Gaia_
178+
security_profile: gaia_cluster
179+
state: present
180+
181+
- name: set-lsm-cluster
182+
cp_mgmt_lsm_cluster:
183+
interfaces:
184+
- ip_address_override: 192.168.8.197
185+
member_network_override: 192.168.8.0
186+
name: eth0
187+
new_name: WAN
188+
- ip_address_override: 10.8.197.1
189+
member_network_override: 10.8.197.0
190+
name: eth1
191+
new_name: LAN1
192+
- member_network_override: 10.10.10.0
193+
name: eth2
194+
members:
195+
- name: Gaia_gw1
196+
sic:
197+
ip_address: 192.168.8.200
198+
one_time_password: aaaa
199+
- name: Gaia_gw2
200+
sic:
201+
ip_address: 192.168.8.202
202+
one_time_password: aaaa
203+
name: Gaia_gaia_cluster
204+
state: present
205+
206+
- name: delete-lsm-cluster
207+
cp_mgmt_lsm_cluster:
208+
name: lsm_cluster
209+
state: absent
210+
"""
211+
212+
RETURN = """
213+
cp_mgmt_lsm_cluster:
214+
description: The checkpoint object created or updated.
215+
returned: always, except when deleting the object.
216+
type: dict
217+
"""
218+
219+
from ansible.module_utils.basic import AnsibleModule
220+
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call
221+
222+
223+
def main():
224+
argument_spec = dict(
225+
main_ip_address=dict(type='str'),
226+
name_prefix=dict(type='str'),
227+
name_suffix=dict(type='str'),
228+
security_profile=dict(type='str', required=True),
229+
interfaces=dict(type='list', options=dict(
230+
name=dict(type='str'),
231+
ip_address_override=dict(type='str'),
232+
member_network_override=dict(type='str')
233+
)),
234+
members=dict(type='list', options=dict(
235+
name=dict(type='str'),
236+
provisioning_settings=dict(type='dict', options=dict(
237+
provisioning_profile=dict(type='str')
238+
)),
239+
provisioning_state=dict(type='str', choices=['off', 'manual', 'using-profile']),
240+
sic=dict(type='dict', options=dict(
241+
ip_address=dict(type='str'),
242+
one_time_password=dict(type='str')
243+
)),
244+
tags=dict(type='list'),
245+
color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan',
246+
'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick',
247+
'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral',
248+
'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red',
249+
'sienna', 'yellow']),
250+
comments=dict(type='str')
251+
)),
252+
color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
253+
'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown',
254+
'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green',
255+
'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna',
256+
'yellow']),
257+
comments=dict(type='str'),
258+
details_level=dict(type='str', choices=['uid', 'standard', 'full']),
259+
ignore_warnings=dict(type='bool'),
260+
ignore_errors=dict(type='bool'),
261+
)
262+
argument_spec.update(checkpoint_argument_spec_for_objects)
263+
264+
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
265+
266+
# Create lsm-cluster name
267+
name = module.params['security_profile']
268+
269+
if module.params['name_prefix']:
270+
name = module.params['name_prefix'] + name
271+
if module.params['name_suffix']:
272+
name = name + module.params['name_suffix']
273+
module.params['name'] = name
274+
275+
api_call_object = 'lsm-cluster'
276+
277+
result = api_call(module, api_call_object)
278+
module.exit_json(**result)
279+
280+
281+
if __name__ == '__main__':
282+
main()

0 commit comments

Comments
 (0)