[chef] Re: Using not_if in bash block still causes file to be downloaded


Chronological Thread 
  • From: Matt Ray < >
  • To:
  • Subject: [chef] Re: Using not_if in bash block still causes file to be downloaded
  • Date: Fri, 3 Feb 2012 10:11:16 -0600

Perhaps using remote_file might be cleaner?

  remote_file "/tmp/hubot-#{version}.tar.gz" do
    source  
"https://github.com/downloads/github/hubot/hubot-#{version}.tar.gz";
    action :create_if_missing
  end

  execute "tar -xzf /tmp/hubot-#{version}.tar.gz" do
    cwd "/tmp"
    subscribes :run, resources(:remote_file =>
"/tmp/hubot-#{version}.tar.gz"), :immediately
    action :nothing
  end

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.

 | (512) 731-2218
Twitter, IRC, GitHub: mattray



On Fri, Feb 3, 2012 at 9:43 AM, Arthur Kalmenson 
< >
 wrote:
> Hello everyone,
>
> I'm writing a recipe to install hubot using the bash resource and using the
> not_if constraint to avoid reinstalling each time chef-client runs. While
> the reinstall does not happen, I'm finding that the hubot file continues to
> be downloaded with wget. Therefore, the /tmp dir is filling up with hubot
> tar files. Is there a reason why parts of the bash block execute and others
> don't?
>
> The recipe looks as follows:
>
> ...
>
> install_dir = "#{node['hubot']['install_dir']}"
> install_dir_parent = "#{node['hubot']['install_dir_parent']}"
> version = "#{node['hubot']['version']}"
>
> ...
>
> bash "install hubot" do
>   user hubot_user
>   group hubot_group
>   environment ({'HOME' => "#{install_dir}" })
>   cwd install_dir_parent
>   code <<-EOH
>     wget -P /tmp
> https://github.com/downloads/github/hubot/hubot-#{version}.tar.gz && \
>     tar xzf /tmp/hubot-#{version}.tar.gz && \
>     cd hubot && \
>     npm install
>   EOH
>   not_if "#{install_dir}/bin/hubot -v 2>&1 | grep '#{version}'"
> end
>
> The full recipe file is here: https://gist.github.com/1730793. Thank you in
> advance for any help.
>
> All the best,
> --
> Arthur Kalmenson



Archive powered by MHonArc 2.6.16.

§