| 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_vsx_run_operation |
| 31 |
short_description: Run the VSX operation by its name and parameters. |
| 32 |
description: |
| 33 |
- Run the VSX operation by its name and parameters. |
| 34 |
- An automatic session publish is part of all the operations in this API. |
| 35 |
- All operations are performed over Web Services API. |
| 36 |
- Available from R81 management version. |
| 37 |
version_added: "5.0.0" |
| 38 |
author: "Eden Brillant (@chkp-edenbr)" |
| 39 |
options: |
| 40 |
operation: |
| 41 |
description: |
| 42 |
- The name of the operation to run. Each operation has its specific parameters.<br>The available operations are,<ul><li><i>upgrade</i> - |
| 43 |
Upgrades the VSX Gateway or VSX Cluster object to a higher version</li><li><i>downgrade</i> - Downgrades the VSX Gateway or VSX Cluster object to a |
| 44 |
lower version</li><li><i>add-member</i> - Adds a new VSX Cluster member object</li><li><i>remove-member</i> - Removes a VSX Cluster member |
| 45 |
object</li><li><i>reconf-gw</i> - Reconfigures a VSX Gateway after a clean install</li><li><i>reconf-member</i> - Reconfigures a VSX Cluster member |
| 46 |
after a clean install</li></ul>. |
| 47 |
type: str |
| 48 |
choices: ['upgrade', 'downgrade', 'add-member', 'remove-member', 'reconf-gw', 'reconf-member'] |
| 49 |
add_member_params: |
| 50 |
description: |
| 51 |
- Parameters for the operation to add a VSX Cluster member. |
| 52 |
type: dict |
| 53 |
suboptions: |
| 54 |
ipv4_address: |
| 55 |
description: |
| 56 |
- The IPv4 address of the management interface of the VSX Cluster member. |
| 57 |
type: str |
| 58 |
ipv4_sync_address: |
| 59 |
description: |
| 60 |
- The IPv4 address of the sync interface of the VSX Cluster member. |
| 61 |
type: str |
| 62 |
member_name: |
| 63 |
description: |
| 64 |
- Name of the new VSX Cluster member object. |
| 65 |
type: str |
| 66 |
vsx_name: |
| 67 |
description: |
| 68 |
- Name of the VSX Cluster object. |
| 69 |
type: str |
| 70 |
vsx_uid: |
| 71 |
description: |
| 72 |
- UID of the VSX Cluster object. |
| 73 |
type: str |
| 74 |
downgrade_params: |
| 75 |
description: |
| 76 |
- Parameters for the operation to downgrade a VSX Gateway or VSX Cluster object to a lower version.<br>In case the current version is already |
| 77 |
the target version, or is lower than the target version, no change is done. |
| 78 |
type: dict |
| 79 |
suboptions: |
| 80 |
target_version: |
| 81 |
description: |
| 82 |
- The target version. |
| 83 |
type: str |
| 84 |
vsx_name: |
| 85 |
description: |
| 86 |
- Name of the VSX Gateway or VSX Cluster object. |
| 87 |
type: str |
| 88 |
vsx_uid: |
| 89 |
description: |
| 90 |
- UID of the VSX Gateway or VSX Cluster object. |
| 91 |
type: str |
| 92 |
reconf_gw_params: |
| 93 |
description: |
| 94 |
- Parameters for the operation to reconfigure a VSX Gateway after a clean install. |
| 95 |
type: dict |
| 96 |
suboptions: |
| 97 |
ipv4_corexl_number: |
| 98 |
description: |
| 99 |
- Number of IPv4 CoreXL Firewall instances on the target VSX Gateway.<br>Valid values,<br><ul><li>To configure CoreXL Firewall |
| 100 |
instances, enter an integer greater or equal to 2.</li><li>To disable CoreXL, enter 1.</li></ul>. |
| 101 |
type: int |
| 102 |
one_time_password: |
| 103 |
description: |
| 104 |
- A password required for establishing a Secure Internal Communication (SIC). Enter the same password you used during the First Time |
| 105 |
Configuration Wizard on the target VSX Gateway. |
| 106 |
type: str |
| 107 |
vsx_name: |
| 108 |
description: |
| 109 |
- Name of the VSX Gateway object. |
| 110 |
type: str |
| 111 |
vsx_uid: |
| 112 |
description: |
| 113 |
- UID of the VSX Gateway object. |
| 114 |
type: str |
| 115 |
reconf_member_params: |
| 116 |
description: |
| 117 |
- Parameters for the operation to reconfigure a VSX Cluster member after a clean install. |
| 118 |
type: dict |
| 119 |
suboptions: |
| 120 |
ipv4_corexl_number: |
| 121 |
description: |
| 122 |
- Number of IPv4 CoreXL Firewall instances on the target VSX Cluster member.<br>Valid values,<br><ul><li>To configure CoreXL Firewall |
| 123 |
instances, enter an integer greater or equal to 2.</li><li>To disable CoreXL, enter 1.</li></ul>Important - The CoreXL configuration must be the |
| 124 |
same on all the cluster members. |
| 125 |
type: int |
| 126 |
member_uid: |
| 127 |
description: |
| 128 |
- UID of the VSX Cluster member object. |
| 129 |
type: str |
| 130 |
member_name: |
| 131 |
description: |
| 132 |
- Name of the VSX Cluster member object. |
| 133 |
type: str |
| 134 |
one_time_password: |
| 135 |
description: |
| 136 |
- A password required for establishing a Secure Internal Communication (SIC). Enter the same password you used during the First Time |
| 137 |
Configuration Wizard on the target VSX Cluster member. |
| 138 |
type: str |
| 139 |
remove_member_params: |
| 140 |
description: |
| 141 |
- Parameters for the operation to remove a VSX Cluster member object. |
| 142 |
type: dict |
| 143 |
suboptions: |
| 144 |
member_uid: |
| 145 |
description: |
| 146 |
- UID of the VSX Cluster member object. |
| 147 |
type: str |
| 148 |
member_name: |
| 149 |
description: |
| 150 |
- Name of the VSX Cluster member object. |
| 151 |
type: str |
| 152 |
upgrade_params: |
| 153 |
description: |
| 154 |
- Parameters for the operation to upgrade a VSX Gateway or VSX Cluster object to a higher version.<br>In case the current version is already the |
| 155 |
target version, or is higher than the target version, no change is done. |
| 156 |
type: dict |
| 157 |
suboptions: |
| 158 |
target_version: |
| 159 |
description: |
| 160 |
- The target version. |
| 161 |
type: str |
| 162 |
vsx_name: |
| 163 |
description: |
| 164 |
- Name of the VSX Gateway or VSX Cluster object. |
| 165 |
type: str |
| 166 |
vsx_uid: |
| 167 |
description: |
| 168 |
- UID of the VSX Gateway or VSX Cluster object. |
| 169 |
type: str |
| 170 |
extends_documentation_fragment: check_point.mgmt.checkpoint_commands |
| 171 |
""" |
| 172 |
|
| 173 |
EXAMPLES = """ |
| 174 |
- name: vsx-run-operation |
| 175 |
cp_mgmt_vsx_run_operation: |
| 176 |
add_member_params: |
| 177 |
ipv4_address: 25.25.25.223 |
| 178 |
ipv4_sync_address: 20.20.20.223 |
| 179 |
member_name: Mem3 |
| 180 |
vsx_name: VSX_CLUSTER |
| 181 |
operation: add-member |
| 182 |
""" |
| 183 |
|
| 184 |
RETURN = """ |
| 185 |
cp_mgmt_vsx_run_operation: |
| 186 |
description: The checkpoint vsx-run-operation output. |
| 187 |
returned: always. |
| 188 |
type: dict |
| 189 |
""" |
| 190 |
|
| 191 |
from ansible.module_utils.basic import AnsibleModule |
| 192 |
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_commands, api_command |
| 193 |
|
| 194 |
|
| 195 |
def main(): |
| 196 |
argument_spec = dict( |
| 197 |
operation=dict(type='str', choices=['upgrade', 'downgrade', 'add-member', 'remove-member', 'reconf-gw', 'reconf-member']), |
| 198 |
add_member_params=dict(type='dict', options=dict( |
| 199 |
ipv4_address=dict(type='str'), |
| 200 |
ipv4_sync_address=dict(type='str'), |
| 201 |
member_name=dict(type='str'), |
| 202 |
vsx_name=dict(type='str'), |
| 203 |
vsx_uid=dict(type='str') |
| 204 |
)), |
| 205 |
downgrade_params=dict(type='dict', options=dict( |
| 206 |
target_version=dict(type='str'), |
| 207 |
vsx_name=dict(type='str'), |
| 208 |
vsx_uid=dict(type='str') |
| 209 |
)), |
| 210 |
reconf_gw_params=dict(type='dict', options=dict( |
| 211 |
ipv4_corexl_number=dict(type='int'), |
| 212 |
one_time_password=dict(type='str', no_log=True), |
| 213 |
vsx_name=dict(type='str'), |
| 214 |
vsx_uid=dict(type='str') |
| 215 |
)), |
| 216 |
reconf_member_params=dict(type='dict', options=dict( |
| 217 |
ipv4_corexl_number=dict(type='int'), |
| 218 |
member_uid=dict(type='str'), |
| 219 |
member_name=dict(type='str'), |
| 220 |
one_time_password=dict(type='str', no_log=True) |
| 221 |
)), |
| 222 |
remove_member_params=dict(type='dict', options=dict( |
| 223 |
member_uid=dict(type='str'), |
| 224 |
member_name=dict(type='str') |
| 225 |
)), |
| 226 |
upgrade_params=dict(type='dict', options=dict( |
| 227 |
target_version=dict(type='str'), |
| 228 |
vsx_name=dict(type='str'), |
| 229 |
vsx_uid=dict(type='str') |
| 230 |
)) |
| 231 |
) |
| 232 |
argument_spec.update(checkpoint_argument_spec_for_commands) |
| 233 |
|
| 234 |
module = AnsibleModule(argument_spec=argument_spec) |
| 235 |
|
| 236 |
command = "vsx-run-operation" |
| 237 |
|
| 238 |
result = api_command(module, command) |
| 239 |
module.exit_json(**result) |
| 240 |
|
| 241 |
|
| 242 |
if __name__ == '__main__': |
| 243 |
main() |