During image packing, our chef code downloads files from the internet into the chef file_cache_path default location, /var/chef/cache.
Later, when the servers come up from the packed image using cloud-init, everything that should be cached is being re-downloaded.
Steps to reproduce the problem
Pack a server image using an /etc/chef/client.rb that does not configure a file_cache_path. Data will be cached in /var/chef/cache
Deploy that server image with cloud-init and do not configure a file_cache_path. /etc/chef/client.rb will be rendered with file_cache_path "/var/cache/chef".
Cloud-init renders a file with the non-default cache path:
[root@ip-172-17-6-13 /] :) head -2 /etc/chef/client.rb
# Created by cloud-init v. 19.3-46.amzn2.0.1 on Tue, 05 Mar 2024 20:23:33 +0000
log_level :info
[root@ip-172-17-6-13 /] :) grep file_cache_path /etc/chef/client.rb
file_cache_path "/var/cache/chef"
Thank you for this bug @RulerOf and making cloud-init better. It does appear this is a typo in the original chef defaults and I believe should be corrected to /var/chef/cache in cloud-init defaults.
Bug report
During image packing, our chef code downloads files from the internet into the chef
file_cache_path
default location,/var/chef/cache
.Later, when the servers come up from the packed image using cloud-init, everything that should be cached is being re-downloaded.
Steps to reproduce the problem
/etc/chef/client.rb
that does not configure afile_cache_path
. Data will be cached in/var/chef/cache
file_cache_path
./etc/chef/client.rb
will be rendered withfile_cache_path "/var/cache/chef"
.https://github.com/canonical/cloud-init/blob/main/cloudinit/config/cc_chef.py#L61
More Details
As shown on one of my servers, this is the chef section of the user-data:
Cloud-init renders a file with the non-default cache path:
Chef respects this config:
Removing
file_cache_path
from my client.rb brings back the expected result:Environment details
19.3-46.amzn2.0.1