| 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_external_trusted_ca |
| 31 |
short_description: Manages external-trusted-ca objects on Checkpoint over Web Services API |
| 32 |
description: |
| 33 |
- Manages external-trusted-ca 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 |
name: |
| 40 |
description: |
| 41 |
- Object name. |
| 42 |
type: str |
| 43 |
required: True |
| 44 |
base64_certificate: |
| 45 |
description: |
| 46 |
- Certificate file encoded in base64. |
| 47 |
type: str |
| 48 |
retrieve_crl_from_http_servers: |
| 49 |
description: |
| 50 |
- Whether to retrieve Certificate Revocation List from http servers. |
| 51 |
type: bool |
| 52 |
crl_cache_method: |
| 53 |
description: |
| 54 |
- Weather to retrieve new Certificate Revocation List after the certificate expires or after a fixed period. |
| 55 |
type: str |
| 56 |
choices: ['timeout', 'expiration date'] |
| 57 |
crl_cache_timeout: |
| 58 |
description: |
| 59 |
- When to fetch new Certificate Revocation List (in minutes). |
| 60 |
type: int |
| 61 |
allow_certificates_from_branches: |
| 62 |
description: |
| 63 |
- Allow only certificates from listed branches. |
| 64 |
type: bool |
| 65 |
branches: |
| 66 |
description: |
| 67 |
- Branches to allow certificates from. Required only if "allow-certificates-from-branches" set to "true". |
| 68 |
type: list |
| 69 |
elements: str |
| 70 |
tags: |
| 71 |
description: |
| 72 |
- Collection of tag identifiers. |
| 73 |
type: list |
| 74 |
elements: str |
| 75 |
color: |
| 76 |
description: |
| 77 |
- Color of the object. Should be one of existing colors. |
| 78 |
type: str |
| 79 |
choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green', |
| 80 |
'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', |
| 81 |
'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow'] |
| 82 |
comments: |
| 83 |
description: |
| 84 |
- Comments string. |
| 85 |
type: str |
| 86 |
details_level: |
| 87 |
description: |
| 88 |
- 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 |
| 89 |
representation of the object. |
| 90 |
type: str |
| 91 |
choices: ['uid', 'standard', 'full'] |
| 92 |
domains_to_process: |
| 93 |
description: |
| 94 |
- 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 |
| 95 |
with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER. |
| 96 |
type: list |
| 97 |
elements: str |
| 98 |
ignore_warnings: |
| 99 |
description: |
| 100 |
- Apply changes ignoring warnings. |
| 101 |
type: bool |
| 102 |
ignore_errors: |
| 103 |
description: |
| 104 |
- 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. |
| 105 |
type: bool |
| 106 |
extends_documentation_fragment: check_point.mgmt.checkpoint_objects |
| 107 |
""" |
| 108 |
|
| 109 |
EXAMPLES = """ |
| 110 |
- name: add-external-trusted-ca |
| 111 |
cp_mgmt_external_trusted_ca: |
| 112 |
base64_certificate: |
| 113 |
"MIICujCCAaKgAwIBAgIIP1+IHWHbl0EwDQYJKoZIhvcNAQELBQAwFDESMBAGA1UEAxMJd3d3LnouY29tMB4XDTIzMTEyOTEyMzAwMFoXDTI0MTEyMDE2MDAwMFowFDESMBAGA1UEAxMJd3d3LnouY29tMI |
| 114 |
BIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoBreRGuq8u43GBog+ZaAnaR8ZF8cT2ppvtd3JoFmzTOQivLIt9sNtFYqEgHCtnNkKn9TRrxN14YscHgKIxfDSVlC9Rh0rrBvWgFqcm715Whr99Ogx |
| 115 |
JbYFkusFWJarSejIFx4n6MM48MJxLdtCP6Hy1G2cj1BCiCHj4i3VIVaDE/aMkSqJbYEvf+vFqUWxY8/uEuKI/HGhI7mhUPW4NSGL0Oafz5eEFVsxqV5NA19/JJZ9NajSkyANnaNL5raxGV0oeqaE3JB3lS |
| 116 |
ZfWbH6mQsToUxxwIQfsZiIBozajDdTgP3Kn4SMY0b+I/WAWgfigMSDTAIR8J1sdzGXy2w2kqQIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBUgrHztHwC1E0mU5c4reMrHg+ |
| 117 |
+YRHrgJNHVIYQbL5I2TJHk9S3UZsynoMa1CO86rReOtR5xoGv4PCkyyOW+PNlWUtXF3tNgqWj/21+XzG4RBHPw89TaTxRCdo+MHX58fi07SIzKjmxfdkEi+7+HQEQluDZGViolrGBAw2rXq/SZ3q/11mNq |
| 118 |
b5ZyqyOa2u1sBF1ApvG5a/FBRTaO8gaiNelRf0PGYkuV+1HhF2XyP8Qk565d+uxUH5M7eHF2PNyVk/r/36T+x+UMql9y9iizA0ekuAjXLok1xYl3Vw4S5zXCXYtNZLOVrs+plJb7IrlElyTOAbDFuPugh0 |
| 119 |
edz7uZ" |
| 120 |
name: external_ca |
| 121 |
state: present |
| 122 |
|
| 123 |
- name: set-external-trusted-ca |
| 124 |
cp_mgmt_external_trusted_ca: |
| 125 |
base64_certificate: |
| 126 |
"MIICujCCAaKgAwIBAgIIFbLYzT2+3TMwDQYJKoZIhvcNAQELBQAwFDESMBAGA1UEAxMJd3d3LnouY29tMB4XDTI0MDIwMTEyMzEwMFoXDTI0MTIzMTE2MDAwMFowFDESMBAGA1UEAxMJd3d3LnouY29tMI |
| 127 |
BIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoBreRGuq8u43GBog+ZaAnaR8ZF8cT2ppvtd3JoFmzTOQivLIt9sNtFYqEgHCtnNkKn9TRrxN14YscHgKIxfDSVlC9Rh0rrBvWgFqcm715Whr99Ogx |
| 128 |
JbYFkusFWJarSejIFx4n6MM48MJxLdtCP6Hy1G2cj1BCiCHj4i3VIVaDE/aMkSqJbYEvf+vFqUWxY8/uEuKI/HGhI7mhUPW4NSGL0Oafz5eEFVsxqV5NA19/JJZ9NajSkyANnaNL5raxGV0oeqaE3JB3lS |
| 129 |
ZfWbH6mQsToUxxwIQfsZiIBozajDdTgP3Kn4SMY0b+I/WAWgfigMSDTAIR8J1sdzGXy2w2kqQIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBxaE9O/LCjKfWeugPeDPvr3Ld |
| 130 |
i1mYsgNIyN+ES1iDoJHXrBQpVzZelJRr8leFgbghGUX7Fwdh1qZ2Jw6nmD1oe/Q7jkPzTngb6dIMI/kFK4eXcS4GJ3S7yGobLB7QUKK1vrYWZdNuAzR6jMRmFECS+lPF7zlTexnwwOkATMp6lzS7xEpEhk |
| 131 |
8eLpSQnYzvsM+rL9voU5q9MrdAJ2XaCZe4Crv75NdYU6ljD2eSYDrO148Tg480TlvT5wzBuyanKhI/Po2oLEVWU7h5tkensHKB5zvxigIr9ZkczdzVbbrRFi2jSQy+VxYWc0zCo/uO+yaKmmLfGDQEb8wZ |
| 132 |
Y1Ml27" |
| 133 |
crl_cache_method: expiration date |
| 134 |
name: external_ca |
| 135 |
retrieve_crl_from_http_servers: 'false' |
| 136 |
state: present |
| 137 |
|
| 138 |
- name: delete-external-trusted-ca |
| 139 |
cp_mgmt_external_trusted_ca: |
| 140 |
name: external_ca |
| 141 |
state: absent |
| 142 |
""" |
| 143 |
|
| 144 |
RETURN = """ |
| 145 |
cp_mgmt_external_trusted_ca: |
| 146 |
description: The checkpoint object created or updated. |
| 147 |
returned: always, except when deleting the object. |
| 148 |
type: dict |
| 149 |
""" |
| 150 |
|
| 151 |
from ansible.module_utils.basic import AnsibleModule |
| 152 |
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call |
| 153 |
|
| 154 |
|
| 155 |
def main(): |
| 156 |
argument_spec = dict( |
| 157 |
name=dict(type='str', required=True), |
| 158 |
base64_certificate=dict(type='str'), |
| 159 |
retrieve_crl_from_http_servers=dict(type='bool'), |
| 160 |
crl_cache_method=dict(type='str', choices=['timeout', 'expiration date']), |
| 161 |
crl_cache_timeout=dict(type='int'), |
| 162 |
allow_certificates_from_branches=dict(type='bool'), |
| 163 |
branches=dict(type='list', elements='str'), |
| 164 |
tags=dict(type='list', elements='str'), |
| 165 |
color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', |
| 166 |
'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', |
| 167 |
'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green', |
| 168 |
'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', |
| 169 |
'yellow']), |
| 170 |
comments=dict(type='str'), |
| 171 |
details_level=dict(type='str', choices=['uid', 'standard', 'full']), |
| 172 |
domains_to_process=dict(type='list', elements='str'), |
| 173 |
ignore_warnings=dict(type='bool'), |
| 174 |
ignore_errors=dict(type='bool') |
| 175 |
) |
| 176 |
argument_spec.update(checkpoint_argument_spec_for_objects) |
| 177 |
|
| 178 |
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) |
| 179 |
api_call_object = 'external-trusted-ca' |
| 180 |
|
| 181 |
result = api_call(module, api_call_object) |
| 182 |
module.exit_json(**result) |
| 183 |
|
| 184 |
|
| 185 |
if __name__ == '__main__': |
| 186 |
main() |