Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_logical_server.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_logical_server
31 short_description: Manages logical-server objects on Checkpoint over Web Services API
32 description:
33 - Manages logical-server objects on Checkpoint devices including creating, updating and removing objects.
34 - All operations are performed over Web Services API.
35 - Available from R82.10 management version.
36 version_added: "6.7.0"
37 author: "Eden Brillant (@chkp-edenbr)"
38 options:
39 name:
40 description:
41 - Object name.
42 type: str
43 required: True
44 ip_address:
45 description:
46 - IPv4 or IPv6 address. If both addresses are required use ipv4-address and ipv6-address fields explicitly.
47 type: str
48 ipv4_address:
49 description:
50 - IPv4 address.
51 type: str
52 ipv6_address:
53 description:
54 - IPv6 address.
55 type: str
56 server_group:
57 description:
58 - Server group associated with the logical server.Identified by name or UID.
59 type: str
60 server_type:
61 description:
62 - Type of server for the logical server.
63 type: str
64 choices: ['other', 'http']
65 persistence_mode:
66 description:
67 - Indicates if persistence mode is enabled for the logical server.
68 type: bool
69 persistency_type:
70 description:
71 - Persistency type for the logical server.
72 type: str
73 choices: ['by_server', 'by_service']
74 balance_method:
75 description:
76 - Load balancing method for the logical server.
77 type: str
78 choices: ['random', 'round_trip', 'domain', 'server_load', 'round_robin']
79 color:
80 description:
81 - Color of the object. Should be one of existing colors.
82 type: str
83 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
84 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
85 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
86 comments:
87 description:
88 - Comments string.
89 type: str
90 details_level:
91 description:
92 - 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
93 representation of the object.
94 type: str
95 choices: ['uid', 'standard', 'full']
96 tags:
97 description:
98 - Collection of tag identifiers.
99 type: list
100 elements: str
101 ignore_warnings:
102 description:
103 - Apply changes ignoring warnings.
104 type: bool
105 ignore_errors:
106 description:
107 - 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.
108 type: bool
109 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
110 """
111
112 EXAMPLES = """
113 - name: add-logical-server
114 cp_mgmt_logical_server:
115 balance_method: domain
116 ip_address: 1.1.1.1
117 name: logicalServer1
118 persistence_mode: true
119 persistency_type: by_server
120 server_group: testGroup
121 server_type: other
122 state: present
123
124 - name: set-logical-server
125 cp_mgmt_logical_server:
126 name: logicalServer1
127 server_type: http
128 state: present
129
130 - name: delete-logical-server
131 cp_mgmt_logical_server:
132 name: logicalServer1
133 state: absent
134 """
135
136 RETURN = """
137 cp_mgmt_logical_server:
138 description: The checkpoint object created or updated.
139 returned: always, except when deleting the object.
140 type: dict
141 """
142
143 from ansible.module_utils.basic import AnsibleModule
144 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call
145
146
147 def main():
148 argument_spec = dict(
149 name=dict(type='str', required=True),
150 ip_address=dict(type='str'),
151 ipv4_address=dict(type='str'),
152 ipv6_address=dict(type='str'),
153 server_group=dict(type='str'),
154 server_type=dict(type='str', choices=['other', 'http']),
155 persistence_mode=dict(type='bool'),
156 persistency_type=dict(type='str', choices=['by_server', 'by_service']),
157 balance_method=dict(type='str', choices=['random', 'round_trip', 'domain', 'server_load', 'round_robin']),
158 color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
159 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown',
160 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green',
161 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna',
162 'yellow']),
163 comments=dict(type='str'),
164 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
165 tags=dict(type='list', elements='str'),
166 ignore_warnings=dict(type='bool'),
167 ignore_errors=dict(type='bool')
168 )
169 argument_spec.update(checkpoint_argument_spec_for_objects)
170
171 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
172 api_call_object = 'logical-server'
173
174 result = api_call(module, api_call_object)
175 module.exit_json(**result)
176
177
178 if __name__ == '__main__':
179 main()