- From: "D.A." <
>
- To:
- Subject: [chef] Set attribute from recipe
- Date: Sun, 3 Nov 2013 16:40:19 +0400
Hi,
I need to set an attribute (value) from default recipe.
Here is the code that I have and it works on my lab.
CentOS 6.4
Chef Server: chef-server-11.0.8-1.el6.x86_64
Chef Client: 11.4.4
attributes/default.rb
default['yum']['epel']['url'] = "http://#{node['yum_srv_ip']}/epel/6/#{node['kernel']['machine']}"
default['yum']['epel']['enabled'] = 1
recipes/default.rb
nodes = search("node", "recipe:rm-yum-srv AND chef_environment:#{node.chef_environment}")
node.default['yum_srv_ip'] = nodes.first['ipaddress']
Chef::Log.info("20 YUM_SRV_IP: #{node['yum_srv_ip']}")
Chef::Log.info("20 LOOKUP: #{nodes.first['ipaddress']}")
Chef::Log.info("20 ENV: #{node.chef_environment}")
The problem becomes when I try to compile that same code in different environment (set of servers)
yum_srv_ip is empty and URL can't be built, however I can see the value printed to console ( Chef::Log from recipe )
CentOS 6.3
Chef Server: chef-server-11.0.4-1.el6.x86_64
Chef client: 11.4.0
Any idea where to have a look ?
Thanks
- [chef] Set attribute from recipe, D.A., 11/03/2013
Archive powered by MHonArc 2.6.16.