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


Chronological Thread 
  • From: "Fouts, Chris" < >
  • To: " " < >
  • Subject: [chef] RE: how to append an variable using chef
  • Date: Mon, 8 Jun 2015 13:34:15 +0000
  • Accept-language: en-US

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:
Sent: Monday, June 08, 2015 6:38 AM
To:
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.

§