|
| 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() |
0 commit comments