Skip to content

Commit f8bde4c

Browse files
committed
ansible version 2.0.0
1 parent 0d2f4ec commit f8bde4c

File tree

5 files changed

+287
-1
lines changed

5 files changed

+287
-1
lines changed

plugins/doc_fragments/checkpoint_commands.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ class ModuleDocFragment(object):
1717
- Wait for the task to end. Such as publish task.
1818
type: bool
1919
default: True
20+
wait_for_task_timeout:
21+
description:
22+
- How many minutes to wait until throwing a timeout error.
23+
type: int
24+
default: 30
2025
version:
2126
description:
2227
- Version of checkpoint. If not given one, the latest version taken.

plugins/doc_fragments/checkpoint_objects.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ class ModuleDocFragment(object):
3030
- Wait for the task to end. Such as publish task.
3131
type: bool
3232
default: True
33+
wait_for_task_timeout:
34+
description:
35+
- How many minutes to wait until throwing a timeout error.
36+
type: int
37+
default: 30
3338
version:
3439
description:
3540
- Version of checkpoint. If not given one, the latest version taken.

plugins/module_utils/checkpoint.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
checkpoint_argument_spec_for_objects = dict(
3838
auto_publish_session=dict(type='bool'),
3939
wait_for_task=dict(type='bool', default=True),
40+
wait_for_task_timeout=dict(type='int', default=30),
4041
state=dict(type='str', choices=['present', 'absent'], default='present'),
4142
version=dict(type='str')
4243
)
@@ -47,6 +48,7 @@
4748

4849
checkpoint_argument_spec_for_commands = dict(
4950
wait_for_task=dict(type='bool', default=True),
51+
wait_for_task_timeout=dict(type='int', default=30),
5052
version=dict(type='str')
5153
)
5254

@@ -70,6 +72,7 @@ def is_checkpoint_param(parameter):
7072
if parameter == 'auto_publish_session' or \
7173
parameter == 'state' or \
7274
parameter == 'wait_for_task' or \
75+
parameter == 'wait_for_task_timeout' or \
7376
parameter == 'version':
7477
return False
7578
return True
@@ -101,8 +104,11 @@ def get_payload_from_parameters(params):
101104
def wait_for_task(module, version, connection, task_id):
102105
task_id_payload = {'task-id': task_id, 'details-level': 'full'}
103106
task_complete = False
107+
minutes_until_timeout = 30
108+
if module.params['wait_for_task_timeout'] is not None and module.params['wait_for_task_timeout'] >= 0:
109+
minutes_until_timeout = module.params['wait_for_task_timeout']
110+
max_num_iterations = minutes_until_timeout * 30
104111
current_iteration = 0
105-
max_num_iterations = 300
106112

