Would it be possible to add a new module to handle the directory feature?
Proposed new module name is 'File'.
I tried to add 'chownbyname' in 'ensure_dir' method directly, which will only change the ownership for parent directory only.
But I have some concerns.
As 'os.makedirs' will create directories recursively by default, we can not easily know which of them are newly created. So there would introduce much more logic to detect which directories is newly created and which exist already.
e.g.
- path: /home/ubuntu/foo/bar/baz/file-in.txt
We have to check whether all '/home/ubuntu/foo/bar/baz', '/home/ubuntu/foo/bar' and '/home/ubuntu/foo' exist. If all of them don't exist, we have to change ownership for all of them.
It is inspired by shixuantong (sxt1001)'s idea. If so, users have to ensure the directory exists first via 'file' module and then write out arbitrary content to files via 'Write Files' module.
Hi
Would it be possible to add a new module to handle the directory feature?
Proposed new module name is 'File'.
I tried to add 'chownbyname' in 'ensure_dir' method directly, which will only change the ownership for parent directory only.
But I have some concerns.
As 'os.makedirs' will create directories recursively by default, we can not easily know which of them are newly created. So there would introduce much more logic to detect which directories is newly created and which exist already.
e.g.
- path: /home/ubuntu/ foo/bar/ baz/file- in.txt
We have to check whether all '/home/ ubuntu/ foo/bar/ baz', '/home/ ubuntu/ foo/bar' and '/home/ubuntu/foo' exist. If all of them don't exist, we have to change ownership for all of them.
It is inspired by shixuantong (sxt1001)'s idea. If so, users have to ensure the directory exists first via 'file' module and then write out arbitrary content to files via 'Write Files' module.
Reference: /github. com/canonical/ cloud-init/ blob/94a00492b1 1995dd9278605eb 29ee4b096ce3a90 /cloudinit/ util.py# L1795 /docs.ansible. com/ansible/ latest/ collections/ ansible/ builtin/ file_module. html#parameter- recurse
https:/
https:/