Hi,
I have a partial search in my tomcat recipe. I use it for finding out theMySQL Server Backend for the tomcat application server.At the beginning of my tomcat recipe I get the information for the MysqlServer:
mysql_master_node = partial_search(:node, "roles:mysql_payment_server AND chef_environment:#{node.chef_environment}",:keys => { 'name' => ['name'],'ip' => ['ipaddress‘],'kernel_version' => ['kernel','version']})if mysql_master_node.length == 1mysql_master_node.each do |result|if result['name'] == node['machinename']node.set['tc']['payserver']['database_master'] = 'localhost'elsenode.set['tc']['payserver']['database_master'] =mysql_master_node[0]['ip']endEnd
During the rest of the recipe, I will use the node variablenode['tc']['payserver'][‚database_master‘] to define the mysql backendserver in the server.xml of the tomcat.
template node['tc']['server_conf_file'] dosource 'server.xml.erb'mode '0644'owner 'tomcatusr1'group 'tomcatusr1'variables({:mysql_master =>node['tc']['payserver']['database_master'],})notifies :restart, "service[#{node['tc']['service_name']}]"End
It seems that the variable will set during the first run, and can onlyused in the second chef-client run.In the first run, the server.xml don’t have the content ofnode['tc']['payserver'][‚database_master‘] in it. After the second run,the file is correct.
Do you have any idea to solve this or is there a better way gettingbackend server information?
Thanks in advance,Christian
Archive powered by MHonArc 2.6.16.