templates - Parsing an IP ADDR in a attribute that will use in a configration -


i have set of master , slave postgresql server. need dbslave server see dbmaster server. in pg_hba.conf have ruby variable name private_ip within node.

the template pg_hba.conf looks this:

 <% node["postgresql"]["pg_hba"].each |hba| %>  <%= hba['type'] %> <%= hba['db'] %> <%= hba['user'] %> <%= hba['addr'] %> <%= hba['method'] %>  <% end %> 

and in recipe this. value of each hash node.

slave.rb recipe:

 # hba  node.override["postgresql"]["pg_hba"] = [ { "type" => "host", "db" => "all", "user" =>"all", "addr" => "<%= private_ip %>", "method" => "trust"} 

to ip address use search method.

 dbserver = search(:node, "role:pg_server_master")  private_ip = "#{dbserver[0][:private_ip]}"  puts private_ip 

the question - how can put value of result of search on node.override variable <%= private_ip =>.

any ideas, please?

i used search method chef:

  # getting private ip pg_hba.conf   dbserver = search(:node, "role:oftheserver")   private_ip = dbserver[0]['ipaddress']   mask = @ipaddress.to_s + "/32" 

so output of search x.x.x.x/32 in case.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -