| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
# |
| 4 |
# Ansible module to manage Check Point 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 = { |
| 25 |
"metadata_version": "1.1", |
| 26 |
"status": ["preview"], |
| 27 |
"supported_by": "community", |
| 28 |
} |
| 29 |
|
| 30 |
DOCUMENTATION = """ |
| 31 |
--- |
| 32 |
module: cp_mgmt_global_assignment |
| 33 |
short_description: Manages global-assignment objects on Check Point over Web Services API |
| 34 |
description: |
| 35 |
- Manages global-assignment objects on Check Point devices including creating, updating and removing objects. |
| 36 |
- All operations are performed over Web Services API. |
| 37 |
- Available from R80 management version. |
| 38 |
version_added: "1.0.0" |
| 39 |
author: "Or Soffer (@chkp-orso)" |
| 40 |
options: |
| 41 |
dependent_domain: |
| 42 |
description: |
| 43 |
- N/A |
| 44 |
type: str |
| 45 |
global_access_policy: |
| 46 |
description: |
| 47 |
- Global domain access policy that is assigned to a dependent domain. |
| 48 |
type: str |
| 49 |
global_domain: |
| 50 |
description: |
| 51 |
- N/A |
| 52 |
type: str |
| 53 |
global_threat_prevention_policy: |
| 54 |
description: |
| 55 |
- Global domain threat prevention policy that is assigned to a dependent domain. |
| 56 |
type: str |
| 57 |
manage_protection_actions: |
| 58 |
description: |
| 59 |
- N/A |
| 60 |
type: bool |
| 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_objects |
| 76 |
""" |
| 77 |
|
| 78 |
EXAMPLES = """ |
| 79 |
- name: add-global-assignment |
| 80 |
cp_mgmt_global_assignment: |
| 81 |
dependent_domain: domain2 |
| 82 |
global_access_policy: standard |
| 83 |
global_domain: Global |
| 84 |
global_threat_prevention_policy: standard |
| 85 |
manage_protection_actions: true |
| 86 |
state: present |
| 87 |
|
| 88 |
- name: set-global-assignment |
| 89 |
cp_mgmt_global_assignment: |
| 90 |
dependent_domain: domain1 |
| 91 |
global_domain: Global2 |
| 92 |
global_threat_prevention_policy: '' |
| 93 |
manage_protection_actions: false |
| 94 |
state: present |
| 95 |
|
| 96 |
- name: delete-global-assignment |
| 97 |
cp_mgmt_global_assignment: |
| 98 |
dependent_domain: domain1 |
| 99 |
global_domain: Global2 |
| 100 |
state: absent |
| 101 |
""" |
| 102 |
|
| 103 |
RETURN = """ |
| 104 |
cp_mgmt_global_assignment: |
| 105 |
description: The checkpoint object created or updated. |
| 106 |
returned: always, except when deleting the object. |
| 107 |
type: dict |
| 108 |
""" |
| 109 |
|
| 110 |
from ansible.module_utils.basic import AnsibleModule |
| 111 |
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import ( |
| 112 |
checkpoint_argument_spec_for_objects, |
| 113 |
api_call, |
| 114 |
) |
| 115 |
|
| 116 |
|
| 117 |
def main(): |
| 118 |
argument_spec = dict( |
| 119 |
dependent_domain=dict(type="str"), |
| 120 |
global_access_policy=dict(type="str"), |
| 121 |
global_domain=dict(type="str"), |
| 122 |
global_threat_prevention_policy=dict(type="str"), |
| 123 |
manage_protection_actions=dict(type="bool"), |
| 124 |
details_level=dict(type="str", choices=["uid", "standard", "full"]), |
| 125 |
ignore_warnings=dict(type="bool"), |
| 126 |
ignore_errors=dict(type="bool"), |
| 127 |
) |
| 128 |
argument_spec.update(checkpoint_argument_spec_for_objects) |
| 129 |
|
| 130 |
module = AnsibleModule( |
| 131 |
argument_spec=argument_spec, supports_check_mode=True |
| 132 |
) |
| 133 |
api_call_object = "global-assignment" |
| 134 |
|
| 135 |
result = api_call(module, api_call_object) |
| 136 |
module.exit_json(**result) |
| 137 |
|
| 138 |
|
| 139 |
if __name__ == "__main__": |
| 140 |
main() |