|
| 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_radius_group |
| 31 | +short_description: Manages radius-group objects on Checkpoint over Web Services API |
| 32 | +description: |
| 33 | + - Manages radius-group objects on Checkpoint devices including creating, updating and removing objects. |
| 34 | + - All operations are performed over Web Services API. |
| 35 | +version_added: "6.3.0" |
| 36 | +author: "Shiran Golzar (@chkp-shirango)" |
| 37 | +options: |
| 38 | + name: |
| 39 | + description: |
| 40 | + - Object name. |
| 41 | + type: str |
| 42 | + required: True |
| 43 | + members: |
| 44 | + description: |
| 45 | + - Collection of radius servers identified by the name or UID. |
| 46 | + type: list |
| 47 | + elements: str |
| 48 | + tags: |
| 49 | + description: |
| 50 | + - Collection of tag identifiers. |
| 51 | + type: list |
| 52 | + elements: str |
| 53 | + color: |
| 54 | + description: |
| 55 | + - Color of the object. Should be one of existing colors. |
| 56 | + type: str |
| 57 | + choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green', |
| 58 | + 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', |
| 59 | + 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow'] |
| 60 | + comments: |
| 61 | + description: |
| 62 | + - Comments string. |
| 63 | + type: str |
| 64 | + details_level: |
| 65 | + description: |
| 66 | + - 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 |
| 67 | + representation of the object. |
| 68 | + type: str |
| 69 | + choices: ['uid', 'standard', 'full'] |
| 70 | + groups: |
| 71 | + description: |
| 72 | + - Collection of group identifiers. |
| 73 | + type: list |
| 74 | + elements: str |
| 75 | + ignore_warnings: |
| 76 | + description: |
| 77 | + - Apply changes ignoring warnings. |
| 78 | + type: bool |
| 79 | + ignore_errors: |
| 80 | + description: |
| 81 | + - 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. |
| 82 | + type: bool |
| 83 | +extends_documentation_fragment: check_point.mgmt.checkpoint_objects |
| 84 | +""" |
| 85 | + |
| 86 | +EXAMPLES = """ |
| 87 | +- name: add-radius-group |
| 88 | + cp_mgmt_radius_group: |
| 89 | + members: |
| 90 | + - t4 |
| 91 | + - radgroup |
| 92 | + name: radgroup |
| 93 | + state: present |
| 94 | +
|
| 95 | +- name: set-radius-group |
| 96 | + cp_mgmt_radius_group: |
| 97 | + members: |
| 98 | + - t4 |
| 99 | + name: radgroup |
| 100 | + state: present |
| 101 | +
|
| 102 | +- name: delete-radius-group |
| 103 | + cp_mgmt_radius_group: |
| 104 | + ignore_warnings: 'true' |
| 105 | + name: testgroup |
| 106 | + state: absent |
| 107 | +""" |
| 108 | + |
| 109 | +RETURN = """ |
| 110 | +cp_mgmt_radius_group: |
| 111 | + description: The checkpoint object created or updated. |
| 112 | + returned: always, except when deleting the object. |
| 113 | + type: dict |
| 114 | +""" |
| 115 | + |
| 116 | +from ansible.module_utils.basic import AnsibleModule |
| 117 | +from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, \ |
| 118 | + api_call |
| 119 | + |
| 120 | + |
| 121 | +def main(): |
| 122 | + argument_spec = dict( |
| 123 | + name=dict(type='str', required=True), |
| 124 | + members=dict(type='list', elements='str'), |
| 125 | + tags=dict(type='list', elements="str"), |
| 126 | + color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', |
| 127 | + 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', |
| 128 | + 'dark blue', 'firebrick', 'brown', |
| 129 | + 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', |
| 130 | + 'lemon chiffon', 'coral', 'sea green', |
| 131 | + 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', |
| 132 | + 'olive', 'orange', 'red', 'sienna', |
| 133 | + 'yellow']), |
| 134 | + comments=dict(type='str'), |
| 135 | + details_level=dict(type='str', choices=['uid', 'standard', 'full']), |
| 136 | + groups=dict(type='list', elements='str'), |
| 137 | + ignore_warnings=dict(type='bool'), |
| 138 | + ignore_errors=dict(type='bool') |
| 139 | + ) |
| 140 | + argument_spec.update(checkpoint_argument_spec_for_objects) |
| 141 | + |
| 142 | + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) |
| 143 | + api_call_object = 'radius-group' |
| 144 | + |
| 145 | + result = api_call(module, api_call_object) |
| 146 | + module.exit_json(**result) |
| 147 | + |
| 148 | + |
| 149 | +if __name__ == '__main__': |
| 150 | + main() |
0 commit comments