| 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_policy_settings |
| 31 |
short_description: Edit Policy settings, the changes will be applied after publish. |
| 32 |
description: |
| 33 |
- Edit Policy settings, the changes will be applied after publish. |
| 34 |
- All operations are performed over Web Services API. |
| 35 |
- Available from R81.10 management version. |
| 36 |
version_added: "5.0.0" |
| 37 |
author: "Eden Brillant (@chkp-edenbr)" |
| 38 |
options: |
| 39 |
last_in_cell: |
| 40 |
description: |
| 41 |
- Added object after removing the last object in cell. |
| 42 |
type: str |
| 43 |
choices: ['none', 'restore to default'] |
| 44 |
none_object_behavior: |
| 45 |
description: |
| 46 |
- a 'None' object behavior. Rules with object 'None' will never be matched. |
| 47 |
type: str |
| 48 |
choices: ['warning', 'error', 'none'] |
| 49 |
security_access_defaults: |
| 50 |
description: |
| 51 |
- Access Policy default values. |
| 52 |
type: dict |
| 53 |
suboptions: |
| 54 |
destination: |
| 55 |
description: |
| 56 |
- Destination default value for new rule creation. Any or None. |
| 57 |
type: str |
| 58 |
service: |
| 59 |
description: |
| 60 |
- Service and Applications default value for new rule creation. Any or None. |
| 61 |
type: str |
| 62 |
source: |
| 63 |
description: |
| 64 |
- Source default value for new rule creation. Any or None. |
| 65 |
type: str |
| 66 |
extends_documentation_fragment: check_point.mgmt.checkpoint_commands |
| 67 |
""" |
| 68 |
|
| 69 |
EXAMPLES = """ |
| 70 |
- name: set-policy-settings |
| 71 |
cp_mgmt_set_policy_settings: |
| 72 |
last_in_cell: any |
| 73 |
none_object_behavior: none |
| 74 |
security_access_defaults: |
| 75 |
destination: any |
| 76 |
service: any |
| 77 |
source: any |
| 78 |
""" |
| 79 |
|
| 80 |
RETURN = """ |
| 81 |
cp_mgmt_set_policy_settings: |
| 82 |
description: The checkpoint set-policy-settings output. |
| 83 |
returned: always. |
| 84 |
type: dict |
| 85 |
""" |
| 86 |
|
| 87 |
from ansible.module_utils.basic import AnsibleModule |
| 88 |
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_commands, api_command |
| 89 |
|
| 90 |
|
| 91 |
def main(): |
| 92 |
argument_spec = dict( |
| 93 |
last_in_cell=dict(type='str', choices=['none', 'restore to default']), |
| 94 |
none_object_behavior=dict(type='str', choices=['warning', 'error', 'none']), |
| 95 |
security_access_defaults=dict(type='dict', options=dict( |
| 96 |
destination=dict(type='str'), |
| 97 |
service=dict(type='str'), |
| 98 |
source=dict(type='str') |
| 99 |
)) |
| 100 |
) |
| 101 |
argument_spec.update(checkpoint_argument_spec_for_commands) |
| 102 |
|
| 103 |
module = AnsibleModule(argument_spec=argument_spec) |
| 104 |
|
| 105 |
command = "set-policy-settings" |
| 106 |
|
| 107 |
result = api_command(module, command) |
| 108 |
module.exit_json(**result) |
| 109 |
|
| 110 |
|
| 111 |
if __name__ == '__main__': |
| 112 |
main() |