Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_administrator.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 = {
25 "metadata_version": "1.1",
26 "status": ["preview"],
27 "supported_by": "community",
28 }
29
30 DOCUMENTATION = """
31 ---
32 module: cp_mgmt_administrator
33 short_description: Manages administrator objects on Checkpoint over Web Services API
34 description:
35 - Manages administrator objects on Checkpoint devices including creating, updating and removing objects.
36 - All operations are performed over Web Services API.
37 - Available from R80 management version.
38 version_added: "1.0.0"
39 author: "Or Soffer (@chkp-orso)"
40 options:
41 name:
42 description:
43 - Object name.
44 type: str
45 required: True
46 authentication_method:
47 description:
48 - Authentication method.
49 type: str
50 choices: ['undefined', 'check point password', 'os password', 'securid', 'radius', 'tacacs', 'ad authentication', 'api key']
51 email:
52 description:
53 - Administrator email.
54 type: str
55 expiration_date:
56 description:
57 - Format, YYYY-MM-DD, YYYY-mm-ddThh,mm,ss.
58 type: str
59 multi_domain_profile:
60 description:
61 - Administrator multi-domain profile.
62 type: str
63 must_change_password:
64 description:
65 - True if administrator must change password on the next login.
66 type: bool
67 password:
68 description:
69 - Administrator password.
70 type: str
71 password_hash:
72 description:
73 - Administrator password hash.
74 type: str
75 permissions_profile:
76 description:
77 - Permission profile
78 type: str
79 permissions_profile_list:
80 description:
81 - Administrator permissions profile. Permissions profile should not be provided when multi-domain-profile is set to "Multi-Domain Super User" or
82 "Domain Super User". Used only in MDS.
83 type: list
84 elements: dict
85 suboptions:
86 profile:
87 description:
88 - Permission profile.
89 type: str
90 domain:
91 description:
92 - Domain.
93 type: str
94 phone_number:
95 description:
96 - Administrator phone number.
97 type: str
98 radius_server:
99 description:
100 - RADIUS server object identified by the name or UID. Must be set when "authentication-method" was selected to be "RADIUS".
101 type: str
102 tacacs_server:
103 description:
104 - TACACS server object identified by the name or UID. Must be set when "authentication-method" was selected to be "TACACS".
105 type: str
106 tags:
107 description:
108 - Collection of tag identifiers.
109 type: list
110 elements: str
111 color:
112 description:
113 - Color of the object. Should be one of existing colors.
114 type: str
115 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
116 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
117 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
118 comments:
119 description:
120 - Comments string.
121 type: str
122 details_level:
123 description:
124 - 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
125 representation of the object.
126 type: str
127 choices: ['uid', 'standard', 'full']
128 ignore_warnings:
129 description:
130 - Apply changes ignoring warnings.
131 type: bool
132 ignore_errors:
133 description:
134 - 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.
135 type: bool
136 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
137 """
138
139 EXAMPLES = """
140 - name: add-administrator
141 cp_mgmt_administrator:
142 authentication_method: check point password
143 email: [email protected]
144 must_change_password: false
145 name: admin
146 password: secret
147 permissions_profile: read write all
148 phone_number: 1800-800-800
149 state: present
150
151 - name: set-administrator
152 cp_mgmt_administrator:
153 name: admin
154 password: new secret
155 permissions_profile: read only profile
156 state: present
157
158 - name: delete-administrator
159 cp_mgmt_administrator:
160 name: admin
161 state: absent
162
163 - name: add-administrator-in-MDS
164 cp_mgmt_administrator:
165 authentication_method: check point password
166 email: [email protected]
167 must_change_password: false
168 name: admin
169 password: secret
170 permissions_profile_list:
171 profile: read write all
172 domain: dom1
173 phone_number: 1800-800-800
174 state: present
175 """
176
177 RETURN = """
178 cp_mgmt_administrator:
179 description: The checkpoint object created or updated.
180 returned: always, except when deleting the object.
181 type: dict
182 """
183
184 from ansible.module_utils.basic import AnsibleModule
185 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
186 checkpoint_argument_spec_for_objects,
187 api_call,
188 )
189
190
191 def main():
192 argument_spec = dict(
193 name=dict(type="str", required=True),
194 authentication_method=dict(
195 type="str",
196 choices=[
197 "undefined",
198 "check point password",
199 "os password",
200 "securid",
201 "radius",
202 "tacacs",
203 "ad authentication",
204 "api key",
205 ],
206 ),
207 email=dict(type="str"),
208 expiration_date=dict(type="str"),
209 multi_domain_profile=dict(type="str"),
210 must_change_password=dict(type="bool", no_log=False),
211 password=dict(type="str", no_log=True),
212 password_hash=dict(type="str", no_log=True),
213 permissions_profile=dict(type="str"),
214 permissions_profile_list=dict(
215 type="list",
216 elements="dict",
217 options=dict(profile=dict(type="str"), domain=dict(type="str")),
218 ),
219 phone_number=dict(type="str"),
220 radius_server=dict(type="str"),
221 tacacs_server=dict(type="str"),
222 tags=dict(type="list", elements="str"),
223 color=dict(
224 type="str",
225 choices=[
226 "aquamarine",
227 "black",
228 "blue",
229 "crete blue",
230 "burlywood",
231 "cyan",
232 "dark green",
233 "khaki",
234 "orchid",
235 "dark orange",
236 "dark sea green",
237 "pink",
238 "turquoise",
239 "dark blue",
240 "firebrick",
241 "brown",
242 "forest green",
243 "gold",
244 "dark gold",
245 "gray",
246 "dark gray",
247 "light green",
248 "lemon chiffon",
249 "coral",
250 "sea green",
251 "sky blue",
252 "magenta",
253 "purple",
254 "slate blue",
255 "violet red",
256 "navy blue",
257 "olive",
258 "orange",
259 "red",
260 "sienna",
261 "yellow",
262 ],
263 ),
264 comments=dict(type="str"),
265 details_level=dict(type="str", choices=["uid", "standard", "full"]),
266 ignore_warnings=dict(type="bool"),
267 ignore_errors=dict(type="bool"),
268 )
269 argument_spec.update(checkpoint_argument_spec_for_objects)
270
271 module = AnsibleModule(
272 argument_spec=argument_spec, supports_check_mode=True
273 )
274 api_call_object = "administrator"
275
276 if module.params["permissions_profile_list"] is not None:
277 if module.params["permissions_profile"] is not None:
278 raise AssertionError(
279 "The use of both 'permissions_profile_list' and 'permissions_profile' arguments isn't allowed"
280 )
281 module.params["permissions_profile"] = module.params[
282 "permissions_profile_list"
283 ]
284 module.params.pop("permissions_profile_list")
285
286 result = api_call(module, api_call_object)
287 module.exit_json(**result)
288
289
290 if __name__ == "__main__":
291 main()