Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_network_probe.py

raw
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_network_probe
31 short_description: Manages network-probe objects on Checkpoint over Web Services API
32 description:
33 - Manages network-probe objects on Checkpoint devices including creating, updating and removing objects.
34 - All operations are performed over Web Services API.
35 - Available from R82 management version.
36 version_added: "6.0.0"
37 author: "Eden Brillant (@chkp-edenbr)"
38 options:
39 name:
40 description:
41 - Object name.
42 type: str
43 required: True
44 http_options:
45 description:
46 - Additional options when [protocol] is set to "http".
47 type: dict
48 suboptions:
49 destination:
50 description:
51 - The destination URL.
52 type: str
53 icmp_options:
54 description:
55 - Additional options when [protocol] is set to "icmp".
56 type: dict
57 suboptions:
58 destination:
59 description:
60 - One of these,<br>- Name or UID of an existing object with a unicast IPv4 address (Host, Security Gateway, and so on).<br>- A unicast
61 IPv4 address string (if you do not want to create such an object).
62 type: str
63 source:
64 description:
65 - One of these,<br>- The string "main-ip" (the probe uses the main IPv4 address of the Security Gateway objects you specified in the
66 parameter [install-on]).<br>- Name or UID of an existing object of type 'Host' with a unicast IPv4 address.<br>- A unicast IPv4 address string (if
67 you do not want to create such an object).
68 type: str
69 install_on:
70 description:
71 - Collection of Check Point Security Gateways that generate the probe, identified by name or UID.
72 type: list
73 elements: str
74 protocol:
75 description:
76 - The probing protocol to use.
77 type: str
78 choices: ['http', 'icmp']
79 tags:
80 description:
81 - Collection of tag identifiers.
82 type: list
83 elements: str
84 interval:
85 description:
86 - The time interval in the range of 5-300 (seconds) between each probe request.
87 Best Practice - The interval value should be lower than the timeout value.
88 type: int
89 timeout:
90 description:
91 - The probe expiration timeout in the range of 5-300 (seconds).
92 If there is not a single reply within this time, the status of the probe changes to "Down".
93 type: int
94 color:
95 description:
96 - Color of the object. Should be one of existing colors.
97 type: str
98 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
99 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
100 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
101 comments:
102 description:
103 - Comments string.
104 type: str
105 details_level:
106 description:
107 - 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
108 representation of the object.
109 type: str
110 choices: ['uid', 'standard', 'full']
111 domains_to_process:
112 description:
113 - Indicates which domains to process the commands on. It cannot be used with the details-level full, must be run from the System Domain only and
114 with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
115 type: list
116 elements: str
117 ignore_warnings:
118 description:
119 - Apply changes ignoring warnings.
120 type: bool
121 ignore_errors:
122 description:
123 - 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.
124 type: bool
125 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
126 """
127
128 EXAMPLES = """
129 - name: add-network-probe
130 cp_mgmt_network_probe:
131 icmp_options:
132 destination: HOST_20.20.20.20
133 source: Host_10.10.10.10
134 install_on: GW_1
135 name: probe_GW1
136 state: present
137
138 - name: set-network-probe
139 cp_mgmt_network_probe:
140 icmp_options:
141 destination: 2.2.2.2
142 source: 1.1.1.1
143 name: probe_GW1
144 state: present
145
146 - name: delete-network-probe
147 cp_mgmt_network_probe:
148 name: probe_GW1
149 state: absent
150 """
151
152 RETURN = """
153 cp_mgmt_network_probe:
154 description: The checkpoint object created or updated.
155 returned: always, except when deleting the object.
156 type: dict
157 """
158
159 from ansible.module_utils.basic import AnsibleModule
160 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call
161
162
163 def main():
164 argument_spec = dict(
165 name=dict(type='str', required=True),
166 http_options=dict(type='dict', options=dict(
167 destination=dict(type='str')
168 )),
169 icmp_options=dict(type='dict', options=dict(
170 destination=dict(type='str'),
171 source=dict(type='str')
172 )),
173 install_on=dict(type='list', elements='str'),
174 protocol=dict(type='str', choices=['http', 'icmp']),
175 tags=dict(type='list', elements='str'),
176 interval=dict(type='int'),
177 timeout=dict(type='int'),
178 color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
179 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown',
180 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green',
181 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna',
182 'yellow']),
183 comments=dict(type='str'),
184 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
185 domains_to_process=dict(type='list', elements='str'),
186 ignore_warnings=dict(type='bool'),
187 ignore_errors=dict(type='bool')
188 )
189 argument_spec.update(checkpoint_argument_spec_for_objects)
190
191 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
192 api_call_object = 'network-probe'
193
194 result = api_call(module, api_call_object)
195 module.exit_json(**result)
196
197
198 if __name__ == '__main__':
199 main()