- From: Daniel DeLeo <
>
- To:
- Cc: sachin kumar <
>
- Subject: [chef] Re: Re: RE: how to append an variable using chef
- Date: Tue, 9 Jun 2015 14:28:40 -0700
On Tuesday, June 9, 2015 at 3:11 AM, Sachin Gupta wrote:
>
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??
It’s always better to manage the whole resource if you can. If you generated
that file from a template earlier, it would be preferable to merge the data
you pass in to the template instead of appending to it like this.
If you have no other option, then you should take care to ensure that this
won’t keep appending every time you run chef.
>
>
Thanks
>
Sachin
--
Daniel DeLeo
>
>
On Mon, Jun 8, 2015 at 7:04 PM, Fouts, Chris
>
<
>
>
(mailto:
)>
>
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:
>
>
>
> Sent: Monday, June 08, 2015 6:38 AM
>
> To:
>
>
>
>
>
> (mailto:
)
>
> 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 (http://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 (http://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.