[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1040979: write_files: defer not working any more



On 7/14/23 06:49, Sven Strickroth wrote:
I'm not able to reproduce the behavior you describe.  defer seems to
work as expected.  For example:

admin@ip-10-0-0-87:~$ ec2-metadata --ami-id
ami-id: ami-0544719b13af6edc3
admin@ip-10-0-0-87:~$ sudo cat /var/lib/cloud/instance/user-data.txt
#cloud-config
write_files:
- content: |
     testing. this file should be owned by the dynamically created user
   path: /test-file
   owner: admin:admin
   defer: true
admin@ip-10-0-0-87:~$ ls -l /test-file
-rw-r--r-- 1 admin admin 67 Jul 13 16:59 /test-file

That example does not work for me on Hetzner.cloud.

Strange. The functionality works as expected for me using the current bookworm AMIs on Amazon EC2, as shown in the output below. I don't have an account with Hetzner, so I'm afraid you're going to have to collect some more information.

Can you show that the "defer" field in your cloud-config is making through to the input that's passed to cloud-init?

Can you show that write_files works without the defer flag?

The write_files modules are defined to run once per instance. Is it possible that your launches are not showing up as new instances, resulting in cloud-init skipping their execution?

noah

admin@ip-10-0-0-199:~$ sudo cat /var/lib/cloud/instance/user-data.txt
#cloud-config
locale: de_DE.UTF-8
timezone: Europe/Berlin
package_update: true # Implied with `package_upgrade: true`
package_upgrade: true
packages: ['joe','mariadb-server','aptitude','psmisc','bzip2','fail2ban','postfix','apticron','nagios-nrpe-server','monitoring-plugins','libmariadb3','borgbackup','logwatch']
write_files:
- content: |
    [mysqldump]
    max_allowed_packet     = 60M
  path: /etc/mysql/mariadb.conf.d/51-dump.cnf
  defer: true
admin@ip-10-0-0-199:~$ cat /etc/mysql/mariadb.conf.d/51-dump.cnf
[mysqldump]
max_allowed_packet     = 60M
admin@ip-10-0-0-199:~$ grep write-files-deferred /var/log/cloud-init.log
2023-07-14 21:28:41,034 - modules.py[DEBUG]: Running module write-files-deferred (<module 'cloudinit.config.cc_write_files_deferred' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_write_files_deferred.py'>) with frequency once-per-instance 2023-07-14 21:28:41,034 - handlers.py[DEBUG]: start: modules-final/config-write-files-deferred: running config-write-files-deferred with frequency once-per-instance 2023-07-14 21:28:41,036 - helpers.py[DEBUG]: Running config-write-files-deferred using lock (<FileLock using file '/var/lib/cloud/instances/i-096c9d6b1c3c04be6/sem/config_write_files_deferred'>) 2023-07-14 21:28:41,036 - handlers.py[DEBUG]: finish: modules-final/config-write-files-deferred: SUCCESS: config-write-files-deferred ran successfully


Reply to: