44
44
version_added: "2.3"
45
45
get_checksum:
46
46
version_added: "1.8"
47
+ get_selinux_context:
48
+ description:
49
+ - Get file SELinux context in a list V([user, role, type, range]),
50
+ and will get V([None, None, None, None]) if it is not possible to retrieve the context,
51
+ either because it does not exist or some other issue.
52
+ type: bool
53
+ default: no
54
+ version_added: '2.20'
47
55
extends_documentation_fragment:
48
56
- action_common_attributes
49
57
- checksum_common
346
354
type: list
347
355
sample: [ immutable, extent ]
348
356
version_added: 2.3
357
+ selinux_context:
358
+ description: The SELinux context of a path
359
+ returned: success, path exists and user can execute the path
360
+ type: list
361
+ sample: [ user, role, type, range ]
362
+ version_added: '2.20'
349
363
version:
350
364
description: The version/generation attribute of a file according to the filesystem
351
365
returned: success, path exists, user can execute the path, lsattr is available and filesystem supports
@@ -434,6 +448,7 @@ def main():
434
448
get_checksum = dict (type = 'bool' , default = True ),
435
449
get_mime = dict (type = 'bool' , default = True , aliases = ['mime' , 'mime_type' , 'mime-type' ]),
436
450
get_attributes = dict (type = 'bool' , default = True , aliases = ['attr' , 'attributes' ]),
451
+ get_selinux_context = dict (type = 'bool' , default = False ),
437
452
checksum_algorithm = dict (type = 'str' , default = 'sha1' ,
438
453
choices = ['md5' , 'sha1' , 'sha224' , 'sha256' , 'sha384' , 'sha512' ],
439
454
aliases = ['checksum' , 'checksum_algo' ]),
@@ -448,6 +463,7 @@ def main():
448
463
get_attr = module .params .get ('get_attributes' )
449
464
get_checksum = module .params .get ('get_checksum' )
450
465
checksum_algorithm = module .params .get ('checksum_algorithm' )
466
+ get_selinux_context = module .params .get ('get_selinux_context' )
451
467
452
468
# main stat data
453
469
try :
@@ -515,6 +531,10 @@ def main():
515
531
if x in out :
516
532
output [x ] = out [x ]
517
533
534
+ # try to get SELinux context
535
+ if get_selinux_context :
536
+ output ['selinux_context' ] = module .selinux_context (b_path )
537
+
518
538
module .exit_json (changed = False , stat = output )
519
539
520
540
0 commit comments