mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Module consistency and make daisy chaining work with invalid arguments detection.
This commit is contained in:
15
library/file
15
library/file
@@ -31,7 +31,7 @@ def add_path_info(kwargs):
|
||||
path = kwargs['path']
|
||||
if os.path.exists(path):
|
||||
(user, group) = user_and_group(path)
|
||||
kwargs['user'] = user
|
||||
kwargs['owner'] = user
|
||||
kwargs['group'] = group
|
||||
st = os.stat(path)
|
||||
kwargs['mode'] = oct(stat.S_IMODE(st[stat.ST_MODE]))
|
||||
@@ -209,13 +209,10 @@ def set_mode_if_different(path, mode, changed):
|
||||
def rmtree_error(func, path, exc_info):
|
||||
module_fail_json(path=path, msg='failed to remove directory')
|
||||
|
||||
# ===========================================
|
||||
# go...
|
||||
|
||||
def main():
|
||||
|
||||
global module
|
||||
module = AnsibleModule(
|
||||
module = AnsibleFileModule(
|
||||
argument_spec = dict(
|
||||
state = dict(choices=['file','directory','link','absent'], default='file'),
|
||||
path = dict(aliases=['dest', 'name'], required=True),
|
||||
@@ -351,6 +348,12 @@ def main():
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
|
||||
|
||||
class AnsibleFileModule(AnsibleModule):
|
||||
|
||||
def _check_invalid_arguments(self):
|
||||
# needed to support daisy chaining
|
||||
pass
|
||||
|
||||
main()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user