[chef] Re: Unusual behavior of attributes as node object is not getting reset during client run


Chronological Thread 
  • From: Mrigesh Priyadarshi < >
  • To: Daniel DeLeo < >
  • Cc:
  • Subject: [chef] Re: Unusual behavior of attributes as node object is not getting reset during client run
  • Date: Thu, 24 Oct 2013 11:34:46 +0530

Thanks Daniel. That(Putting all attributes on one location) was also on my mind but I wanted to put all attributes in attributes file only and calling library function in attribute file was failing.

Anyhow, I put the below two lines in recipe only and it worked like a charm.
<<<  ====
node.default[:net][:user] = {node[:db2][:uid] => [ node[:db2][:user], "db2 user", node[:db2][:db2home]] }
node.default[:net][:group] = { node[:db2][:gid] => node[:db2][:group] }
=======   >>>

Thanks again for the help.



Warm Regards,

Mrigesh Priyadarshi
             


On Thu, Oct 24, 2013 at 4:16 AM, Daniel DeLeo < " target="_blank"> > wrote:
On Wednesday, October 23, 2013 at 6:30 AM, Mrigesh Priyadarshi wrote:
Hello,


I am working on a recipe of DB2 installation where the User and group information changes with every DB2 version.

So, I put user and group info in data bag  and trying to override the information in attribute file with the data_bag info.

This is what i did :-
<<< ----
In data_bag :-
{"id":"db2","V9.1":{"uid":"9001","uname":"db91inst","gid":"9100","gname":"db9grp"},"V9.5":{"uid":"9005","uname":"db95inst","gid":"9100","gname":"db9grp"}}

In attribute file:-
default[:db2][:version] = "V9.5"
default[:db2][:uid] = "uid"
default[:db2][:user] = "db2user"
default[:db2][:gid] = "gid"
default[:db2][:group] = "db2grp"
default[:net][:user] = {node[:db2][:uid] => [ node[:db2][:user], "db2 user", node[:db2][:db2home]] }
On the first pass, you set node[:net][:user] to {node[:db2][:uid] => [ node[:db2][:user], "db2 user", node[:db2][:db2home]] }
 
default[:net][:group] = { node[:db2][:gid] => node[:db2][:group] }
=========================================================
In recipe file :-
db2client = node[:db2]
version = db2client[:version]
node.set[:db2][:uid] = DB2InstallInfo.getInstallUserId(version)
Here, you change node[:db2][:uid] to a new value. This _does not_ update node[:net][:user], but it does set  node[:db2][:uid]  to a persistent attribute (belongs to the node itself and is independent of any roles/recipes applied to the node).

default[:net][:user] = {node[:db2][:uid] => [ node[:db2][:user], "db2 user", node[:db2][:db2home]] }
On the second run, node[:db2][:uid] is going to be the value that you set in the recipe, because it “pre-exists” on the node and is higher precedence than the default value you set in the attributes file.


You can probably make everything a lot simpler if you set all your attributes in one place, if possible.

 
-- 
Daniel DeLeo






Archive powered by MHonArc 2.6.16.

§