107113
# As long as there is a task in progress
108114
while not task_complete and current_iteration < max_num_iterations:
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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_set_session
31+
short_description: Edit user's current session.
32+
description:
33+
- Edit user's current session.
34+
- All operations are performed over Web Services API.
35+
version_added: "2.9"
36+
author: "Or Soffer (@chkp-orso)"
37+
options:
38+
description:
39+
description:
40+
- Session description.
41+
type: str
42+
new_name:
43+
description:
44+
- New name of the object.
45+
type: str
46+
tags:
47+
description:
48+
- Collection of tag identifiers.
49+
type: list
50+
color:
51+
description:
52+
- Color of the object. Should be one of existing colors.
53+
type: str
54+
choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
55+
'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
56+
'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
57+
comments:
58+
description:
59+
- Comments string.
60+
type: str
61+
details_level:
62+
description:
63+
- 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
64+
representation of the object.
65+
type: str
66+
choices: ['uid', 'standard', 'full']
67+
ignore_warnings:
68+
description:
69+
- Apply changes ignoring warnings.
70+
type: bool
71+
ignore_errors:
72+
description:
73+
- 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.
74+
type: bool
75+
extends_documentation_fragment: check_point.mgmt.checkpoint_commands
76+
"""
77+
78+
EXAMPLES = """
79+
- name: set-session
80+
cp_mgmt_set_session:
81+
description: Session to work on ticket number CR00323665
82+
state: present
83+
"""
84+
85+
RETURN = """
86+
cp_mgmt_set_session:
87+
description: The checkpoint set-session output.
88+
returned: always.
89+
type: dict
90+
"""
91+
92+
from ansible.module_utils.basic import AnsibleModule
93+
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_commands, api_command
94+
95+
96+
def main():
97+
argument_spec = dict(
98+
description=dict(type='str'),
99+
new_name=dict(type='str'),
100+
tags=dict(type='list'),
101+
color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
102+
'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown',
103+
'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green',
104+
'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna',
105+
'yellow']),
106+
comments=dict(type='str'),
107+
details_level=dict(type='str', choices=['uid', 'standard', 'full']),
108+
ignore_warnings=dict(type='bool'),
109+
ignore_errors=dict(type='bool')
110+
)
111+
argument_spec.update(checkpoint_argument_spec_for_commands)
112+
113+
module = AnsibleModule(argument_spec=argument_spec)
114+
115+
command = "set-session"
116+
117+
result = api_command(module, command)
118+
module.exit_json(**result)
119+
120+
121+
if __name__ == '__main__':
122+
main()
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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_show_logs
31+
short_description: Showing logs according to the given filter.
32+
description:
33+
- Showing logs according to the given filter.
34+
- All operations are performed over Web Services API.
35+
version_added: "2.9"
36+
author: "Or Soffer (@chkp-orso)"
37+
options:
38+
new_query:
39+
description:
40+
- Running a new query.
41+
type: dict
42+
suboptions:
43+
filter:
44+
description:
45+
- The filter as entered in SmartConsole/SmartView.
46+
type: str
47+
time_frame:
48+
description:
49+
- Specify the time frame to query logs.
50+
type: str
51+
choices: ['last-7-days', 'last-hour', 'today', 'last-24-hours', 'yesterday', 'this-week', 'this-month', 'last-30-days', 'all-time', 'custom']
52+
custom_start:
53+
description:
54+
- This option is only applicable when using the custom time-frame option.
55+
type: str
56+
custom_end:
57+
description:
58+
- This option is only applicable when using the custom time-frame option.
59+
type: str
60+
max_logs_per_request:
61+
description:
62+
- Limit the number of logs to be retrieved.
63+
type: int
64+
top:
65+
description:
66+
- Top results configuration.
67+
type: dict
68+
suboptions:
69+
field:
70+
description:
71+
- The field on which the top command is executed.
72+
type: str
73+
choices: ['sources', 'destinations', 'services', 'actions', 'blades' , 'origins', 'users', 'applications']
74+
count:
75+
description:
76+
- The number of results to retrieve.
77+
type: int
78+
type:
79+
description:
80+
- Type of logs to return.
81+
type: str
82+
choices: ['logs', 'audit']
83+
log_servers:
84+
description:
85+
- List of IP's of logs servers to query.
86+
type: list
87+
query_id:
88+
description:
89+
- Get the next page of last run query with specified limit.
90+
type: str
91+
ignore_warnings:
92+
description:
93+
- Ignore warnings if exist.
94+
type: bool
95+
extends_documentation_fragment: check_point.mgmt.checkpoint_commands
96+
"""
97+
98+
EXAMPLES = """
99+
- name: show-logs
100+
cp_mgmt_show_logs:
101+
new_query:
102+
filter: blade:"Threat Emulation"
103+
max_logs_per_request: '2'
104+
time_frame: today
105+
"""
106+
107+
RETURN = """
108+
cp_mgmt_show_logs:
109+
description: The checkpoint show-logs output.
110+
returned: always.
111+
type: dict
112+
"""
113+
114+
from ansible.module_utils.basic import AnsibleModule
115+
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_commands, api_command
116+
117+
118+
def main():
119+
argument_spec = dict(
120+
new_query=dict(type='dict', options=dict(
121+
filter=dict(type='str'),
122+
time_frame=dict(type='str', choices=['last-7-days', 'last-hour', 'today', 'last-24-hours', 'yesterday',
123+
'this-week', 'this-month', 'last-30-days', 'all-time', 'custom']),
124+
custom_start=dict(type='str'),
125+
custom_end=dict(type='str'),
126+
max_logs_per_request=dict(type='int'),
127+
top=dict(type='dict', options=dict(
128+
field=dict(type='str', choices=['sources', 'destinations', 'services', 'actions', 'blades', 'origins', 'users', 'applications']),
129+
count=dict(type='int')
130+
)),
131+
type=dict(type='str', choices=['logs', 'audit']),
132+
log_servers=dict(type='list')
133+
)),
134+
query_id=dict(type='str'),
135+
ignore_warnings=dict(type='bool')
136+
)
137+
argument_spec.update(checkpoint_argument_spec_for_commands)
138+
139+
module = AnsibleModule(argument_spec=argument_spec)
140+
141+
command = "show-logs"
142+
143+
result = api_command(module, command)
144+
module.exit_json(**result)
145+
146+
147+
if __name__ == '__main__':
148+
main()

0 commit comments

Comments
 (0)