Chef: Undefined Node Attribute or Method '<<' on 'Node' When Trying to Add

Chef: Undefined node attribute or method `' on `node' when trying to add

Your problem is here:

node['postgresql']['pg_hba'] << {

This way you're accessing the attribute for reading.

Assuming you want to stay at default level you have to use default method like this:

node.default['postgresql']['pg_hba'] << { ... }

This will call default method (like in attribute file) to add the entry.

For this to work the first attribute declaration should be an array (or a hash of hash) like this:

default['postgresql']['pg_hba'] = [{ # notice the [ opening an array
:comment => '# IPv4 local connections',
:type => 'host',
:db => 'all',
:user => 'all',
:addr => '127.0.0.1/32',
:method => 'md5'
}] # Same here to close the array

ERROR: undefined method `python' for #Chef::Node::Attribute:0x00000003f78ef8

That cookbook (python) is deprecated and does not work with Chef 13. Use poise-python instead.

MySQL Chef: NoMethodError: undefined method `set' for #Chef::Node::Attribute

Found, it seems to be a compatibility issue between chef-client and mysql cookbook

By specifying in the Berksfile

cookbook 'mysql', '~> 7.0' 

And in kitchen.yaml

product_name: chef
product_version: 14.12.9

Chef: undefined method `platform_version'

We removed the method syntax for node attributes in Chef 13. The code needs to be updated to node["platform_version"].

ChefSpec - Unable to set node attributes

You are able to set node attributes. If you look at the stacktrace, it's complaining about this line:

expect(chef_run).to create_directory("#{node['nginx']['dir']}")

Specifically, #{node['nginx']['dir']}. You should use a static value here, otherwise your test is pointless. Change it to:

expect(chef_run).to create_directory('/etc/nginx')


Related Topics



Leave a reply



Submit