I have the following piece of code in one the recipes?
chef_client_scheduled_task 'Chef Client' do
user node['chef_client']['task']['user']
password node['chef_client']['task']['password']
frequency node['chef_client']['task']['frequency']
end
and when I run I keep getting
* chef_client_scheduled_task[Chef Client] action add
==============================================
Error executing action `add` on resource 'chef_client_scheduled_task[Chef Client]'
===============================================
RuntimeError
------------
can't modify frozen String
Resource Declaration:
---------------------
# In C:/chef/cache/cookbooks/chef-client/recipes/task.rb
27: chef_client_scheduled_task 'Chef Client' do
28: user node['chef_client']['task']['user']
29: password node['chef_client']['task']['password']
I tried changing chef_client_scheduled_task to chef_client_scheduled_task.dup after reading a few blogs but this did not help. Any pointers on how to fix this?
Hmm, I have not changed to Chef 13 yet, but I think you are already using it and this is because of resource cloning, or rather that resource cloning was removed from Chef. The chef-client cookbook already contains a chef_client_scheduled_task 'Chef Client' which means you have to call your resource anything other than Chef Client and it should work.
The error message here is quite misleading. Maybe this will be changed/fixed in future releases of the chef client.
I tried changing C:/chef/cache/cookbooks/chef-client/recipes/task.rb
and chef_client_scheduled_task 'Chef Client' to chef_client_scheduled_task 'ChefC'
everytime I run the recipe this reverts to chef_client_scheduled_task 'Chef Client'. Anything I am missing? I have 13.6.4. Do you recommend downgrading to some 12.x version?
The chef-client cookbook is an official one from the supermarket. You can not just change it and hope that everything works. The thing is that you stated that you have chef_client_scheduled_task 'Chef Client' in one of your recipes. In which recipe is that? Do you want to use this scheduled task from the chef-client cookbook or anything else?
That is an excerpt from the chef-client cookbook and none of your recipes or cookbooks. If you are trying to use the chef-client cookbook then you need to stop trying to modify this cookbook in any way.
Using the cookbook is quite well documented in the README. For example, to use the task recipe of the chef-client cookbook you need to add chef-client::task to the run list for your node and optionally you can tweak it by setting the attributes mentioned in the README.
The preferred was is usually not to just add the cookbook to the run_list but to write a wrapper cookbook: https://blog.chef.io/2017/02/14/writing-wrapper-cookbooks/.
A good way to start learning all of this is https://learn.chef.io
If I’m reading this conversation right, the error “can’t mosify frozen string” is directly related to the lack of resource cloning in Chef 13.
That’s awesome to know. One of my cookbooks has had that error for a few weeks. Any chance that we could improve that message, so that people like myself wouldn’t have to search too hard?