* Clarify append and groups behavior
* Document return values
(cherry picked from commit 6fa2d9a)
Co-authored-by: Sam Doran <sdoran@redhat.com>
... | ... |
@@ -12,7 +12,6 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', |
12 | 12 |
'supported_by': 'core'} |
13 | 13 |
|
14 | 14 |
DOCUMENTATION = ''' |
15 | 15 |
module: user |
16 | 16 |
author: |
17 | 17 |
- Stephen Fromm (@sfromm) |
... | ... |
@@ -60,13 +59,16 @@ options: |
60 | 60 |
- Optionally sets the user's primary group (takes a group name). |
61 | 61 |
groups: |
62 | 62 |
description: |
63 |
- - Puts the user in list of groups. When set to the empty string ('groups='), |
|
64 |
- the user is removed from all groups except the primary group. |
|
65 |
- - Before version 2.3, the only input format allowed was a 'comma separated string', |
|
66 |
- now it should be able to accept YAML lists also. |
|
63 |
+ - List of groups user will be added to. When set to an empty string C(''), |
|
64 |
+ C(null), or C(~), the user is removed from all groups except the |
|
65 |
+ primary group. (C(~) means C(null) in YAML) |
|
66 |
+ - Before version 2.3, the only input format allowed was a comma separated string. |
|
67 |
+ Now this parameter accepts a list as well as a comma separated string. |
|
67 | 68 |
append: |
68 | 69 |
description: |
69 |
- - If C(yes), will only add groups, not set them to just the list in I(groups). |
|
70 |
+ - If C(yes), add the user to the groups specified in C(groups). |
|
71 |
+ - If C(no), user will only be added to the groups specified in C(groups), |
|
72 |
+ removing them from all other groups. |
|
70 | 73 |
type: bool |
71 | 74 |
default: "no" |
72 | 75 |
shell: |
... | ... |
@@ -233,9 +235,110 @@ EXAMPLES = ''' |
233 | 233 |
user: |
234 | 234 |
name: james18 |
235 | 235 |
expires: -1 |
236 |
+''' |
|
236 | 237 |
|
238 |
+RETURN = ''' |
|
239 |
+append: |
|
240 |
+ description: Whether or not to append the user to groups |
|
241 |
+ returned: When state is 'present' and the user exists |
|
242 |
+ type: bool |
|
243 |
+ sample: True |
|
244 |
+comment: |
|
245 |
+ description: Comment section from passwd file, usually the user name |
|
246 |
+ returned: When user exists |
|
247 |
+ type: string |
|
248 |
+ sample: Agent Smith |
|
249 |
+create_home: |
|
250 |
+ description: Whether or not to create the home directory |
|
251 |
+ returned: When user does not exist and not check mode |
|
252 |
+ type: bool |
|
253 |
+ sample: True |
|
254 |
+force: |
|
255 |
+ description: Whether or not a user account was forcibly deleted |
|
256 |
+ returned: When state is 'absent' and user exists |
|
257 |
+ type: bool |
|
258 |
+ sample: False |
|
259 |
+group: |
|
260 |
+ description: Primary user group ID |
|
261 |
+ returned: When user exists |
|
262 |
+ type: int |
|
263 |
+ sample: 1001 |
|
264 |
+groups: |
|
265 |
+ description: List of groups of which the user is a member |
|
266 |
+ returned: When C(groups) is not empty and C(state) is 'present' |
|
267 |
+ type: string |
|
268 |
+ sample: 'chrony,apache' |
|
269 |
+home: |
|
270 |
+ description: "Path to user's home directory" |
|
271 |
+ returned: When C(state) is 'present' |
|
272 |
+ type: string |
|
273 |
+ sample: '/home/asmith' |
|
274 |
+move_home: |
|
275 |
+ description: Whether or not to move an existing home directory |
|
276 |
+ returned: When C(state) is 'present' and user exists |
|
277 |
+ type: bool |
|
278 |
+ sample: False |
|
279 |
+name: |
|
280 |
+ description: User account name |
|
281 |
+ returned: always |
|
282 |
+ type: string |
|
283 |
+ sample: asmith |
|
284 |
+password: |
|
285 |
+ description: Masked value of the password |
|
286 |
+ returned: When C(state) is 'present' and C(password) is not empty |
|
287 |
+ type: string |
|
288 |
+ sample: 'NOT_LOGGING_PASSWORD' |
|
289 |
+remove: |
|
290 |
+ description: Whether or not to remove the user account |
|
291 |
+ returned: When C(state) is 'absent' and user exists |
|
292 |
+ type: bool |
|
293 |
+ sample: True |
|
294 |
+shell: |
|
295 |
+ description: User login shell |
|
296 |
+ returned: When C(state) is 'present' |
|
297 |
+ type: string |
|
298 |
+ sample: '/bin/bash' |
|
299 |
+ssh_fingerprint: |
|
300 |
+ description: Fingerprint of generated SSH key |
|
301 |
+ returned: When C(generate_ssh_key) is C(True) |
|
302 |
+ type: string |
|
303 |
+ sample: '2048 SHA256:aYNHYcyVm87Igh0IMEDMbvW0QDlRQfE0aJugp684ko8 ansible-generated on host (RSA)' |
|
304 |
+ssh_key_file: |
|
305 |
+ description: Path to generated SSH public key file |
|
306 |
+ returned: When C(generate_ssh_key) is C(True) |
|
307 |
+ type: string |
|
308 |
+ sample: /home/asmith/.ssh/id_rsa |
|
309 |
+ssh_public_key: |
|
310 |
+ description: Generated SSH public key file |
|
311 |
+ returned: When C(generate_ssh_key) is C(True) |
|
312 |
+ type: string |
|
313 |
+ sample: > |
|
314 |
+ 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC95opt4SPEC06tOYsJQJIuN23BbLMGmYo8ysVZQc4h2DZE9ugbjWWGS1/pweUGjVstgzMkBEeBCByaEf/RJKNecKRPeGd2Bw9DCj/bn5Z6rGfNENKBmo |
|
315 |
+ 618mUJBvdlEgea96QGjOwSB7/gmonduC7gsWDMNcOdSE3wJMTim4lddiBx4RgC9yXsJ6Tkz9BHD73MXPpT5ETnse+A3fw3IGVSjaueVnlUyUmOBf7fzmZbhlFVXf2Zi2rFTXqvbdGHKkzpw1U8eB8xFPP7y |
|
316 |
+ d5u1u0e6Acju/8aZ/l17IDFiLke5IzlqIMRTEbDwLNeO84YQKWTm9fODHzhYe0yvxqLiK07 ansible-generated on host' |
|
317 |
+stderr: |
|
318 |
+ description: Standard error from running commands |
|
319 |
+ returned: When stderr is returned by a command that is run |
|
320 |
+ type: string |
|
321 |
+ sample: Group wheels does not exist |
|
322 |
+stdout: |
|
323 |
+ description: Standard output from running commands |
|
324 |
+ returned: When standard output is returned by the command that is run |
|
325 |
+ type: string |
|
326 |
+ sample: |
|
327 |
+system: |
|
328 |
+ description: Whether or not the account is a system account |
|
329 |
+ returned: When C(system) is passed to the module and the account does not exist |
|
330 |
+ type: bool |
|
331 |
+ sample: True |
|
332 |
+uid: |
|
333 |
+ description: User ID of the user account |
|
334 |
+ returned: When C(UID) is passed to the module |
|
335 |
+ type: int |
|
336 |
+ sample: 1044 |
|
237 | 337 |
''' |
238 | 338 |
|
339 |
+ |
|
239 | 340 |
import errno |
240 | 341 |
import grp |
241 | 342 |
import os |