diff --git a/README.md b/README.md index ecd77ba..2855fc5 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,12 @@ Modules * `cp_gaia_expert_password_facts` – get expert hash password of a Check Point machine over Web Services API. * `cp_gaia_time_and_date` – manage time and date and timezone of a Check Point machine over Web Services API. * `cp_gaia_time_and_date_facts` – get time and date and timezone of a Check Point machine over Web Services API. +* `cp_gaia_virtual_systems_facts` – Get virtual-system objects facts on Check Point over Web Services API. +* `cp_gaia_virtual_switch` – Manages virtual switch on Check Point Gateway over Web Services API. +* `cp_gaia_virtual_switch_facts` – Get virtual-switch objects facts on Check Point over Web Services API. +* `cp_gaia_virtual_gateway` – Get virtual-gateway objects facts on Check Point over Web Services API. +* `cp_gaia_virtual_gateway_facts` – Get virtual-gateway objects facts on Check Point over Web Services API. +* `cp_gaia_virtual_vsnext_state_facts` – Show the VSNext state on Check Point over Web Services API. ### Code of Conduct This collection follows the Ansible project's diff --git a/plugins/modules/cp_gaia_bond_interface.py b/plugins/modules/cp_gaia_bond_interface.py index fc4ed07..8f7d832 100644 --- a/plugins/modules/cp_gaia_bond_interface.py +++ b/plugins/modules/cp_gaia_bond_interface.py @@ -41,6 +41,10 @@ type: str default: present choices: [present, absent] + virtual_system_id: + description: Virtual System ID. + required: false + type: int name: description: - Interface name with format C(bond), valid values are bond1, bond2, bond3 .. etc. @@ -151,6 +155,10 @@ description: Media monitoring interval, Valid values are C(1-5000). required: false type: int + virtual_system_id: + description: Virtual System ID. + required: false + type: int """ EXAMPLES = """ @@ -203,7 +211,8 @@ def main(): primary=dict(type='str'), lacp_rate=dict(type='str', choices=['slow', 'fast']), mode=dict(type='str', choices=['round-robin', 'active-backup', 'xor', '8023AD']), - mii_interval=dict(type='int') + mii_interval=dict(type='int'), + virtual_system_id=dict(type="int", required=False) ) fields.update(checkpoint_argument_spec_for_all) diff --git a/plugins/modules/cp_gaia_bond_interface_facts.py b/plugins/modules/cp_gaia_bond_interface_facts.py index 6596b8c..3945309 100644 --- a/plugins/modules/cp_gaia_bond_interface_facts.py +++ b/plugins/modules/cp_gaia_bond_interface_facts.py @@ -39,6 +39,11 @@ description: Interface name to show. If not specified, all bond interfaces information is returned. required: false type: str + virtual_system_id: + description: Virtual System ID. + required: false + type: int + """ @@ -70,6 +75,10 @@ - Interface name. returned: always type: str + virtual_system_id: + description: Virtual System ID. + returned: always + type: int ipv4_address: description: Interface IPv4 address. returned: always @@ -216,7 +225,8 @@ def main(): # arguments for the module: fields = dict( - name=dict(required=False, type='str') + name=dict(required=False, type='str'), + virtual_system_id=dict(required=False, type="int") ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) diff --git a/plugins/modules/cp_gaia_bridge_interface.py b/plugins/modules/cp_gaia_bridge_interface.py index 01c1a04..680a0f0 100644 --- a/plugins/modules/cp_gaia_bridge_interface.py +++ b/plugins/modules/cp_gaia_bridge_interface.py @@ -122,6 +122,10 @@ required: false type: list elements: str + virtual_system_id: + description: Virtual System ID. + required: False + type: int """ EXAMPLES = """ @@ -167,7 +171,8 @@ def main(): ) ), mtu=dict(type='int'), - members=dict(type='list', elements='str') + members=dict(type='list', elements='str'), + virtual_system_id=dict(type="int", required=False) ) fields.update(checkpoint_argument_spec_for_all) diff --git a/plugins/modules/cp_gaia_bridge_interface_facts.py b/plugins/modules/cp_gaia_bridge_interface_facts.py index 256d9c2..58ccc90 100644 --- a/plugins/modules/cp_gaia_bridge_interface_facts.py +++ b/plugins/modules/cp_gaia_bridge_interface_facts.py @@ -39,6 +39,10 @@ description: Interface name to show. If not specified, all bridge interfaces information is returned. required: false type: str + virtual_system_id: + description: Virtual System ID. + required: false + type: int """ @@ -70,6 +74,10 @@ - Interface name. returned: always type: str + virtual_system_id: + description: Virtual System ID. + returned: always + type: int ipv4_address: description: Interface IPv4 address. returned: always @@ -183,7 +191,8 @@ def main(): # arguments for the module: fields = dict( - name=dict(required=False, type='str') + name=dict(required=False, type='str'), + virtual_system_id=dict(required=False, type="int") ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) diff --git a/plugins/modules/cp_gaia_dhcp_server.py b/plugins/modules/cp_gaia_dhcp_server.py index 4952f2d..2577a0f 100644 --- a/plugins/modules/cp_gaia_dhcp_server.py +++ b/plugins/modules/cp_gaia_dhcp_server.py @@ -95,6 +95,10 @@ description: The IPv4 address of the default gateway for the DHCP clients. required: False type: str + virtual_system_id: + description: Virtual System ID. + required: False + type: int dns: description: DNS configuration. required: False @@ -133,7 +137,7 @@ "default_gateway": "4.5.6.1", "ip_pools": [{"start": "4.5.6.5", "end": "4.5.6.7", "enabled": True, "include": "include"}], "dns": {"domain_name": "my_domain_name", "primary": "8.8.8.8", "secondary": "8.8.8.8", "tertiary": "8.8.4.4"}, - "enabled": True} + "enabled": True, virtual_system_id: 0} ] """ @@ -154,6 +158,7 @@ def main(): # arguments for the module: fields = dict( enabled=dict(type='bool'), + virtual_system_id=dict(type='int', required=False), subnets=dict( type='list', elements='dict', options=dict( diff --git a/plugins/modules/cp_gaia_dhcp_server_facts.py b/plugins/modules/cp_gaia_dhcp_server_facts.py index 15960e6..fd489dc 100644 --- a/plugins/modules/cp_gaia_dhcp_server_facts.py +++ b/plugins/modules/cp_gaia_dhcp_server_facts.py @@ -107,6 +107,10 @@ description: The IPv4 address of the default gateway for the DHCP clients. returned: always type: str + virtual_system_id: + description: Virtual System ID. + returned: always + type: int dns: description: DNS configuration. returned: always @@ -139,7 +143,9 @@ def main(): # arguments for the module: - fields = dict() + fields = dict( + virtual_system_id=dict(type="int", required=False) + ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) diff --git a/plugins/modules/cp_gaia_dns.py b/plugins/modules/cp_gaia_dns.py index 54a474c..042b341 100644 --- a/plugins/modules/cp_gaia_dns.py +++ b/plugins/modules/cp_gaia_dns.py @@ -87,7 +87,8 @@ def main(): suffix=dict(type="str"), primary=dict(type="str"), tertiary=dict(type="str"), - secondary=dict(type="str") + secondary=dict(type="str"), + virtual_system_id=dict(type="int", required=False) ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) diff --git a/plugins/modules/cp_gaia_dns_facts.py b/plugins/modules/cp_gaia_dns_facts.py index 22a7168..ebf9b37 100644 --- a/plugins/modules/cp_gaia_dns_facts.py +++ b/plugins/modules/cp_gaia_dns_facts.py @@ -82,7 +82,9 @@ def main(): # arguments for the module: - fields = dict() + fields = dict( + virtual_system_id=dict(type="int", required=False) + ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) api_call_object = 'dns' diff --git a/plugins/modules/cp_gaia_initial_setup.py b/plugins/modules/cp_gaia_initial_setup.py index 6043f5a..5b4bf5e 100644 --- a/plugins/modules/cp_gaia_initial_setup.py +++ b/plugins/modules/cp_gaia_initial_setup.py @@ -189,7 +189,9 @@ def main(): options=dict( dynamically_assigned_ip=dict(type='bool', required=False, default=False), cluster_member=dict(type='bool', required=False, default=False), - activation_key=dict(type='str', required=False, no_log=True) + activation_key=dict(type='str', required=False, no_log=True), + vsnext=dict(type='bool', required=False, default=False), + elastic_xl=dict(type='bool', required=False, default=False) ) ) ) diff --git a/plugins/modules/cp_gaia_physical_interface.py b/plugins/modules/cp_gaia_physical_interface.py index 9a9cab0..f226b56 100644 --- a/plugins/modules/cp_gaia_physical_interface.py +++ b/plugins/modules/cp_gaia_physical_interface.py @@ -99,6 +99,10 @@ description: Set transmit buffer size for interfaces. required: false type: int + virtual_system_id: + description: Virtual System ID. + required: false + type: int """ @@ -140,7 +144,8 @@ def main(): mac_addr=dict(required=False, type="str"), rx_ringsize=dict(required=False, type="int"), speed=dict(required=False, type="str"), - ipv6_mask_length=dict(required=False, type="int") + ipv6_mask_length=dict(required=False, type="int"), + virtual_system_id=dict(required=False, type="int") ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) diff --git a/plugins/modules/cp_gaia_physical_interfaces_facts.py b/plugins/modules/cp_gaia_physical_interfaces_facts.py index 1a87124..9ad6026 100644 --- a/plugins/modules/cp_gaia_physical_interfaces_facts.py +++ b/plugins/modules/cp_gaia_physical_interfaces_facts.py @@ -39,6 +39,10 @@ description: Interface name to show. If not specified, all physical interfaces information is returned. required: false type: str + virtual_system_id: + description: Virtual System ID. + required: false + type: int """ @@ -194,6 +198,10 @@ description: Interface tx ringsize. returned: always type: int + virtual_system_id: + description: Virtual System ID. + returned: always + type: int """ from ansible.module_utils.basic import AnsibleModule @@ -203,7 +211,8 @@ def main(): # arguments for the module: fields = dict( - name=dict(required=False, type="str") + name=dict(required=False, type="str"), + virtual_system_id=dict(type="int", required=False) ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) diff --git a/plugins/modules/cp_gaia_routes_facts.py b/plugins/modules/cp_gaia_routes_facts.py index cf43144..7197fa1 100644 --- a/plugins/modules/cp_gaia_routes_facts.py +++ b/plugins/modules/cp_gaia_routes_facts.py @@ -38,6 +38,10 @@ description: Gaia API version for example 1.6. required: False type: str + virtual_system_id: + description: Virtual System ID. + required: False + type: int limit: description: The maximum number of returned results. required: False @@ -86,6 +90,10 @@ returned: always type: list elements: dict + virtual_system_id: + description: Virtual System ID. + returned: always + type: int """ @@ -99,6 +107,7 @@ def main(): limit=dict(type="int", required=False, default=50), offset=dict(type="int", required=False, default=0), order=dict(type="str", required=False, choices=['ASC', 'DESC'], default="ASC"), + virtual_system_id=dict(type="int", required=False) ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) diff --git a/plugins/modules/cp_gaia_routes_kernel_facts.py b/plugins/modules/cp_gaia_routes_kernel_facts.py index 071d5c0..b744c9d 100644 --- a/plugins/modules/cp_gaia_routes_kernel_facts.py +++ b/plugins/modules/cp_gaia_routes_kernel_facts.py @@ -54,6 +54,10 @@ type: str choices: ['ASC', 'DESC'] default: 'ASC' + virtual_system_id: + description: Virtual System ID. + required: False + type: int """ @@ -81,6 +85,7 @@ def main(): limit=dict(type="int", required=False, default=50), offset=dict(type="int", required=False, default=0), order=dict(type="str", required=False, choices=['ASC', 'DESC'], default="ASC"), + virtual_system_id=dict(type="int", required=False) ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) diff --git a/plugins/modules/cp_gaia_routes_ospf_facts.py b/plugins/modules/cp_gaia_routes_ospf_facts.py index 27218cd..36e358f 100644 --- a/plugins/modules/cp_gaia_routes_ospf_facts.py +++ b/plugins/modules/cp_gaia_routes_ospf_facts.py @@ -54,6 +54,10 @@ type: str choices: ['ASC', 'DESC'] default: 'ASC' + virtual_system_id: + description: Virtual System ID. + required: False + type: int """ @@ -86,6 +90,10 @@ returned: always type: list elements: dict + virtual_systems_id: + description: Virtual System ID. + returned: always + type: int """ @@ -99,6 +107,7 @@ def main(): limit=dict(type="int", required=False, default=50), offset=dict(type="int", required=False, default=0), order=dict(type="str", required=False, choices=['ASC', 'DESC'], default="ASC"), + virtual_system_id=dict(type="int", required=False), ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) diff --git a/plugins/modules/cp_gaia_routes_rip_facts.py b/plugins/modules/cp_gaia_routes_rip_facts.py index 12cbe73..4528ab4 100644 --- a/plugins/modules/cp_gaia_routes_rip_facts.py +++ b/plugins/modules/cp_gaia_routes_rip_facts.py @@ -54,6 +54,10 @@ type: str choices: ['ASC', 'DESC'] default: 'ASC' + virtual_system_id: + description: Virtual System ID. + required: False + type: int """ @@ -86,6 +90,10 @@ returned: always type: list elements: dict + virtual_systems_id: + description: Virtual System ID. + returned: always + type: int """ @@ -99,6 +107,7 @@ def main(): limit=dict(type="int", required=False, default=50), offset=dict(type="int", required=False, default=0), order=dict(type="str", required=False, choices=['ASC', 'DESC'], default="ASC"), + virtual_system_id=dict(type="int", required=False), ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) diff --git a/plugins/modules/cp_gaia_routes_static_facts.py b/plugins/modules/cp_gaia_routes_static_facts.py index 594a68e..edaa057 100644 --- a/plugins/modules/cp_gaia_routes_static_facts.py +++ b/plugins/modules/cp_gaia_routes_static_facts.py @@ -99,6 +99,7 @@ def main(): limit=dict(type="int", required=False, default=50), offset=dict(type="int", required=False, default=0), order=dict(type="str", required=False, choices=['ASC', 'DESC'], default="ASC"), + virtual_system_id=dict(type="int", required=False) ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) diff --git a/plugins/modules/cp_gaia_static_route.py b/plugins/modules/cp_gaia_static_route.py index 10d0931..74c5c10 100644 --- a/plugins/modules/cp_gaia_static_route.py +++ b/plugins/modules/cp_gaia_static_route.py @@ -140,6 +140,7 @@ def main(): rank=dict(type='int'), ping=dict(type='bool', default=False), scope_local=dict(type='bool', default=False), + virtual_system_id=dict(type="int", required=False) ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule( diff --git a/plugins/modules/cp_gaia_static_route_facts.py b/plugins/modules/cp_gaia_static_route_facts.py index 472f246..b7bfdc9 100644 --- a/plugins/modules/cp_gaia_static_route_facts.py +++ b/plugins/modules/cp_gaia_static_route_facts.py @@ -109,7 +109,8 @@ def main(): mask_length=dict(type="int"), limit=dict(type="int", required=False, default=50), offset=dict(type="int", required=False, default=0), - order=dict(type="str", required=False, default='ASC', choices=['ASC', 'DESC']) + order=dict(type="str", required=False, default='ASC', choices=['ASC', 'DESC']), + virtual_system_id=dict(type="int", required=False) ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True, required_together=[('address', 'mask_length')]) diff --git a/plugins/modules/cp_gaia_virtual_gateway.py b/plugins/modules/cp_gaia_virtual_gateway.py new file mode 100644 index 0000000..9e28c86 --- /dev/null +++ b/plugins/modules/cp_gaia_virtual_gateway.py @@ -0,0 +1,186 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Ansible module to manage CheckPoint Firewall (c) 2019 +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: cp_gaia_virtual_system +short_description: Manages virtual gateway on Check Point Gateway over Web Services API +description: + - Manages virtual gateway on Check Point gateways including creating, updating and removing virtual systems. + - All operations are performed over Web Services API. +version_added: "2.9" +author: "Jafar Atili (@chkp-jafara)" +options: + id: + description: + - virtual gateway ID. + This parameter is used to change existing virtual gateway or creating new if does not exist + type: str + name: + description: + - name of the virtual gateway. + This parameter is used to change existing virtual gateway by name + type: str + one_time_password: + description: + - one time password of the virtual gateway. + This parameter is used to set one time password for existing virtual gateway by name or id + type: str + interfaces: + description: + - configure interfaces for the virtual gateway. + type: list + description: + - Collection of interfaces to be set identified by the name. Replaces existing interfaces. + resources: + description: + - virtual gateway resources configuration + type: dict + suboptions: + firewall_ipv4_instances: + description: + - The number of IPv4 CoreXL instances to be assigned to the virtual gateway identified by name or id + type: int + firewall_ipv6_instances: + description: + - The number of IPv6 CoreXL instances to be assigned to the virtual gateway identified by name or id + type: int + virtual_switches: + description: + - Connect virtual gateway identified by name or id to pre existing virtual switches identified by their ids + type: list + description: + - Collection of virtual switches to be set identified by the ids. Replaces existing interfaces. + type: list + mgmt_connection: + description: + - management connection configuration + type: dict + suboptions: + mgmt_connection_identifier: + description: + - management connection identifier. + This parameter is used to change existing virtual gateway by name + type: str + mgmt_connection_type: + description: + - management connection type. + This parameter is used to change existing virtual gateway by name + type: str + mgmt_ipv4_configuration: + description: + - management connection IPv4 configuration + type: dict + suboptions: + ipv4_address: + description: + - management connection IPv4 address. + type: str + ipv4_mask_length: + description: + - management connection IPv4 mask length. + type: int + ipv4_default_gateway: + description: + - management connection IPv4 default gateway. + type: str + mgmt_ipv6_configuration: + description: + - management connection IPv6 configuration + type: dict + suboptions: + ipv6_address: + description: + - management connection IPv6 address. + type: str + ipv6_mask_length: + description: + - management connection IPv6 mask length. + type: int + ipv6_default_gateway: + description: + - management connection IPv6 default gateway. + type: str +""" +EXAMPLES = """ +- name: set virtual gateway + check_point.gaia.cp_gaia_virtual_gateway: + id: 11 + one_time_password: dummyOTP + interfaces: + - name: eth1-02.2 + - name: eth1-02.3 + virtual_switches: + - id: 1 + - id: 500 + resources: + firewall_ipv4_instances: 2 + firewall_ipv6_instances: 0 + mgmt_connection: + mgmt_connection_identifier: 500 + mgmt_connection_type: virtual-switch-id + mgmt_ipv4_configuration: + ipv4_address: 172.72.72.1 + ipv4_mask: 24 + ipv4_default_gateway: 172.72.72.4 +""" +RETURN = """ +cp_gaia_virtual_system: + description: virtual gateway creation output. + returned: always. + type: dict +""" +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.check_point.gaia.plugins.module_utils.checkpoint import chkp_api_call, checkpoint_argument_spec_for_all + +def run_module(): + # arguments for the module: + fields = dict( + state=dict(type='str', default='present', choices=['present', 'absent']), + id=dict(type='int'), + one_time_password=dict(type='str'), + interfaces=dict(type='list'), + virtual_switches=dict(type='list'), + resources=dict(type='dict', + firewall_ipv4_instances=dict(type='int'), + firewall_ipv6_instances=dict(type='int')), + mgmt_connection=dict(type='dict', mgmt_connection_identifier=dict(type='str', required=True), + mgmt_connection_type=dict(type='str', required=True, choices=['interface', 'virtual-switch-id', 'virtual-switch-name']), + mgmt_ipv4_configuration=dict(type='dict', required=False, ipv4_address=dict(type='str', required=True), + ipv4_mask=dict(type='int', required=True), + ipv4_default_gateway=dict(type='str', required=False)), + mgmt_ipv6_configuration=dict(type='dict', required=False, ipv6_address=dict(type='str', required=True), + ipv6_mask=dict(type='int', required=True), + ipv6_default_gateway=dict(type='str', required=False)) + ) + ) + fields.update(checkpoint_argument_spec_for_all) + module = AnsibleModule(argument_spec=fields, supports_check_mode=True) + ignore = ['status'] + show_params = ['id'] + add_params = {'id': module.params['id']} + api_call_object = "virtual-gateway" + res = chkp_api_call(module, api_call_object, True, ignore=ignore, show_params=show_params, add_params=add_params) + module.exit_json(**res) +def main(): + run_module() +if __name__ == '__main__': + main() diff --git a/plugins/modules/cp_gaia_virtual_gateway_facts.py b/plugins/modules/cp_gaia_virtual_gateway_facts.py new file mode 100644 index 0000000..5c51e81 --- /dev/null +++ b/plugins/modules/cp_gaia_virtual_gateway_facts.py @@ -0,0 +1,74 @@ + +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Ansible module to manage CheckPoint Firewall (c) 2019 +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: cp_gaia_virtual_gateway_facts +short_description: Get virtual-system objects facts on Check Point over Web Services API +description: + - Get virtual-system objects facts on Check Point devices. + - All operations are performed over Web Services API. + - This module handles both operations, get a specific object and get several objects, + For getting a specific object use the parameter 'id' to specify the virtual system id. +version_added: "2.9" +author: "Jafar Atili (@chkp-jafara)" +options: + id: + description: + - Virtual system ID. + This parameter is relevant only for getting a specific Virtual system object. + type: str +""" +EXAMPLES = """ +- name: show-virtual-system + cp_gaia_virtual_gateway_facts: + id: 1 +- name: show-virtual-systems + cp_gaia_virtual_gateway_facts: +""" +RETURN = """ +ansible_facts: + description: The checkpoint object facts. + returned: always. + type: dict +""" +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.check_point.gaia.plugins.module_utils.checkpoint import chkp_facts_api_call, checkpoint_argument_spec_for_all + +def run_module(): + fields = dict( + id=dict(type="int"), + member_id=dict(type="int") + ) + fields.update(checkpoint_argument_spec_for_all) + module = AnsibleModule(argument_spec=fields, supports_check_mode=True) + if module.params["id"]: + api_call_object = 'virtual-gateway' + else: + api_call_object = 'virtual-gateways' + res = chkp_facts_api_call(module, api_call_object, False) + module.exit_json(**res) + +def main(): + run_module() +if __name__ == '__main__': + main() diff --git a/plugins/modules/cp_gaia_virtual_switch.py b/plugins/modules/cp_gaia_virtual_switch.py new file mode 100644 index 0000000..cee74c9 --- /dev/null +++ b/plugins/modules/cp_gaia_virtual_switch.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Ansible module to manage CheckPoint Firewall (c) 2019 +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: cp_gaia_virtual_switch +short_description: Manages virtual switch on Check Point Gateway over Web Services API +description: + - Manages virtual switch on Check Point gateways including creating, updating and removing virtual switches. + - All operations are performed over Web Services API. +version_added: "2.9" +author: "Jafar Atili (@chkp-jafara)" +options: + id: + description: + - Virtual Switch ID. + This parameter is used to change existing virtual switch or creating new if does not exist + type: str + name: + description: + - name of the virtual switch. + This parameter is used to change existing virtual switch or creating new if does not exist + type: str + interfaces: + description: + - Collection of interfaces to be set identified by the name. Replaces existing interfaces. + type: list +""" +EXAMPLES = """ +- name: set virtual switch + check_point.gaia.cp_gaia_virtual_switch: + id: 10 + name: AnsibleSwitch + interfaces: + - name: eth1-01 + - name: eth2.300 + - name: bond1.20 +""" +RETURN = """ +cp_gaia_virtual_switch: + description: virtual switch creation output. + returned: always. + type: dict +""" +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.check_point.gaia.plugins.module_utils.checkpoint import chkp_api_call, checkpoint_argument_spec_for_all + +def run_module(): + # arguments for the module: + fields = dict( + state=dict(type='str', default='present', choices=['present', 'absent']), + id=dict(type='int'), + name=dict(type='str'), + interfaces=dict(type='list'), + ) + fields.update(checkpoint_argument_spec_for_all) + module = AnsibleModule(argument_spec=fields, supports_check_mode=True) + ignore = ['status'] + show_params = ['id'] + add_params = {'name': module.params['name'], 'id': module.params['id']} + api_call_object = 'virtual-switch' + res = chkp_api_call(module, api_call_object, True, ignore=ignore, show_params=show_params, add_params=add_params) + module.exit_json(**res) +def main(): + run_module() +if __name__ == '__main__': + main() diff --git a/plugins/modules/cp_gaia_virtual_switch_facts.py b/plugins/modules/cp_gaia_virtual_switch_facts.py new file mode 100644 index 0000000..41e9de8 --- /dev/null +++ b/plugins/modules/cp_gaia_virtual_switch_facts.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Ansible module to manage CheckPoint Firewall (c) 2019 +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: cp_gaia_virtual_switch_facts +short_description: Get virtual-switch objects facts on Check Point over Web Services API +description: + - Get virtual-switch objects facts on Check Point devices. + - All operations are performed over Web Services API. + - This module handles both operations, get a specific object and get several objects, + For getting a specific object use the parameter 'id' to specify the virtual switch id. +version_added: "2.9" +author: "Jafar Atili (@chkp-jafara)" +options: + id: + description: + - Virtual Switch ID. + This parameter is relevant only for getting a specific Virtual Switch object. + type: str + +""" +EXAMPLES = """ +- name: show-virtual-switch + cp_gaia_virtual_switch_facts: + id: 1 +- name: show-virtual-switches + cp_gaia_virtual_switch_facts: +""" +RETURN = """ +ansible_facts: + description: The checkpoint object facts. + returned: always. + type: dict +""" +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.check_point.gaia.plugins.module_utils.checkpoint import chkp_facts_api_call, checkpoint_argument_spec_for_all + +def run_module(): + fields = dict( + id=dict(type="int"), + member_id=dict(type="int") + ) + fields.update(checkpoint_argument_spec_for_all) + module = AnsibleModule(argument_spec=fields, supports_check_mode=True) + if module.params["id"]: + api_call_object = 'virtual-switch' + else: + api_call_object = 'virtual-switches' + res = chkp_facts_api_call(module, api_call_object, False) + module.exit_json(**res) +def main(): + run_module() +if __name__ == '__main__': + main() diff --git a/plugins/modules/cp_gaia_virtual_systems_facts.py b/plugins/modules/cp_gaia_virtual_systems_facts.py new file mode 100644 index 0000000..337e64a --- /dev/null +++ b/plugins/modules/cp_gaia_virtual_systems_facts.py @@ -0,0 +1,82 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Ansible module to manage CheckPoint Firewall (c) 2019 +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# + +from __future__ import (absolute_import, division, print_function) + +__metaclass__ = type + + +DOCUMENTATION = """ +author: Omer Hadad (@chkp-omerhad) +description: +- Show Virtual Systems. +module: cp_gaia_virtual_systems_facts +options: + version: + description: Gaia API version for example 1.8. + required: False + type: str +short_description: Show Virtual Systems. +version_added: '5.0.0' +notes: +- Supports C(check_mode). +requirements: +- supported starting from gaia_api >= 1.8 +""" +EXAMPLES = """ +- name: Show Virtual Systems + check_point.gaia.cp_gaia_virtual_systems_facts: + +""" +RETURN = """ +ansible_facts: + description: The VSNext state facts. + returned: always. + type: dict + contains: + enabled: + description: The VSNext state. + returned: always + type: bool + session-virtual-system-id: + description: The Virtual System ID of the current Gaia API session. + returned: always + type: int + member-id: + description: The member on which the command was executed. + returned: On Scalable and Elastic XL platforms only. + type: sp-member-id +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.check_point.gaia.plugins.module_utils.checkpoint import chkp_facts_api_call, checkpoint_argument_spec_for_all + +def run_module(): + fields = dict() + fields.update(checkpoint_argument_spec_for_all) + module = AnsibleModule(argument_spec=fields, supports_check_mode=True) + api_call_object = 'virtual-systems' + + res = chkp_facts_api_call(module, api_call_object, False) + module.exit_json(ansible_facts=res["ansible_facts"]) + +def main(): + run_module() +if __name__ == '__main__': + main() diff --git a/plugins/modules/cp_gaia_vlan_interface.py b/plugins/modules/cp_gaia_vlan_interface.py index 48de612..a0c4d7b 100644 --- a/plugins/modules/cp_gaia_vlan_interface.py +++ b/plugins/modules/cp_gaia_vlan_interface.py @@ -111,6 +111,10 @@ description: Interface mtu. required: false type: int + virtual_system_id: + description: Virtual system identifier. + required: false + type: int """ EXAMPLES = """ @@ -154,7 +158,8 @@ def main(): reacquire_timeout=dict(type='int', default=10), ) ), - mtu=dict(type='int') + mtu=dict(type='int'), + virtual_system_id=dict(type='int', required=False) ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) diff --git a/plugins/modules/cp_gaia_vlan_interface_facts.py b/plugins/modules/cp_gaia_vlan_interface_facts.py index bb2b4a9..a43412c 100644 --- a/plugins/modules/cp_gaia_vlan_interface_facts.py +++ b/plugins/modules/cp_gaia_vlan_interface_facts.py @@ -39,6 +39,10 @@ description: Interface name to show. If not specified, all vlan interfaces information is returned. required: false type: str + virtual_system_id: + description: Virtual System ID. + required: false + type: int """ @@ -141,6 +145,10 @@ description: Interface ipv6 local link address. returned: always type: str + virtual_system_id: + description: Virtual system ID. + returned: always + type: int status: description: Interface data. returned: always @@ -183,7 +191,8 @@ def main(): # arguments for the module: fields = dict( - name=dict(required=False, type='str') + name=dict(required=False, type='str'), + virtual_system_id=dict(required=False, type='int') ) fields.update(checkpoint_argument_spec_for_all) module = AnsibleModule(argument_spec=fields, supports_check_mode=True) diff --git a/plugins/modules/cp_gaia_vsnext_state_facts.py b/plugins/modules/cp_gaia_vsnext_state_facts.py new file mode 100644 index 0000000..3ef5483 --- /dev/null +++ b/plugins/modules/cp_gaia_vsnext_state_facts.py @@ -0,0 +1,82 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Ansible module to manage CheckPoint Firewall (c) 2019 +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# + +from __future__ import (absolute_import, division, print_function) + +__metaclass__ = type + + +DOCUMENTATION = """ +author: Omer Hadad (@chkp-omerhad) +description: +- Show the VSNext state. +module: cp_gaia_vsnext_state_facts +options: + version: + description: Gaia API version for example 1.8. + required: False + type: str +short_description: Show the VSNext state. +version_added: '5.0.0' +notes: +- Supports C(check_mode). +requirements: +- supported starting from gaia_api >= 1.8 +""" +EXAMPLES = """ +- name: Show VSNext state + check_point.gaia.cp_gaia_vsnext_state_facts: + +""" +RETURN = """ +ansible_facts: + description: The VSNext state facts. + returned: always. + type: dict + contains: + enabled: + description: The VSNext state. + returned: always + type: bool + session-virtual-system-id: + description: The Virtual System ID of the current Gaia API session. + returned: always + type: int + member-id: + description: The member on which the command was executed. + returned: On Scalable and Elastic XL platforms only. + type: sp-member-id +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.check_point.gaia.plugins.module_utils.checkpoint import chkp_facts_api_call, checkpoint_argument_spec_for_all + +def run_module(): + fields = dict() + fields.update(checkpoint_argument_spec_for_all) + module = AnsibleModule(argument_spec=fields, supports_check_mode=True) + api_call_object = 'vsnext-state' + + res = chkp_facts_api_call(module, api_call_object, False) + module.exit_json(ansible_facts=res["ansible_facts"]) + +def main(): + run_module() +if __name__ == '__main__': + main()