| 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_set_global_domain |
| 31 |
short_description: Edit Global domain object using domain name or UID. |
| 32 |
description: |
| 33 |
- Edit Global domain object using domain name or UID. When the list of Multi Domain Server is edited, the command is handled asynchronously. A list of |
| 34 |
task identifiers is returned to a user. In this case, the changes to the Global domain object are done in a public session and so should not be published. |
| 35 |
If the domain is changed in other parameters than the Multi Domain Servers, i.e. comments, color or tags, such changes are done in the user's private |
| 36 |
session and therefore should be published. In this case, the returned command output is similar to the one of 'show-global-domain'. |
| 37 |
- All operations are performed over Web Services API. |
| 38 |
- Available from R80 management version. |
| 39 |
version_added: "5.0.0" |
| 40 |
author: "Eden Brillant (@chkp-edenbr)" |
| 41 |
options: |
| 42 |
name: |
| 43 |
description: |
| 44 |
- Object name. |
| 45 |
type: str |
| 46 |
servers: |
| 47 |
description: |
| 48 |
- Multi Domain Servers. When the field is provided, 'set-global-domain' command is executed asynchronously. |
| 49 |
type: dict |
| 50 |
suboptions: |
| 51 |
add: |
| 52 |
description: |
| 53 |
- Adds to collection of values |
| 54 |
type: list |
| 55 |
elements: str |
| 56 |
remove: |
| 57 |
description: |
| 58 |
- Removes from collection of values |
| 59 |
type: list |
| 60 |
elements: str |
| 61 |
tags: |
| 62 |
description: |
| 63 |
- Collection of tag identifiers. Note, The list of tags can not be modified in a single command together with the domain servers. To modify |
| 64 |
tags, please use the separate 'set-global-domain' command, without providing the list of domain servers. |
| 65 |
type: list |
| 66 |
elements: str |
| 67 |
color: |
| 68 |
description: |
| 69 |
- Color of the object. Should be one of existing colors. |
| 70 |
type: str |
| 71 |
choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green', |
| 72 |
'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', |
| 73 |
'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow'] |
| 74 |
comments: |
| 75 |
description: |
| 76 |
- Comments string. |
| 77 |
type: str |
| 78 |
details_level: |
| 79 |
description: |
| 80 |
- 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 |
| 81 |
representation of the object. |
| 82 |
type: str |
| 83 |
choices: ['uid', 'standard', 'full'] |
| 84 |
ignore_warnings: |
| 85 |
description: |
| 86 |
- Apply changes ignoring warnings. |
| 87 |
type: bool |
| 88 |
ignore_errors: |
| 89 |
description: |
| 90 |
- 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. |
| 91 |
type: bool |
| 92 |
extends_documentation_fragment: check_point.mgmt.checkpoint_commands |
| 93 |
""" |
| 94 |
|
| 95 |
EXAMPLES = """ |
| 96 |
- name: set-global-domain |
| 97 |
cp_mgmt_set_global_domain: |
| 98 |
name: Global |
| 99 |
tags: |
| 100 |
- tag1 |
| 101 |
comments: "This is a Global domain" |
| 102 |
""" |
| 103 |
|
| 104 |
RETURN = """ |
| 105 |
cp_mgmt_set_global_domain: |
| 106 |
description: The checkpoint set-global-domain output. |
| 107 |
returned: always. |
| 108 |
type: dict |
| 109 |
""" |
| 110 |
|
| 111 |
from ansible.module_utils.basic import AnsibleModule |
| 112 |
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_commands, api_command |
| 113 |
|
| 114 |
|
| 115 |
def main(): |
| 116 |
argument_spec = dict( |
| 117 |
name=dict(type='str'), |
| 118 |
servers=dict(type='dict', options=dict( |
| 119 |
add=dict(type='list', elements='str'), |
| 120 |
remove=dict(type='list', elements='str') |
| 121 |
)), |
| 122 |
tags=dict(type='list', elements='str'), |
| 123 |
color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', |
| 124 |
'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', |
| 125 |
'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green', |
| 126 |
'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', |
| 127 |
'yellow']), |
| 128 |
comments=dict(type='str'), |
| 129 |
details_level=dict(type='str', choices=['uid', 'standard', 'full']), |
| 130 |
ignore_warnings=dict(type='bool'), |
| 131 |
ignore_errors=dict(type='bool') |
| 132 |
) |
| 133 |
argument_spec.update(checkpoint_argument_spec_for_commands) |
| 134 |
|
| 135 |
module = AnsibleModule(argument_spec=argument_spec) |
| 136 |
|
| 137 |
command = "set-global-domain" |
| 138 |
|
| 139 |
result = api_command(module, command) |
| 140 |
module.exit_json(**result) |
| 141 |
|
| 142 |
|
| 143 |
if __name__ == '__main__': |
| 144 |
main() |