Skip to content

Commit af07104

Browse files
Add modules (#102)
* Add radius_group, radius_server, software_packages, repository_package modules * fix radius_group, radius_server, software_packages, repository_package modules
1 parent 031bf86 commit af07104

9 files changed

+1066
-0
lines changed

plugins/module_utils/checkpoint.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
"exception-group-name",
7676
"rule-name",
7777
"package",
78+
"ignore-errors",
79+
"ignore-warnings"
7880
]
7981

8082
remove_from_set_payload = {
@@ -295,6 +297,7 @@ def get_payload_from_parameters(params):
295297
if (
296298
parameter == "gateway_version"
297299
or parameter == "cluster_version"
300+
or parameter == "server_version"
298301
):
299302
parameter = "version"
300303

@@ -1145,6 +1148,7 @@ def build_payload(api_call_object, payload, params_to_remove):
11451148
if api_call_object in params_to_remove:
11461149
for param in params_to_remove[api_call_object]:
11471150
del payload[param]
1151+
11481152
return payload
11491153

11501154

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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_add_repository_package
31+
short_description: Add the software package to the central repository.<br>On Multi-Domain Server this command is available only after logging in to the Global
32+
domain.
33+
description:
34+
- Add the software package to the central repository.<br>On Multi-Domain Server this command is available only after logging in to the Global domain.
35+
- All operations are performed over Web Services API.
36+
version_added: "6.3.0"
37+
author: "Shiran Golzar (@chkp-shirango)"
38+
options:
39+
name:
40+
description:
41+
- The name of the repository package.
42+
type: str
43+
path:
44+
description:
45+
- The path of the repository package.<br><font color="red">Required only for</font> adding package from local.
46+
type: str
47+
source:
48+
description:
49+
- The source of the repository package.
50+
type: str
51+
choices: ['cloud', 'local']
52+
extends_documentation_fragment: check_point.mgmt.checkpoint_commands
53+
"""
54+
55+
EXAMPLES = """
56+
- name: add-repository-package
57+
cp_mgmt_add_repository_package:
58+
name: Check_Point_R80_20_JUMBO_HF_Bundle_T118_sk137592_Security_Gateway_and_Standalone_2_6_18_FULL.tgz
59+
path: /home/admin/
60+
source: local
61+
state: present
62+
"""
63+
64+
RETURN = """
65+
cp_mgmt_add_repository_package:
66+
description: The checkpoint add-repository-package output.
67+
returned: always.
68+
type: dict
69+
"""
70+
71+
from ansible.module_utils.basic import AnsibleModule
72+
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_commands, \
73+
api_command
74+
75+
76+
def main():
77+
argument_spec = dict(
78+
name=dict(type='str'),
79+
path=dict(type='str'),
80+
source=dict(type='str', choices=['cloud', 'local'])
81+
)
82+
argument_spec.update(checkpoint_argument_spec_for_commands)
83+
84+
module = AnsibleModule(argument_spec=argument_spec)
85+
86+
command = "add-repository-package"
87+
88+
result = api_command(module, command)
89+
module.exit_json(**result)
90+
91+
92+
if __name__ == '__main__':
93+
main()
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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_delete_repository_package
31+
short_description: Delete the repository software package from the central repository.<br>On Multi-Domain Server this command is available only after logging
32+
in to the Global domain.
33+
description:
34+
- Delete the repository software package from the central repository.<br>On Multi-Domain Server this command is available only after logging in to the
35+
Global domain.
36+
- All operations are performed over Web Services API.
37+
version_added: "6.3.0"
38+
author: "Shiran Golzar (@chkp-shirango)"
39+
options:
40+
name:
41+
description:
42+
- The name of the software package.
43+
type: str
44+
extends_documentation_fragment: check_point.mgmt.checkpoint_commands
45+
"""
46+
47+
EXAMPLES = """
48+
- name: delete-repository-package
49+
cp_mgmt_delete_repository_package:
50+
name: Check_Point_R80_20_JUMBO_HF_Bundle_T118_sk137592_Security_Gateway_and_Standalone_2_6_18_FULL.tgz
51+
state: absent
52+
"""
53+
54+
RETURN = """
55+
cp_mgmt_delete_repository_package:
56+
description: The checkpoint delete-repository-package output.
57+
returned: always.
58+
type: dict
59+
"""
60+
61+
from ansible.module_utils.basic import AnsibleModule
62+
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_commands, \
63+
api_command
64+
65+
66+
def main():
67+
argument_spec = dict(
68+
name=dict(type='str')
69+
)
70+
argument_spec.update(checkpoint_argument_spec_for_commands)
71+
72+
module = AnsibleModule(argument_spec=argument_spec)
73+
74+
command = "delete-repository-package"
75+
76+
result = api_command(module, command)
77+
module.exit_json(**result)
78+
79+
80+
if __name__ == '__main__':
81+
main()
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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_radius_group
31+
short_description: Manages radius-group objects on Checkpoint over Web Services API
32+
description:
33+
- Manages radius-group objects on Checkpoint devices including creating, updating and removing objects.
34+
- All operations are performed over Web Services API.
35+
version_added: "6.3.0"
36+
author: "Shiran Golzar (@chkp-shirango)"
37+
options:
38+
name:
39+
description:
40+
- Object name.
41+
type: str
42+
required: True
43+
members:
44+
description:
45+
- Collection of radius servers identified by the name or UID.
46+
type: list
47+
elements: str
48+
tags:
49+
description:
50+
- Collection of tag identifiers.
51+
type: list
52+
elements: str
53+
color:
54+
description:
55+
- Color of the object. Should be one of existing colors.
56+
type: str
57+
choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
58+
'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
59+
'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
60+
comments:
61+
description:
62+
- Comments string.
63+
type: str
64+
details_level:
65+
description:
66+
- 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
67+
representation of the object.
68+
type: str
69+
choices: ['uid', 'standard', 'full']
70+
groups:
71+
description:
72+
- Collection of group identifiers.
73+
type: list
74+
elements: str
75+
ignore_warnings:
76+
description:
77+
- Apply changes ignoring warnings.
78+
type: bool
79+
ignore_errors:
80+
description:
81+
- 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.
82+
type: bool
83+
extends_documentation_fragment: check_point.mgmt.checkpoint_objects
84+
"""
85+
86+
EXAMPLES = """
87+
- name: add-radius-group
88+
cp_mgmt_radius_group:
89+
members:
90+
- t4
91+
- radgroup
92+
name: radgroup
93+
state: present
94+
95+
- name: set-radius-group
96+
cp_mgmt_radius_group:
97+
members:
98+
- t4
99+
name: radgroup
100+
state: present
101+
102+
- name: delete-radius-group
103+
cp_mgmt_radius_group:
104+
ignore_warnings: 'true'
105+
name: testgroup
106+
state: absent
107+
"""
108+
109+
RETURN = """
110+
cp_mgmt_radius_group:
111+
description: The checkpoint object created or updated.
112+
returned: always, except when deleting the object.
113+
type: dict
114+
"""
115+
116+
from ansible.module_utils.basic import AnsibleModule
117+
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, \
118+
api_call
119+
120+
121+
def main():
122+
argument_spec = dict(
123+
name=dict(type='str', required=True),
124+
members=dict(type='list', elements='str'),
125+
tags=dict(type='list', elements="str"),
126+
color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
127+
'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise',
128+
'dark blue', 'firebrick', 'brown',
129+
'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green',
130+
'lemon chiffon', 'coral', 'sea green',
131+
'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue',
132+
'olive', 'orange', 'red', 'sienna',
133+
'yellow']),
134+
comments=dict(type='str'),
135+
details_level=dict(type='str', choices=['uid', 'standard', 'full']),
136+
groups=dict(type='list', elements='str'),
137+
ignore_warnings=dict(type='bool'),
138+
ignore_errors=dict(type='bool')
139+
)
140+
argument_spec.update(checkpoint_argument_spec_for_objects)
141+
142+
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
143+
api_call_object = 'radius-group'
144+
145+
result = api_call(module, api_call_object)
146+
module.exit_json(**result)
147+
148+
149+
if __name__ == '__main__':
150+
main()

0 commit comments

Comments
 (0)