Menu
  • HOME
  • TAGS

Iterating over an array attribute in Chef

ruby,chef,chef-recipe,lwrp

The error appears to be in your template, not your cookbook. In fact, it appears completely unrelated to the files you posted. I'd need to see the #{env_name}_config.conf.erb file and the build_admin.rb file in order to be more help than that.

Is attr_accessor required in resource definition of chef lwrp?

chef,lwrp

def load_current_resource @current_resource = Chef::Resource::Foo.new @new_resource.name @current_resource.name = @new_resource.name end Your problem is here, name is supposed to be invariable (for current and new resource to match) as it identify the resource, you should not try to set @current_resource.name. Remove this line and it should be ok without the accessor....

Where yum_repository resource is defined?

chef,cookbook,lwrp

A LWRP consists of two files, a "resource" (declaration) and "provider" (implementation): https://github.com/chef-cookbooks/yum/blob/master/resources/repository.rb https://github.com/chef-cookbooks/yum/blob/master/providers/repository.rb ...

variable scope in chef LWRPs

ruby,chef,lwrp

It would appear that the default value is passed to each new resource, but not cloned for each new resource. As a result, the array (not it's contents) is the default value. If you add things to this array, it would be expected that each provider using the default attribute...

Using File::read in a provider's default.rb in Chef

ruby,chef,chef-recipe,lwrp

It happens becuase Chef already has a file resource. We have to use the Ruby File class in a recipe.We use ::File to use the Ruby File class to fix this issue. For example: execute 'apt-get-update' do command 'apt-get update' ignore_failure true only_if { apt_installed? } not_if { ::File.exist?('/var/lib/apt/periodic/update-success-stamp') }...