Skip to content

Commit a531deb

Browse files
committed
upload version 1.5
1 parent 30fd444 commit a531deb

29 files changed

+2346
-25
lines changed

galaxy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace: check_point
99
name: mgmt
1010

1111
# The version of the collection. Must be compatible with semantic versioning
12-
version: 1.0.1
12+
version: 1.0.5
1313

1414
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
1515
readme: README.md
@@ -36,7 +36,7 @@ license_file: ''
3636

3737
# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character
3838
# requirements as 'namespace' and 'name'
39-
tags: []
39+
tags: [security]
4040

4141
# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
4242
# collection label 'namespace.name'. The value is a version range
@@ -51,7 +51,7 @@ repository: https://github.com/CheckPointSW/CheckPointAnsibleMgmtCollection
5151
documentation: https://docs.ansible.com/ansible/latest/modules/list_of_network_modules.html#check-point
5252

5353
# The URL to the homepage of the collection/project
54-
homepage: https://sc1.checkpoint.com/documents/latest/APIs/index.html#introduction~v1.5%20
54+
homepage: https://github.com/CheckPointSW/CheckPointAnsibleMgmtCollection
5555

5656
# The URL to the collection issue tracker
57-
issues: http://example.com/issue/tracker
57+
issues: https://github.com/CheckPointSW/CheckPointAnsibleMgmtCollection/issues

plugins/httpapi/checkpoint.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
- Specifies the domain of the Check Point device
2222
vars:
2323
- name: ansible_checkpoint_domain
24+
api_key:
25+
type: str
26+
description:
27+
- Login with api-key instead of user & password
28+
vars:
29+
- name: ansible_api_key
2430
"""
2531

2632
import json
@@ -33,21 +39,26 @@
3339

3440
BASE_HEADERS = {
3541
'Content-Type': 'application/json',
42+
'User-Agent': 'Ansible',
3643
}
3744

3845

3946
class HttpApi(HttpApiBase):
4047
def login(self, username, password):
41-
if username and password:
42-
cp_domain = self.get_option('domain')
43-
if cp_domain:
44-
payload = {'user': username, 'password': password, 'domain': cp_domain}
45-
else:
46-
payload = {'user': username, 'password': password}
47-
url = '/web_api/login'
48-
response, response_data = self.send_request(url, payload)
48+
payload = {}
49+
cp_domain = self.get_option('domain')
50+
cp_api_key = self.get_option('api_key')
51+
if cp_domain:
52+
payload['domain'] = cp_domain
53+
if username and password and not cp_api_key:
54+
payload['user'] = username
55+
payload['password'] = password
56+
elif cp_api_key and not username and not password:
57+
payload['api-key'] = cp_api_key
4958
else:
50-
raise AnsibleConnectionFailure('Username and password are required for login')
59+
raise AnsibleConnectionFailure('[Username and password] or api_key are required for login')
60+
url = '/web_api/login'
61+
response, response_data = self.send_request(url, payload)
5162

5263
try:
5364
self.connection._auth = {'X-chkp-sid': response_data['sid']}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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_access_section
31+
short_description: Manages access-section objects on Checkpoint over Web Services API
32+
description:
33+
- Manages access-section 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: "Or Soffer (@chkp-orso)"
37+
options:
38+
layer:
39+
description:
40+
- Layer that the rule belongs to identified by the name or UID.
41+
type: str
42+
position:
43+
description:
44+
- Position in the rulebase.
45+
type: str
46+
name:
47+
description:
48+
- Object name.
49+
type: str
50+
required: True
51+
details_level:
52+
description:
53+
- 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
54+
representation of the object.
55+
type: str
56+
choices: ['uid', 'standard', 'full']
57+
ignore_warnings:
58+
description:
59+
- Apply changes ignoring warnings.
60+
type: bool
61+
ignore_errors:
62+
description:
63+
- 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.
64+
type: bool
65+
extends_documentation_fragment: check_point.mgmt.checkpoint_objects
66+
"""
67+
68+
EXAMPLES = """
69+
- name: add-access-section
70+
cp_mgmt_access_section:
71+
layer: Network
72+
name: New Section 1
73+
position: 1
74+
state: present
75+
76+
- name: set-access-section
77+
cp_mgmt_access_section:
78+
layer: Network
79+
name: New Section 1
80+
state: present
81+
82+
- name: delete-access-section
83+
cp_mgmt_access_section:
84+
layer: Network
85+
name: New Section 2
86+
state: absent
87+
"""
88+
89+
RETURN = """
90+
cp_mgmt_access_section:
91+
description: The checkpoint object created or updated.
92+
returned: always, except when deleting the object.
93+
type: dict
94+
"""
95+
96+
from ansible.module_utils.basic import AnsibleModule
97+
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call
98+
99+
100+
def main():
101+
argument_spec = dict(
102+
layer=dict(type='str'),
103+
position=dict(type='str'),
104+
name=dict(type='str', required=True),
105+
details_level=dict(type='str', choices=['uid', 'standard', 'full']),
106+
ignore_warnings=dict(type='bool'),
107+
ignore_errors=dict(type='bool')
108+
)
109+
argument_spec.update(checkpoint_argument_spec_for_objects)
110+
111+
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
112+
api_call_object = 'access-section'
113+
114+
result = api_call(module, api_call_object)
115+
module.exit_json(**result)
116+
117+
118+
if __name__ == '__main__':
119+
main()
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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_api_key
31+
short_description: Add API key for administrator, to enable login with it. For the key to be valid publish is needed.
32+
description:
33+
- Add API key for administrator, to enable login with it. For the key to be valid publish is needed. <br>When using mgmt_cli tool, add -f json to get
34+
the key in the command's output.
35+
- All operations are performed over Web Services API.
36+
version_added: "2.9"
37+
author: "Or Soffer (@chkp-orso)"
38+
options:
39+
admin_uid:
40+
description:
41+
- Administrator uid to generate API key for.
42+
type: str
43+
admin_name:
44+
description:
45+
- Administrator name to generate API key for.
46+
type: str
47+
extends_documentation_fragment: check_point.mgmt.checkpoint_commands
48+
"""
49+
50+
EXAMPLES = """
51+
- name: add-api-key
52+
cp_mgmt_add_api_key:
53+
admin_name: admin
54+
state: present
55+
"""
56+
57+
RETURN = """
58+
cp_mgmt_add_api_key:
59+
description: The checkpoint add-api-key output.
60+
returned: always.
61+
type: dict
62+
"""
63+
64+
from ansible.module_utils.basic import AnsibleModule
65+
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_commands, api_command
66+
67+
68+
def main():
69+
argument_spec = dict(
70+
admin_uid=dict(type='str'),
71+
admin_name=dict(type='str')
72+
)
73+
argument_spec.update(checkpoint_argument_spec_for_commands)
74+
75+
module = AnsibleModule(argument_spec=argument_spec)
76+
77+
command = "add-api-key"
78+
79+
result = api_command(module, command)
80+
module.exit_json(**result)
81+
82+
83+
if __name__ == '__main__':
84+
main()

0 commit comments

Comments
 (0)