Hi Chef users mail distribution list,
I am wrapping a bash resource in a compiled cookbook that recompiles from source and installs the compiled artifact regardless of whether or not the version it is compiling is already present on disk. I am trying to use the wrapper method to add a not_if guard that would prevent the behavior, a la:
begin
s = resources(bash: “compile_package_source”)
s.environment ({ ‘GOPATH’ => “#{node[‘package’][‘gopath’]}” })
s.cwd “#{node[‘package’][‘gopath’]}/src/github.com/package/package"
s.not_if “{ ::File.exists?(”#{node[‘package’][‘dir’]}/package_binary_name}”)"
rescue Chef::Exceptions::ResourceNotFound
puts "Bash Prometheus compile resource not found!"
end
The wrapped code block is of the form:
bash ‘compile_package_source’ do
cwd "#{Chef::Config[:file_cache_path]}/package-#{node[‘package’][‘version’]}"
code <<-EOH
make build &&
mv package_binary_name #{node[‘package’][‘dir’]} &&
cp -R a_dir #{node[‘package’][‘dir’]} &&
cp -R a_dir #{node[‘package’][‘dir’]}
EOH
notifies :restart, 'service[package_service_name]'
end
The compile is still executing on every run. Is this becuase the branching decision has already been made? The wrapped code block is present in the run_list prior to the wrapper that attempts to modify it’s behavior.
Thanks in advance for any assistance anyone can proffer me.
Joseph Hammerman