Using a variable inside a Chef recipe

前端 未结 4 958
终归单人心
终归单人心 2021-01-14 09:48

I\'m using chef-cookbook-hostname cookbook to setup node\'s hostname. I don\'t want my hostname to be hard coded in the attribute file (default[\'set_fqdn\']).

In

4条回答
  •  情深已故
    2021-01-14 10:28

    The source of the problem here is that you are setting the variable fqdn inside the scope of a ruby_block and are attempting to make reference to that variable at the compilation phase. The ruby_block resources allows the ability to run ruby code during the convergence phase.

    Given that you appear to be using the fqdn to setup the resource set, it looks as though you can remove the ruby block from around the ruby code. e.g.

    fqdn = // logic to get fqdn
    
    file '/tmp/file' do
      content "fqdn=#{fqdn}"
    end
    

提交回复
热议问题