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

前端 未结 1 1959
日久生厌
日久生厌 2021-01-25 08:27

In my attributes file for postgresql recipe I have:

default[\'postgresql\'][\'pg_hba\'] = {
    :comment => \'# IPv4 lo         


        
相关标签:
1条回答
  • 2021-01-25 09:19

    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
    
    0 讨论(0)
提交回复
热议问题