Using a variable inside a Chef recipe

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

    Please follow this link http://lists.opscode.com/sympa/arc/chef/2015-03/msg00266.html you can use node.run_state[:variables] for parsing one variable to another recipe

    Here is my code :: file.rb

    node.run_state[:script_1] = "foo" include_recipe 'provision::copy'

    and in other copy.rb file put following code ::

    copy.rb

    filename = node.run_state[:script_1] puts "Name is #{filename}"

提交回复
热议问题