| 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 = { |
| 25 |
"metadata_version": "1.1", |
| 26 |
"status": ["preview"], |
| 27 |
"supported_by": "community", |
| 28 |
} |
| 29 |
|
| 30 |
DOCUMENTATION = """ |
| 31 |
--- |
| 32 |
module: cp_mgmt_md_permissions_profile |
| 33 |
short_description: Manages md-permissions-profile objects on Checkpoint over Web Services API |
| 34 |
description: |
| 35 |
- Manages md-permissions-profile objects on Checkpoint devices including creating, updating and removing objects. |
| 36 |
- All operations are performed over Web Services API. |
| 37 |
- Available from R81.20 management version. |
| 38 |
version_added: "3.0.0" |
| 39 |
author: "Eden Brillant (@chkp-edenbr)" |
| 40 |
options: |
| 41 |
name: |
| 42 |
description: |
| 43 |
- Object name. |
| 44 |
type: str |
| 45 |
required: True |
| 46 |
permission_level: |
| 47 |
description: |
| 48 |
- The level of the Multi Domain Permissions Profile.<br>The level cannot be changed after creation. |
| 49 |
type: str |
| 50 |
choices: ['super user', 'manager', 'domain level only'] |
| 51 |
mds_provisioning: |
| 52 |
description: |
| 53 |
- Create and manage Multi-Domain Servers and Multi-Domain Log Servers.<br>Only a "Super User" permission-level profile can select this option. |
| 54 |
type: bool |
| 55 |
manage_admins: |
| 56 |
description: |
| 57 |
- Create and manage Multi-Domain Security Management administrators with the same or lower permission level. For example, a Domain manager |
| 58 |
cannot create Superusers or global managers.<br>Only a 'Manager' permission-level profile can edit this permission. |
| 59 |
type: bool |
| 60 |
manage_sessions: |
| 61 |
description: |
| 62 |
- Connect/disconnect Domain sessions, publish changes, and delete other administrator sessions.<br>Only a 'Manager' permission-level profile can |
| 63 |
edit this permission. |
| 64 |
type: bool |
| 65 |
management_api_login: |
| 66 |
description: |
| 67 |
- Permission to log in to the Security Management Server and run API commands using these tools, mgmt_cli (Linux and Windows binaries), Gaia CLI |
| 68 |
(clish) and Web Services (REST). Useful if you want to prevent administrators from running automatic scripts on the Management.<br>Note, This |
| 69 |
permission is not required to run commands from within the API terminal in SmartConsole. |
| 70 |
type: bool |
| 71 |
cme_operations: |
| 72 |
description: |
| 73 |
- Permission to read / edit the Cloud Management Extension (CME) configuration. |
| 74 |
type: str |
| 75 |
choices: ['read', 'write', 'disabled'] |
| 76 |
global_vpn_management: |
| 77 |
description: |
| 78 |
- Lets the administrator select Enable global use for a Security Gateway shown in the MDS Gateways & Servers view.<br>Only a 'Manager' |
| 79 |
permission-level profile can edit this permission. |
| 80 |
type: bool |
| 81 |
manage_global_assignments: |
| 82 |
description: |
| 83 |
- Controls the ability to create, edit and delete global assignment and not the ability to reassign, which is set according to the specific |
| 84 |
Domain's permission profile. |
| 85 |
type: bool |
| 86 |
enable_default_profile_for_global_domains: |
| 87 |
description: |
| 88 |
- Enable the option to specify a default profile for all global domains. |
| 89 |
type: bool |
| 90 |
default_profile_global_domains: |
| 91 |
description: |
| 92 |
- Name or UID of the required default profile for all global domains. |
| 93 |
type: str |
| 94 |
view_global_objects_in_domain: |
| 95 |
description: |
| 96 |
- Lets an administrator with no global objects permissions view the global objects in the domain. This option is required for valid domain management. |
| 97 |
type: bool |
| 98 |
enable_default_profile_for_local_domains: |
| 99 |
description: |
| 100 |
- Enable the option to specify a default profile for all local domains. |
| 101 |
type: bool |
| 102 |
default_profile_local_domains: |
| 103 |
description: |
| 104 |
- Name or UID of the required default profile for all local domains. |
| 105 |
type: str |
| 106 |
tags: |
| 107 |
description: |
| 108 |
- Collection of tag identifiers. |
| 109 |
type: list |
| 110 |
elements: str |
| 111 |
color: |
| 112 |
description: |
| 113 |
- Color of the object. Should be one of existing colors. |
| 114 |
type: str |
| 115 |
choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green', |
| 116 |
'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', |
| 117 |
'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow'] |
| 118 |
comments: |
| 119 |
description: |
| 120 |
- Comments string. |
| 121 |
type: str |
| 122 |
details_level: |
| 123 |
description: |
| 124 |
- 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 |
| 125 |
representation of the object. |
| 126 |
type: str |
| 127 |
choices: ['uid', 'standard', 'full'] |
| 128 |
domains_to_process: |
| 129 |
description: |
| 130 |
- Indicates which domains to process the commands on. It cannot be used with the details-level full, must be run from the System Domain only and |
| 131 |
with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER. |
| 132 |
type: list |
| 133 |
elements: str |
| 134 |
ignore_warnings: |
| 135 |
description: |
| 136 |
- Apply changes ignoring warnings. |
| 137 |
type: bool |
| 138 |
ignore_errors: |
| 139 |
description: |
| 140 |
- 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. |
| 141 |
type: bool |
| 142 |
extends_documentation_fragment: check_point.mgmt.checkpoint_objects |
| 143 |
""" |
| 144 |
|
| 145 |
EXAMPLES = """ |
| 146 |
- name: add-md-permissions-profile |
| 147 |
cp_mgmt_md_permissions_profile: |
| 148 |
name: manager profile |
| 149 |
state: present |
| 150 |
|
| 151 |
- name: set-md-permissions-profile |
| 152 |
cp_mgmt_md_permissions_profile: |
| 153 |
default_profile_global_domains: read write all |
| 154 |
name: manager profile |
| 155 |
permission_level: domain level only |
| 156 |
state: present |
| 157 |
|
| 158 |
- name: delete-md-permissions-profile |
| 159 |
cp_mgmt_md_permissions_profile: |
| 160 |
name: profile |
| 161 |
state: absent |
| 162 |
""" |
| 163 |
|
| 164 |
RETURN = """ |
| 165 |
cp_mgmt_md_permissions_profile: |
| 166 |
description: The checkpoint object created or updated. |
| 167 |
returned: always, except when deleting the object. |
| 168 |
type: dict |
| 169 |
""" |
| 170 |
|
| 171 |
from ansible.module_utils.basic import AnsibleModule |
| 172 |
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import ( |
| 173 |
checkpoint_argument_spec_for_objects, |
| 174 |
api_call, |
| 175 |
) |
| 176 |
|
| 177 |
|
| 178 |
def main(): |
| 179 |
argument_spec = dict( |
| 180 |
name=dict(type="str", required=True), |
| 181 |
permission_level=dict( |
| 182 |
type="str", choices=["super user", "manager", "domain level only"] |
| 183 |
), |
| 184 |
mds_provisioning=dict(type="bool"), |
| 185 |
manage_admins=dict(type="bool"), |
| 186 |
manage_sessions=dict(type="bool"), |
| 187 |
management_api_login=dict(type="bool"), |
| 188 |
cme_operations=dict(type="str", choices=["read", "write", "disabled"]), |
| 189 |
global_vpn_management=dict(type="bool"), |
| 190 |
manage_global_assignments=dict(type="bool"), |
| 191 |
enable_default_profile_for_global_domains=dict(type="bool"), |
| 192 |
default_profile_global_domains=dict(type="str"), |
| 193 |
view_global_objects_in_domain=dict(type="bool"), |
| 194 |
enable_default_profile_for_local_domains=dict(type="bool"), |
| 195 |
default_profile_local_domains=dict(type="str"), |
| 196 |
tags=dict(type="list", elements="str"), |
| 197 |
color=dict( |
| 198 |
type="str", |
| 199 |
choices=[ |
| 200 |
"aquamarine", |
| 201 |
"black", |
| 202 |
"blue", |
| 203 |
"crete blue", |
| 204 |
"burlywood", |
| 205 |
"cyan", |
| 206 |
"dark green", |
| 207 |
"khaki", |
| 208 |
"orchid", |
| 209 |
"dark orange", |
| 210 |
"dark sea green", |
| 211 |
"pink", |
| 212 |
"turquoise", |
| 213 |
"dark blue", |
| 214 |
"firebrick", |
| 215 |
"brown", |
| 216 |
"forest green", |
| 217 |
"gold", |
| 218 |
"dark gold", |
| 219 |
"gray", |
| 220 |
"dark gray", |
| 221 |
"light green", |
| 222 |
"lemon chiffon", |
| 223 |
"coral", |
| 224 |
"sea green", |
| 225 |
"sky blue", |
| 226 |
"magenta", |
| 227 |
"purple", |
| 228 |
"slate blue", |
| 229 |
"violet red", |
| 230 |
"navy blue", |
| 231 |
"olive", |
| 232 |
"orange", |
| 233 |
"red", |
| 234 |
"sienna", |
| 235 |
"yellow", |
| 236 |
], |
| 237 |
), |
| 238 |
comments=dict(type="str"), |
| 239 |
details_level=dict(type="str", choices=["uid", "standard", "full"]), |
| 240 |
domains_to_process=dict(type="list", elements="str"), |
| 241 |
ignore_warnings=dict(type="bool"), |
| 242 |
ignore_errors=dict(type="bool"), |
| 243 |
) |
| 244 |
argument_spec.update(checkpoint_argument_spec_for_objects) |
| 245 |
|
| 246 |
module = AnsibleModule( |
| 247 |
argument_spec=argument_spec, supports_check_mode=True |
| 248 |
) |
| 249 |
api_call_object = "md-permissions-profile" |
| 250 |
|
| 251 |
result = api_call(module, api_call_object) |
| 252 |
module.exit_json(**result) |
| 253 |
|
| 254 |
|
| 255 |
if __name__ == "__main__": |
| 256 |
main() |