canonical / canonical/cloud-init
write_files as a specific user fails if folder is owned by root
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 18
Description
# Bug report
## Steps to reproduce the problem
Use this cloud-init.yaml file:
```yaml
#cloud-config
users:
- name: asterisk
gecos: 'Asterisk User'
groups: users
sudo: ['ALL=(ALL) NOPASSWD:ALL']
shell: /bin/bash
lock_passwd: true
write_files:
- path: /var/log/asterisk/empty.log
owner: asterisk:asterisk
permissions: '0664'
content: |
---LOG BEGINS---
```
The file does not get written to /var/log/asterisk/empty.log
Remove `owner: asterisk:asterisk` and try again, voila, it works.
## Environment details
- Cloud-init version: cloud-init 24.4-0ubuntu1~24.04.2
- Operating System Distribution: Ubuntu 24.04.2
- Cloud provider, platform or installer type: Google Cloud
## cloud-init logs
https://pastebin.canonical.com/p/7njH9PswGW/
Contributor guide
Assessment
This issue has not been assessed yet.