|
| 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_add_nat_rule |
| 31 | +short_description: Create new object. |
| 32 | +description: |
| 33 | + - Create new object. |
| 34 | + - All operations are performed over Web Services API. |
| 35 | +version_added: "2.9" |
| 36 | +author: "Or Soffer (@chkp-orso)" |
| 37 | +options: |
| 38 | + package: |
| 39 | + description: |
| 40 | + - Name of the package. |
| 41 | + type: str |
| 42 | + position: |
| 43 | + description: |
| 44 | + - Position in the rulebase. |
| 45 | + type: str |
| 46 | + enabled: |
| 47 | + description: |
| 48 | + - Enable/Disable the rule. |
| 49 | + type: bool |
| 50 | + install_on: |
| 51 | + description: |
| 52 | + - Which Gateways identified by the name or UID to install the policy on. |
| 53 | + type: list |
| 54 | + method: |
| 55 | + description: |
| 56 | + - Nat method. |
| 57 | + type: str |
| 58 | + choices: ['static', 'hide', 'nat64', 'nat46'] |
| 59 | + original_destination: |
| 60 | + description: |
| 61 | + - Original destination. |
| 62 | + type: str |
| 63 | + original_service: |
| 64 | + description: |
| 65 | + - Original service. |
| 66 | + type: str |
| 67 | + original_source: |
| 68 | + description: |
| 69 | + - Original source. |
| 70 | + type: str |
| 71 | + translated_destination: |
| 72 | + description: |
| 73 | + - Translated destination. |
| 74 | + type: str |
| 75 | + translated_service: |
| 76 | + description: |
| 77 | + - Translated service. |
| 78 | + type: str |
| 79 | + translated_source: |
| 80 | + description: |
| 81 | + - Translated source. |
| 82 | + type: str |
| 83 | + comments: |
| 84 | + description: |
| 85 | + - Comments string. |
| 86 | + type: str |
| 87 | + details_level: |
| 88 | + description: |
| 89 | + - 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 |
| 90 | + representation of the object. |
| 91 | + type: str |
| 92 | + choices: ['uid', 'standard', 'full'] |
| 93 | + ignore_warnings: |
| 94 | + description: |
| 95 | + - Apply changes ignoring warnings. |
| 96 | + type: bool |
| 97 | + ignore_errors: |
| 98 | + description: |
| 99 | + - 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. |
| 100 | + type: bool |
| 101 | +extends_documentation_fragment: check_point.mgmt.checkpoint_commands |
| 102 | +""" |
| 103 | + |
| 104 | +EXAMPLES = """ |
| 105 | +- name: add-nat-rule |
| 106 | + cp_mgmt_add_nat_rule: |
| 107 | + comments: comment example1 nat999 |
| 108 | + enabled: false |
| 109 | + install_on: |
| 110 | + - Policy Targets |
| 111 | + original_destination: All_Internet |
| 112 | + original_source: Any |
| 113 | + package: standard |
| 114 | + position: 1 |
| 115 | + state: present |
| 116 | +""" |
| 117 | + |
| 118 | +RETURN = """ |
| 119 | +cp_mgmt_add_nat_rule: |
| 120 | + description: The checkpoint add-nat-rule output. |
| 121 | + returned: always. |
| 122 | + type: dict |
| 123 | +""" |
| 124 | + |
| 125 | +from ansible.module_utils.basic import AnsibleModule |
| 126 | +from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_commands, api_command |
| 127 | + |
| 128 | + |
| 129 | +def main(): |
| 130 | + argument_spec = dict( |
| 131 | + package=dict(type='str'), |
| 132 | + position=dict(type='str'), |
| 133 | + enabled=dict(type='bool'), |
| 134 | + install_on=dict(type='list'), |
| 135 | + method=dict(type='str', choices=['static', 'hide', 'nat64', 'nat46']), |
| 136 | + original_destination=dict(type='str'), |
| 137 | + original_service=dict(type='str'), |
| 138 | + original_source=dict(type='str'), |
| 139 | + translated_destination=dict(type='str'), |
| 140 | + translated_service=dict(type='str'), |
| 141 | + translated_source=dict(type='str'), |
| 142 | + comments=dict(type='str'), |
| 143 | + details_level=dict(type='str', choices=['uid', 'standard', 'full']), |
| 144 | + ignore_warnings=dict(type='bool'), |
| 145 | + ignore_errors=dict(type='bool') |
| 146 | + ) |
| 147 | + argument_spec.update(checkpoint_argument_spec_for_commands) |
| 148 | + |
| 149 | + module = AnsibleModule(argument_spec=argument_spec) |
| 150 | + |
| 151 | + command = "add-nat-rule" |
| 152 | + |
| 153 | + result = api_command(module, command) |
| 154 | + module.exit_json(**result) |
| 155 | + |
| 156 | + |
| 157 | +if __name__ == '__main__': |
| 158 | + main() |
0 commit comments