| 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_mobile_access_section |
| 31 |
short_description: Manages mobile-access-section objects on Checkpoint over Web Services API |
| 32 |
description: |
| 33 |
- Manages mobile-access-section objects on Checkpoint devices including creating, updating and removing objects. |
| 34 |
- All operations are performed over Web Services API. |
| 35 |
- Available from R82 management version. |
| 36 |
version_added: "6.0.0" |
| 37 |
author: "Eden Brillant (@chkp-edenbr)" |
| 38 |
options: |
| 39 |
position: |
| 40 |
description: |
| 41 |
- Position in the rulebase. |
| 42 |
type: str |
| 43 |
relative_position: |
| 44 |
description: |
| 45 |
- Position in the rulebase. |
| 46 |
- Use of this field is relevant only for "add" operation. |
| 47 |
type: dict |
| 48 |
suboptions: |
| 49 |
below: |
| 50 |
description: |
| 51 |
- Add section below specific rule/section identified by name. |
| 52 |
type: str |
| 53 |
above: |
| 54 |
description: |
| 55 |
- Add section above specific rule/section identified by name. |
| 56 |
type: str |
| 57 |
top: |
| 58 |
description: |
| 59 |
- Add section to the top of a specific section identified by name. |
| 60 |
type: str |
| 61 |
bottom: |
| 62 |
description: |
| 63 |
- Add section to the bottom of a specific section identified by name. |
| 64 |
type: str |
| 65 |
tags: |
| 66 |
description: |
| 67 |
- Collection of tag identifiers. |
| 68 |
type: list |
| 69 |
elements: str |
| 70 |
name: |
| 71 |
description: |
| 72 |
- Object name. |
| 73 |
type: str |
| 74 |
required: True |
| 75 |
details_level: |
| 76 |
description: |
| 77 |
- 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 |
| 78 |
representation of the object. |
| 79 |
type: str |
| 80 |
choices: ['uid', 'standard', 'full'] |
| 81 |
ignore_warnings: |
| 82 |
description: |
| 83 |
- Apply changes ignoring warnings. |
| 84 |
type: bool |
| 85 |
ignore_errors: |
| 86 |
description: |
| 87 |
- 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. |
| 88 |
type: bool |
| 89 |
extends_documentation_fragment: check_point.mgmt.checkpoint_objects |
| 90 |
""" |
| 91 |
|
| 92 |
EXAMPLES = """ |
| 93 |
- name: add-mobile-access-section |
| 94 |
cp_mgmt_mobile_access_section: |
| 95 |
name: New Section 1 |
| 96 |
position: 1 |
| 97 |
state: present |
| 98 |
|
| 99 |
- name: set-mobile-access-section |
| 100 |
cp_mgmt_mobile_access_section: |
| 101 |
name: New Section 1 |
| 102 |
state: present |
| 103 |
tags: |
| 104 |
- MA-section |
| 105 |
|
| 106 |
- name: delete-mobile-access-section |
| 107 |
cp_mgmt_mobile_access_section: |
| 108 |
name: New Section 1 |
| 109 |
state: absent |
| 110 |
""" |
| 111 |
|
| 112 |
RETURN = """ |
| 113 |
cp_mgmt_mobile_access_section: |
| 114 |
description: The checkpoint object created or updated. |
| 115 |
returned: always, except when deleting the object. |
| 116 |
type: dict |
| 117 |
""" |
| 118 |
|
| 119 |
from ansible.module_utils.basic import AnsibleModule |
| 120 |
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call |
| 121 |
|
| 122 |
|
| 123 |
def main(): |
| 124 |
argument_spec = dict( |
| 125 |
position=dict(type='str'), |
| 126 |
relative_position=dict( |
| 127 |
type="dict", |
| 128 |
options=dict( |
| 129 |
below=dict(type="str"), |
| 130 |
above=dict(type="str"), |
| 131 |
top=dict(type="str"), |
| 132 |
bottom=dict(type="str"), |
| 133 |
), |
| 134 |
), |
| 135 |
tags=dict(type='list', elements='str'), |
| 136 |
name=dict(type='str', required=True), |
| 137 |
details_level=dict(type='str', choices=['uid', 'standard', 'full']), |
| 138 |
ignore_warnings=dict(type='bool'), |
| 139 |
ignore_errors=dict(type='bool') |
| 140 |
) |
| 141 |
argument_spec.update(checkpoint_argument_spec_for_objects) |
| 142 |
|
| 143 |
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) |
| 144 |
api_call_object = 'mobile-access-section' |
| 145 |
|
| 146 |
if module.params["relative_position"] is not None: |
| 147 |
if module.params["position"] is not None: |
| 148 |
raise AssertionError( |
| 149 |
"The use of both 'relative_position' and 'position' arguments isn't allowed" |
| 150 |
) |
| 151 |
module.params["position"] = module.params["relative_position"] |
| 152 |
module.params.pop("relative_position") |
| 153 |
|
| 154 |
result = api_call(module, api_call_object) |
| 155 |
module.exit_json(**result) |
| 156 |
|
| 157 |
|
| 158 |
if __name__ == '__main__': |
| 159 |
main() |