Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write_files as a specific user fails if folder is owned by root #6042

Open
rajannpatel opened this issue Feb 21, 2025 · 1 comment
Open

write_files as a specific user fails if folder is owned by root #6042

rajannpatel opened this issue Feb 21, 2025 · 1 comment
Labels
incomplete Action required by submitter

Comments

@rajannpatel
Copy link

Bug report

Steps to reproduce the problem

Use this cloud-init.yaml file:

#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/

@rajannpatel rajannpatel added bug Something isn't working correctly new An issue that still needs triage labels Feb 21, 2025
@TheRealFalcon
Copy link
Member

@rajannpatel , if you add defer: true to your write_files definition, I think it should work:

write_files:
  - path: /var/log/asterisk/empty.log
    owner: asterisk:asterisk
    permissions: "0664"
    defer: true
    content: |
      ---LOG BEGINS---

By default, write_files runs before users and groups get created, but defer tells it to run later in boot.

@TheRealFalcon TheRealFalcon added incomplete Action required by submitter and removed bug Something isn't working correctly new An issue that still needs triage labels Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incomplete Action required by submitter
Projects
None yet
Development

No branches or pull requests

2 participants