[chef] Re: RE: how to append an variable using chef


Chronological Thread 
  • From: Sachin Gupta < >
  • To: " " < >
  • Cc: sachin kumar < >
  • Subject: [chef] Re: RE: how to append an variable using chef
  • Date: Tue, 9 Jun 2015 15:41:33 +0530

Hi Chris,

 I am using chef-solo for my development.  I don't think chef-solo supports Search indexes.

I am using a  temp file to write the cluster configuration like

execute "Setting cluster configuration" do
          command "echo -n  #{man_attrib.ip_address}:#{man_attrib.listen_port}, >> /tmp/wls_cluster"
         end

Is this the right approach??

Thanks
Sachin

On Mon, Jun 8, 2015 at 7:04 PM, Fouts, Chris < " target="_blank"> > wrote:

Try,

 

knife exec -E 'nodes.find(:name => some_node) {|n| n.set.ohs.wls_cluster = “ip_address : listen_port” ; n.save }'

 

 

Chris

 

From: Sachin Gupta [mailto: " target="_blank"> ]
Sent: Monday, June 08, 2015 6:38 AM
To: " target="_blank">
Cc: sachin kumar
Subject: [chef] how to append an variable using chef

 

Hi All,

I need to set an attribute  variable through chef recipe.

I an using a role file where I have defined weblogic cluster information  like

 "wls_cluster": {
                "oci_cluster1": {
                    "managed_servers": {
                        "oci_man1": {
                            "ip_address": "10.10.10.31",
                            "listen_port": "7101"
                        },
                        "oci_man2": {
                            "ip_address": "10.10.10.32",
                            "listen_port": "7101"
                        }
                    }
                },

my weblogic oci_cluster1 can have any number of managed servers, is this example there are two

In my chef recipe i am using this code to fetch run time managed servers information

  
        node[:ohs][:wls_cluster].each do |cluster, cluster_attrib|
           cluster_attrib.managed_servers.each do |managed_server, man_attrib|
            Chef::Log.info "the IP address  is #{man_attrib.ip_address} and port is #{man_attrib.listen_port}"
            node.set[:ohs][:wls_cluster] = "#{man_host}:#{man_port},"
            Chef::Log.info "the value of wls_cluster are #{node[:ohs][:wls_cluster]}"
           end
        end


I have an attribute variable default[:ohs][:wls_cluster] ='' initially set to null, I want to set this variable through chef recipe something like

[:ohs][:wls_cluster]= "ip_address:listen_port,ip_address:listen_port,ip_address:listen_port...."

can anyone help how to append the variable values using chef.


Thanks & Regards,

Sachin Gupta





Archive powered by MHonArc 2.6.16.

§