I'm using cloud-init to setup AWS EC2 machines running Ubuntu 14.04. One of the more useful features of cloud-init is the write_files
module that allows me to install additional files during the initialization of the virtual machine.
write_files
has several useful functions, among them is setting the owner of the file, as documented here. Unfortunately, it appears that I can't use this feature of write_files
in Ubuntu 14.04 to set the file owner to any non-system account, because the cloud-init module that adds users - "users groups" is being run after the write_files
section. If I set file owner to a user that is added in the users
section (or in my case the default users
), even if I do this by uid, I get errors such as this:
StandardError:('write-files', OSError("Unknown user or group: 'getpwnam(): name not found: ubuntu'",))
This seems coded into /etc/cloud/cloud.cfg, which has this section:
cloud_init_modules:
- migrator
- seed_random
- bootcmd
- write-files
- growpart
- resizefs
- set_hostname
- update_hostname
- update_etc_hosts
- ca-certs
- rsyslog
- users-groups
- ssh
I've seen a few examples on the internet that set cloud_init_modules
in the cloud-init user data, but if I add such a section and order it so write-files
is under users-groups
, it doesn't seem to have any effect.
Aside from giving up on write_files
and implementing a runcmd
based workaround as documented in question #605670 is there anything else that can be done?