|
| 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_identity_provider |
| 31 | +short_description: Manages identity-provider objects on Checkpoint over Web Services API |
| 32 | +description: |
| 33 | + - Manages identity-provider objects on Checkpoint devices including creating, updating and removing objects. |
| 34 | + - All operations are performed over Web Services API. |
| 35 | + - Available from R82 JHF management version. |
| 36 | +version_added: "6.5.0" |
| 37 | +author: "Dor Berenstein (@chkp-dorbe)" |
| 38 | +options: |
| 39 | + name: |
| 40 | + description: |
| 41 | + - Object name. |
| 42 | + type: str |
| 43 | + required: True |
| 44 | + usage: |
| 45 | + description: |
| 46 | + - Usage of Identity Provider. |
| 47 | + type: str |
| 48 | + choices: ['managing_administrator_access', 'gateway_policy_and_logs'] |
| 49 | + gateway: |
| 50 | + description: |
| 51 | + - Gateway for the SAML Identity Provider usage. |
| 52 | + Identified by name or UID. <font color="red">Required only when</font> 'usage' is set to 'gateway_policy_and_logs'. |
| 53 | + type: str |
| 54 | + service: |
| 55 | + description: |
| 56 | + - Service for the selected gateway. <font color="red">Required only when</font> 'usage' is set to 'gateway_policy_and_logs'. |
| 57 | + type: str |
| 58 | + choices: ['none', 'identity awareness', 'mobile access', 'vpn'] |
| 59 | + data_receiving: |
| 60 | + description: |
| 61 | + - Data receiving method from the SAML Identity Provider. |
| 62 | + type: str |
| 63 | + choices: ['metadata_file', 'manually'] |
| 64 | + received_identifier: |
| 65 | + description: |
| 66 | + - Received Identifier (Entity ID) based on the provider data. <font color="red">Required only when</font> 'data-receiving' is set to 'manually'. |
| 67 | + type: str |
| 68 | + login_url: |
| 69 | + description: |
| 70 | + - Login URL based on the provider data. <font color="red">Required only when</font> 'data-receiving' is set to 'manually'. |
| 71 | + type: str |
| 72 | + base64_metadata_file: |
| 73 | + description: |
| 74 | + - Metadata file encoded in base64 based on the provider data. <font color="red">Required only when</font> 'data-receiving' is set to 'metadata_file'. |
| 75 | + type: str |
| 76 | + base64_certificate: |
| 77 | + description: |
| 78 | + - Certificate file encoded in base64 based on provider data. <font color="red">Required only when</font> 'data-receiving' is set to 'manually'. |
| 79 | + type: str |
| 80 | + color: |
| 81 | + description: |
| 82 | + - Color of the object. Should be one of existing colors. |
| 83 | + type: str |
| 84 | + choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green', |
| 85 | + 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', |
| 86 | + 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow'] |
| 87 | + comments: |
| 88 | + description: |
| 89 | + - Comments string. |
| 90 | + type: str |
| 91 | + details_level: |
| 92 | + description: |
| 93 | + - 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 |
| 94 | + representation of the object. |
| 95 | + type: str |
| 96 | + choices: ['uid', 'standard', 'full'] |
| 97 | + domains_to_process: |
| 98 | + description: |
| 99 | + - 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 |
| 100 | + with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER. |
| 101 | + type: list |
| 102 | + elements: str |
| 103 | + tags: |
| 104 | + description: |
| 105 | + - Collection of tag identifiers. |
| 106 | + type: list |
| 107 | + elements: str |
| 108 | + ignore_warnings: |
| 109 | + description: |
| 110 | + - Apply changes ignoring warnings. |
| 111 | + type: bool |
| 112 | + ignore_errors: |
| 113 | + description: |
| 114 | + - 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. |
| 115 | + type: bool |
| 116 | +extends_documentation_fragment: check_point.mgmt.checkpoint_objects |
| 117 | +""" |
| 118 | + |
| 119 | +EXAMPLES = """ |
| 120 | +- name: add-identity-provider |
| 121 | + cp_mgmt_identity_provider: |
| 122 | + base64_certificate: | |
| 123 | + LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4RENDQWRpZ0F3SUJBZ0lRUTBWZVpLdVBLb0pQUWhaNGhDaWRzREFOQmdrcWhraUc5dzBCQVFzRkFEQTBNVEl3TUFZRFZRUURFeWxOYVdOeWIzTn |
| 124 | + ablFnUVhwMWNtVWdSbVZrWlhKaGRHVmtJRk5UVHlCRFpYSjBhV1pwWTJGMFpUQWVGdzB4T0RBME1UVXhNVEl6TXpOYUZ3MHlNVEEwTVRVeE1USXpNek5hTURReE1qQXdCZ05WQkFNVEtVMXBZM0p2YzI5b |
| 125 | + RDQkJlblZ5WlNCR1pXUmxjbUYwWldRZ1UxTlBJRU5sY25ScFptbGpZWFJsTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUE0VXVqYUd0OFhaODl2dXZ5a3lRVzVYb24vOFIv |
| 126 | + VB0ejRhYjBNM3RNVXZHWHozVXh0V1pTRStUR1hydjN3VHRLMCs4RmtNeXVKYUhGSXBLLzRVREZpRk1yQmxzR0Z1dmtTc1p5VjIzZlNGN3paaXlUWTZUN0EwcCtnczUwNVhEOUdBYjlWYmR3R0cwK0tDVnl |
| 127 | + c1ZRZ1YySXdKZ2l5aHF3RUNvY3dCcmFuN251SytURU5EMmwyZjlZcng1b1JNRU56NzB3bHlIMzZPWkJtdDBrNTk4L1doMEhEWUxaZW8wZHlTV3JOd3dlWXZTeEU4L01kbTQzWEV1U3pialR6ZnNNMHZVUn |
| 128 | + GQlNyVUxFYURPMS9JUDJVcjdCc2dId1JJL3hmb3FJbUsxS2twVXEwQWxjVEFpM3YxdTl6Qy9xTGdQd0F5UUl2dzlVQ3NpcnJQQTBZMFlPaFFJREFRQUJNQTBHQ1NxR1NJYjNEUUVCQ3dVQUE0SUJBUURja |
| 129 | + 9qZEd6L0FJQ2pqTTBaN21ZbGdQNXpic2FRNWRDMmNqZjRESnFta21zV3VmUnBDNHNic3VoODcwY0NCS2N1dmgrb0dpekJRSHJQbTRUaEl2ZklsS0w4WGpMQVhiRnVSUG9IQWcwOHNMWGR2UFRCVE52REYx |
| 130 | + WhvcU5zMmo2ZUZxL2ROdXF2ZUJIcjVENXRLblYyWEJHRUhFOVJFOVdUa1pRT2MwaEhtQ3dNbWNZb3JYRzhCa3l1OXFwNXhyMDZMQ0htMnJLcnI2ZENRVldBV0R0MzhiS2t5STRobTVSNTVCclR5UldSdzI |
| 131 | + RS9YaFEwVksva1FJYW9GZ0hvaWo0ekg5bmxlZnZMbmhaZDVPRzROL29OS2pBKy9LbkVqaTdPQXhKWVNaR1FmRjU0R1AwQTE4VnF1NVVGaFBKMUZFQXZ5YjR0QnZtTzM1NFFVUys5UTY2agotLS0tLUVORC |
| 132 | + DRVJUSUZJQ0FURS0tLS0t |
| 133 | + data_receiving: manually |
| 134 | + login_url: https://login.checkpointonline.com/621ac12d-4afb-479c-9c14-13e7b743cd07/saml2 |
| 135 | + name: TestIdp2 |
| 136 | + received_identifier: https://sts.checkpoint.net/621ac12d-4afb-479c-9c14-13e7b743cd07/ |
| 137 | + state: present |
| 138 | + usage: managing_administrator_access |
| 139 | +
|
| 140 | +- name: set-identity-provider |
| 141 | + cp_mgmt_identity_provider: |
| 142 | + base64_certificate: | |
| 143 | + LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4RENDQWRpZ0F3SUJBZ0lRUTBWZVpLdVBLb0pQUWhaNGhDaWRzREFOQmdrcWhraUc5dzBCQVFzRkFEQTBNVEl3TUFZRFZRUURFeWxOYVdOeWIzTn |
| 144 | + ablFnUVhwMWNtVWdSbVZrWlhKaGRHVmtJRk5UVHlCRFpYSjBhV1pwWTJGMFpUQWVGdzB4T0RBME1UVXhNVEl6TXpOYUZ3MHlNVEEwTVRVeE1USXpNek5hTURReE1qQXdCZ05WQkFNVEtVMXBZM0p2YzI5b |
| 145 | + RDQkJlblZ5WlNCR1pXUmxjbUYwWldRZ1UxTlBJRU5sY25ScFptbGpZWFJsTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUE0VXVqYUd0OFhaODl2dXZ5a3lRVzVYb24vOFIv |
| 146 | + VB0ejRhYjBNM3RNVXZHWHozVXh0V1pTRStUR1hydjN3VHRLMCs4RmtNeXVKYUhGSXBLLzRVREZpRk1yQmxzR0Z1dmtTc1p5VjIzZlNGN3paaXlUWTZUN0EwcCtnczUwNVhEOUdBYjlWYmR3R0cwK0tDVnl |
| 147 | + c1ZRZ1YySXdKZ2l5aHF3RUNvY3dCcmFuN251SytURU5EMmwyZjlZcng1b1JNRU56NzB3bHlIMzZPWkJtdDBrNTk4L1doMEhEWUxaZW8wZHlTV3JOd3dlWXZTeEU4L01kbTQzWEV1U3pialR6ZnNNMHZVUn |
| 148 | + GQlNyVUxFYURPMS9JUDJVcjdCc2dId1JJL3hmb3FJbUsxS2twVXEwQWxjVEFpM3YxdTl6Qy9xTGdQd0F5UUl2dzlVQ3NpcnJQQTBZMFlPaFFJREFRQUJNQTBHQ1NxR1NJYjNEUUVCQ3dVQUE0SUJBUURja |
| 149 | + 9qZEd6L0FJQ2pqTTBaN21ZbGdQNXpic2FRNWRDMmNqZjRESnFta21zV3VmUnBDNHNic3VoODcwY0NCS2N1dmgrb0dpekJRSHJQbTRUaEl2ZklsS0w4WGpMQVhiRnVSUG9IQWcwOHNMWGR2UFRCVE52REYx |
| 150 | + WhvcU5zMmo2ZUZxL2ROdXF2ZUJIcjVENXRLblYyWEJHRUhFOVJFOVdUa1pRT2MwaEhtQ3dNbWNZb3JYRzhCa3l1OXFwNXhyMDZMQ0htMnJLcnI2ZENRVldBV0R0MzhiS2t5STRobTVSNTVCclR5UldSdzI |
| 151 | + RS9YaFEwVksva1FJYW9GZ0hvaWo0ekg5bmxlZnZMbmhaZDVPRzROL29OS2pBKy9LbkVqaTdPQXhKWVNaR1FmRjU0R1AwQTE4VnF1NVVGaFBKMUZFQXZ5YjR0QnZtTzM1NFFVUys5UTY2agotLS0tLUVORC |
| 152 | + DRVJUSUZJQ0FURS0tLS0t |
| 153 | + data_receiving: manually |
| 154 | + login_url: https://login.checkpointonline.com/621ac12d-4afb-479c-9c14-13e7b743cd07/saml2 |
| 155 | + name: TestIdp |
| 156 | + received_identifier: https://sts.checkpoint.net/621ac12d-4afb-479c-9c14-13e7b743cd07/ |
| 157 | + state: present |
| 158 | + usage: managing_administrator_access |
| 159 | +
|
| 160 | +- name: delete-identity-provider |
| 161 | + cp_mgmt_identity_provider: |
| 162 | + name: TestIdp |
| 163 | + state: absent |
| 164 | +""" |
| 165 | + |
| 166 | +RETURN = """ |
| 167 | +cp_mgmt_identity_provider: |
| 168 | + description: The checkpoint object created or updated. |
| 169 | + returned: always, except when deleting the object. |
| 170 | + type: dict |
| 171 | +""" |
| 172 | + |
| 173 | +from ansible.module_utils.basic import AnsibleModule |
| 174 | +from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call |
| 175 | + |
| 176 | + |
| 177 | +def main(): |
| 178 | + argument_spec = dict( |
| 179 | + name=dict(type='str', required=True), |
| 180 | + usage=dict(type='str', choices=['managing_administrator_access', 'gateway_policy_and_logs']), |
| 181 | + gateway=dict(type='str'), |
| 182 | + service=dict(type='str', choices=['none', 'identity awareness', 'mobile access', 'vpn']), |
| 183 | + data_receiving=dict(type='str', choices=['metadata_file', 'manually']), |
| 184 | + received_identifier=dict(type='str'), |
| 185 | + login_url=dict(type='str'), |
| 186 | + base64_metadata_file=dict(type='str'), |
| 187 | + base64_certificate=dict(type='str'), |
| 188 | + color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', |
| 189 | + 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', |
| 190 | + 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green', |
| 191 | + 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', |
| 192 | + 'yellow']), |
| 193 | + comments=dict(type='str'), |
| 194 | + details_level=dict(type='str', choices=['uid', 'standard', 'full']), |
| 195 | + domains_to_process=dict(type='list', elements='str'), |
| 196 | + tags=dict(type='list', elements='str'), |
| 197 | + ignore_warnings=dict(type='bool'), |
| 198 | + ignore_errors=dict(type='bool') |
| 199 | + ) |
| 200 | + argument_spec.update(checkpoint_argument_spec_for_objects) |
| 201 | + |
| 202 | + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) |
| 203 | + api_call_object = 'identity-provider' |
| 204 | + |
| 205 | + result = api_call(module, api_call_object) |
| 206 | + module.exit_json(**result) |
| 207 | + |
| 208 | + |
| 209 | +if __name__ == '__main__': |
| 210 | + main() |
0 commit comments