Debian Codegraph @

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

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Ansible module to manage Check Point 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_user
33 short_description: Manages user objects on Checkpoint over Web Services API
34 description:
35 - Manages user objects on Checkpoint devices including creating, updating and removing objects.
36 - All operations are performed over Web Services API.
37 - Available from R80.40 JHF management version.
38 version_added: "6.3.0"
39 author: "Dor Berenstein (@chkp-dorbe)"
40 options:
41 name:
42 description:
43 - Object name.
44 type: str
45 required: True
46 template:
47 description:
48 - User template name or UID.
49 type: str
50 email:
51 description:
52 - User email.
53 type: str
54 expiration_date:
55 description:
56 - Expiration date in format, yyyy-MM-dd.
57 type: str
58 phone_number:
59 description:
60 - User phone number.
61 type: str
62 authentication_method:
63 description:
64 - Authentication method.
65 type: str
66 choices: ['undefined', 'check point password', 'os password', 'securid', 'radius', 'tacacs']
67 password:
68 description:
69 - Check Point password authentication method identified by the name or UID. Must be set when "authentication-method" was selected to be "Check
70 Point Password".
71 type: str
72 radius_server:
73 description:
74 - RADIUS server object identified by the name or UID. Must be set when "authentication-method" was selected to be "RADIUS".
75 type: str
76 tacacs_server:
77 description:
78 - TACACS server object identified by the name or UID. Must be set when "authentication-method" was selected to be "TACACS".
79 type: str
80 connect_on_days:
81 description:
82 - Days users allow to connect.
83 type: list
84 elements: str
85 connect_daily:
86 description:
87 - Connect every day.
88 type: bool
89 from_hour:
90 description:
91 - Allow users connect from hour.
92 type: str
93 to_hour:
94 description:
95 - Allow users connect until hour.
96 type: str
97 allowed_locations:
98 description:
99 - User allowed locations.
100 type: dict
101 suboptions:
102 destinations:
103 description:
104 - Collection of allowed destination locations name or uid.
105 type: list
106 elements: str
107 sources:
108 description:
109 - Collection of allowed source locations name or uid.
110 type: list
111 elements: str
112 encryption:
113 description:
114 - User encryption. Doesn't support shared secret.
115 type: dict
116 suboptions:
117 ike:
118 description:
119 - Enable IKE encryption for users.
120 type: bool
121 public_key:
122 description:
123 - Enable IKE public key.
124 type: bool
125 color:
126 description:
127 - Color of the object. Should be one of existing colors.
128 type: str
129 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
130 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
131 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
132 comments:
133 description:
134 - Comments string.
135 type: str
136 details_level:
137 description:
138 - 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
139 representation of the object.
140 type: str
141 choices: ['uid', 'standard', 'full']
142 ignore_warnings:
143 description:
144 - Apply changes ignoring warnings.
145 type: bool
146 groups:
147 description:
148 - Collection of group identifiers.
149 type: list
150 elements: str
151 ignore_errors:
152 description:
153 - 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.
154 type: bool
155 tags:
156 description:
157 - Collection of tag identifiers.
158 type: list
159 elements: str
160 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
161 """
162
163 EXAMPLES = """
164 - name: add-user
165 cp_mgmt_user:
166 authentication_method: securid
167 connect_daily: 'True'
168 email: [email protected]
169 encryption:
170 enable_ike: 'True'
171 enable_public_key: 'True'
172 expiration_date: '2030-05-30'
173 from_hour: 08:00
174 name: myuser
175 phone_number: '0501112233'
176 state: present
177 to_hour: '17:00'
178
179 - name: set-user
180 cp_mgmt_user:
181 authentication_method: undefined
182 expiration_date: '2035-01-15'
183 from_hour: '12:00'
184 name: myuser
185 state: present
186
187 - name: delete-user
188 cp_mgmt_user:
189 name: myuser
190 state: absent
191 """
192
193 RETURN = """
194 cp_mgmt_user:
195 description: The checkpoint object created or updated.
196 returned: always, except when deleting the object.
197 type: dict
198 """
199
200 from ansible.module_utils.basic import AnsibleModule
201 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, \
202 api_call
203
204
205 def main():
206 argument_spec = dict(
207 name=dict(type='str', required=True),
208 template=dict(type='str'),
209 email=dict(type='str'),
210 expiration_date=dict(type='str'),
211 phone_number=dict(type='str'),
212 authentication_method=dict(type='str',
213 choices=['undefined',
214 'check point password',
215 'os password',
216 'securid',
217 'radius',
218 'tacacs']),
219 password=dict(type='str', no_log=True),
220 radius_server=dict(type='str'),
221 tacacs_server=dict(type='str'),
222 connect_on_days=dict(type='list', elements="str"),
223 connect_daily=dict(type='bool'),
224 from_hour=dict(type='str'),
225 to_hour=dict(type='str'),
226 allowed_locations=dict(type='dict', options=dict(
227 destinations=dict(type='list', elements="str"),
228 sources=dict(type='list', elements="str")
229 )),
230 encryption=dict(type='dict', options=dict(
231 ike=dict(type='bool'),
232 public_key=dict(type='bool')
233 )),
234 color=dict(type='str', choices=['aquamarine',
235 'black',
236 'blue',
237 'crete blue',
238 'burlywood',
239 'cyan',
240 'dark green',
241 'khaki',
242 'orchid',
243 'dark orange',
244 'dark sea green',
245 'pink',
246 'turquoise',
247 'dark blue',
248 'firebrick',
249 'brown',
250 'forest green',
251 'gold',
252 'dark gold',
253 'gray',
254 'dark gray',
255 'light green',
256 'lemon chiffon',
257 'coral',
258 'sea green',
259 'sky blue',
260 'magenta',
261 'purple',
262 'slate blue',
263 'violet red',
264 'navy blue',
265 'olive',
266 'orange',
267 'red',
268 'sienna',
269 'yellow']),
270 comments=dict(type='str'),
271 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
272 ignore_warnings=dict(type='bool'),
273 groups=dict(type='list', elements="str"),
274 ignore_errors=dict(type='bool'),
275 tags=dict(type='list', elements="str")
276 )
277 argument_spec.update(checkpoint_argument_spec_for_objects)
278
279 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
280 api_call_object = 'user'
281
282 result = api_call(module, api_call_object)
283 module.exit_json(**result)
284
285
286 if __name__ == '__main__':
287 main()