write_files defer not using ownership for new folders
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Fix Released
|
High
|
Unassigned |
Bug Description
I would like to point out what I consider is a bug.
If the folder where the file is created exists, the file is created with the appropriate ownership. However if it doesn't exists, the file is created with the proper ownership while the folder is with root ownership.
In my case the default user is called ubuntu ;)
write_files:
- path: /home/ubuntu/
content: |
hi in
owner: 'ubuntu:ubuntu'
permissions: '0644'
defer: true
- path: /home/ubuntu/
content: |
hi out
owner: 'ubuntu:ubuntu'
permissions: '0644'
defer: true
After running everthing:
ubuntu@
-rw-r--r-- 5 ubuntu ubuntu 6 Sep 22 10:44 file-out.txt
ubuntu@
drwxr-xr-x 3 root root 4096 Sep 22 2022 .help
ubuntu@
-rw-r--r-- 5 ubuntu ubuntu 7 Sep 22 10:44 file-out.txt
I guess the correct way should be to inherit the ownership for the folder as well, unless pointed out in another way.
What do you think?
Changed in cloud-init: | |
importance: | Medium → High |
Thanks for the report, jlanzac.
I have reproduced the case and I think inheriting the ownership for newly required created folders is what the user would expect.