Using a variable inside a Chef recipe

前端 未结 4 960
终归单人心
终归单人心 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:23

    I used node.run_state['variable'] for the same purpose and was successfully able to do it. Please find basic sample code below.

    ruby_block "resource_name" do
       block do
         node.run_state['port_value'] = 1432
       end
    end
    
    ruby_block "resource_name2" do
       block do
          num = node.run_state['variable']
       end
    end
    

    I hope it will help.

提交回复
热议问题