| 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_compliance_settings |
| 31 |
short_description: Edit existing Compliance Settings. |
| 32 |
description: |
| 33 |
- Edit existing Compliance Settings. |
| 34 |
- All operations are performed over Web Services API. |
| 35 |
- Available from R82.10 management version. |
| 36 |
version_added: "6.7.0" |
| 37 |
author: "Eden Brillant (@chkp-edenbr)" |
| 38 |
options: |
| 39 |
automatic_scan_scheduler: |
| 40 |
description: |
| 41 |
- Schedule for an automatic full Compliance scan. |
| 42 |
type: dict |
| 43 |
suboptions: |
| 44 |
scan_day: |
| 45 |
description: |
| 46 |
- The scheduled day of the week for the Compliance scan. The default value is 'every_day'. |
| 47 |
type: str |
| 48 |
choices: ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'every_day'] |
| 49 |
scan_time: |
| 50 |
description: |
| 51 |
- The scheduled time of day for the Compliance scan in format, "HH:mm:ss". |
| 52 |
- The default value is "23:59:59". |
| 53 |
type: str |
| 54 |
scheduled_scan_on: |
| 55 |
description: |
| 56 |
- Enables or disables the scheduled scan. The default value is true. |
| 57 |
type: bool |
| 58 |
enable_email_alerts: |
| 59 |
description: |
| 60 |
- Enables or disables sending email alerts to SmartEvent (only for alerts). The default value is true. |
| 61 |
type: bool |
| 62 |
enable_smart_event_logs: |
| 63 |
description: |
| 64 |
- Enables or disables sending logs to SmartEvent. The default value is true. |
| 65 |
type: bool |
| 66 |
initialize_best_practices: |
| 67 |
description: |
| 68 |
- If true, creates all the default Best Practices again. |
| 69 |
- After the first scan completes, the value of this parameter is automatically set to false. |
| 70 |
- The default value is true for initial setup and false after first scan. |
| 71 |
type: bool |
| 72 |
partial_scan_delay: |
| 73 |
description: |
| 74 |
- Controls when the partial scan starts after publishing a session. The partial scan checks only the relevant firewall best practices. |
| 75 |
- If the value is < 0, the partial scan is disabled. |
| 76 |
- If the value is 0, the partial scan starts immediately after publishing. |
| 77 |
- If the value is > 0, the partial scan is delayed by the specified number of seconds after publishing. |
| 78 |
- The default value is '0'. |
| 79 |
type: int |
| 80 |
extends_documentation_fragment: check_point.mgmt.checkpoint_commands |
| 81 |
""" |
| 82 |
|
| 83 |
EXAMPLES = """ |
| 84 |
- name: set-compliance-settings |
| 85 |
cp_mgmt_set_compliance_settings: |
| 86 |
automatic_scan_scheduler: |
| 87 |
scan_day: sunday |
| 88 |
scan_time: 08:00:00 |
| 89 |
scheduled_scan_on: false |
| 90 |
partial_scan_delay: -1 |
| 91 |
""" |
| 92 |
|
| 93 |
RETURN = """ |
| 94 |
cp_mgmt_set_compliance_settings: |
| 95 |
description: The checkpoint set-compliance-settings output. |
| 96 |
returned: always. |
| 97 |
type: dict |
| 98 |
""" |
| 99 |
|
| 100 |
from ansible.module_utils.basic import AnsibleModule |
| 101 |
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_commands, api_command |
| 102 |
|
| 103 |
|
| 104 |
def main(): |
| 105 |
argument_spec = dict( |
| 106 |
automatic_scan_scheduler=dict(type='dict', options=dict( |
| 107 |
scan_day=dict(type='str', choices=['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'every_day']), |
| 108 |
scan_time=dict(type='str'), |
| 109 |
scheduled_scan_on=dict(type='bool') |
| 110 |
)), |
| 111 |
enable_email_alerts=dict(type='bool'), |
| 112 |
enable_smart_event_logs=dict(type='bool'), |
| 113 |
initialize_best_practices=dict(type='bool'), |
| 114 |
partial_scan_delay=dict(type='int') |
| 115 |
) |
| 116 |
argument_spec.update(checkpoint_argument_spec_for_commands) |
| 117 |
|
| 118 |
module = AnsibleModule(argument_spec=argument_spec) |
| 119 |
|
| 120 |
command = "set-compliance-settings" |
| 121 |
|
| 122 |
result = api_command(module, command) |
| 123 |
module.exit_json(**result) |
| 124 |
|
| 125 |
|
| 126 |
if __name__ == '__main__': |
| 127 |
main() |