[chef] Re: Re: Using Role attributes inside bash resource


Chronological Thread 
  • From: Yonah Russ < >
  • To:
  • Subject: [chef] Re: Re: Using Role attributes inside bash resource
  • Date: Thu, 6 Jun 2013 16:48:02 +0300

Here is the resource:

bash "install_newrelic" do
  not_if {!Dir.glob('/etc/newrelic').empty?}
  user "root"
  cwd "/opt/local"
  code <<-EOH
    /usr/bin/wget -r -nH --cut-dirs=5 -np -A 'newrelic-php5-*-solaris.tar.gz' http://download.newrelic.com/php_agent/release/
    /opt/local/bin/tar -xvzf newrelic-php5-*-solaris.tar.gz
    /opt/local/bin/rm newrelic-php5-*-solaris.tar.gz
    /opt/local/bin/chown -R root:root newrelic-php5-*
    (cd newrelic-php5-*; NR_INSTALL_SILENT=true NR_INSTALL_KEY=#{node['webconfig']['newrelic']['key']} ./newrelic-install install)
  EOH
  notifies :restart, resources(:service => "php54-fpm")
end

We tried chef 11 and, unfortunately, so much broke that it just isn't an option for us.
It would set us back weeks to rewrite, test and redeploy everything :(

Thanks
Yonah

On Thu, Jun 6, 2013 at 4:36 PM, Steven Danna < " target="_blank"> > wrote:
Hi,

On 6/5/13 5:25 AM, Yonah Russ wrote:

> When a recipe tries to use one of the role attributes inside the code, I
> get an error:
> /tmp/chef-script20130605-45783-1h9fd78: line 6:
> Chef::Node::Attribute:0x0000000628e1b8: No such file or directory

Could you post the bash resource that is causing this problem?

>
> Is this a known issue?
> Am I doing something wrong?

Errors such as this is one of the reasons that Dan reworked much of the
attribute code for Chef 11 [0].  The typical solution is to coerce the
attribute into a well-known type using #to_s, #to_hash, or similar
methods which are easier to use elsewhere.

Cheers,

Steven


--
Steven Danna
Systems Engineer, Opscode, Inc
GPG Key: http://stevendanna.github.com/downloads/code/public.key

[0]
http://www.opscode.com/blog/2013/02/05/chef-11-in-depth-attributes-changes/





Archive powered by MHonArc 2.6.16.

§