[chef] Re: Re: Re: Dynamic Template File


Chronological Thread 
  • From: "Soula, William" < >
  • To: 'Bryan Baugher' < >
  • Subject: [chef] Re: Re: Re: Dynamic Template File
  • Date: Tue, 8 May 2012 07:22:05 -0500
  • Accept-language: en-US
  • Acceptlanguage: en-US

Title: Re: [chef] Re: Re: Dynamic Template File
base_install_path=node['mobi.GIS']['install']['install_path']
installer_install_path=File.join(base_install_path,"installer")
installer_config_properties_file = File.join(installer_install_path,"mobi.GIS-install-config.properties")
template installer_config_properties_file do
       source "mobi.GIS-config-ant-properties.erb"
       variables(
               :config => node['mobi.integration']['config']
       )
end

tsomerville.pointserve.com [Mon, 07 May 2012 11:11:15 -0500] INFO: template[c:/pointserve/mobi.GIS/installer/mobi.GIS-install-config.properties] backed up to c:/chef/backup/pointserve/mobi.GIS/installer/mobi.GIS-install-config.properties.chef-20120507111115
tsomerville.pointserve.com [Mon, 07 May 2012 11:11:15 -0500] ERROR: template[c:/pointserve/mobi.GIS/installer/mobi.GIS-install-config.properties] (mobi.GIS::default line /chef/cache/cookbooks/mobi.GIS/recipes/default.rb) has had an error
tsomerville.pointserve.com [Mon, 07 May 2012 11:11:15 -0500] ERROR: template[c:/pointserve/mobi.GIS/installer/mobi.GIS-install-config.properties] (c:/chef/cache/cookbooks/mobi.GIS/recipes/default.rb:12:in `from_file') had an error:
tsomerville.pointserve.com template[c:/pointserve/mobi.GIS/installer/mobi.GIS-install-config.properties] (mobi.GIS::default line /chef/cache/cookbooks/mobi.GIS/recipes/default.rb) had an error: Errno::EACCES: Permission denied - c:/pointserve/mobi.GIS/installer/mobi.GIS-install-config.properties
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1314:in `unlink'tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1314:in `block in remove_file'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1322:in `platform_support'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1313:in `remove_file'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:511:in `block in mv'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1423:in `block in fu_each_src_dest'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1439:in `fu_each_src_dest0'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1421:in `fu_each_src_dest'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:504:in `mv'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/provider/template.rb:47:in `block in action_create'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/mixin/template.rb:48:in `block in render_template'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/1.9.1/tempfile.rb:320:in `open'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/mixin/template.rb:45:in `render_template'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/provider/template.rb:99:in `render_with_context'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/provider/template.rb:39:in `action_create'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource.rb:440:in `run_action'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/runner.rb:45:in `run_action'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/runner.rb:81:in `block (2 levels) in converge'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/runner.rb:81:in `each'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/runner.rb:81:in `block in converge'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection.rb:94:in `block in execute_each_resource'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection.rb:92:in `execute_each_resource'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/runner.rb:76:in `converge'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/client.rb:312:in `converge'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/client.rb:160:in `run'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/application/client.rb:239:in `block in run_application'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/application/client.rb:229:in `loop'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/application/client.rb:229:in `run_application'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/application.rb:67:in `run'
tsomerville.pointserve.com C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-0.10.8/bin/chef-client:26:in `<top (required)>'
tsomerville.pointserve.com C:/opscode/chef/bin/chef-client:19:in `load'
tsomerville.pointserve.com C:/opscode/chef/bin/chef-client:19:in `<main>'
tsomerville.pointserve.com [Mon, 07 May 2012 11:11:15 -0500] ERROR: Running exception handlers
tsomerville.pointserve.com [Mon, 07 May 2012 11:11:15 -0500] FATAL: Saving node information to c:/chef/cache/failed-run-data.json
tsomerville.pointserve.com [Mon, 07 May 2012 11:11:15 -0500] ERROR: Exception handlers complete
tsomerville.pointserve.com [Mon, 07 May 2012 11:11:15 -0500] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out
tsomerville.pointserve.com [Mon, 07 May 2012 11:11:15 -0500] FATAL: Errno::EACCES: template[c:/pointserve/mobi.GIS/installer/mobi.GIS-install-config.properties] (mobi.GIS::default line /chef/cache/cookbooks/mobi.GIS/recipes/default.rb) had an error: Errno::EACCES: Permission denied - c:/pointserve/mobi.GIS/installer/mobi.GIS-install-config.properties
-------------------------------------------------------------
Could you show the code for the recipe or at least the template resource which is creating the file? Can you also give the stacktrace to the permission denied error? 

The permission denied error makes me think something is wrong with the chef installation or you are using chef incorrectly.

You should be able to do something like,

template "/path/to/my.properties" do
  variables(
:config => node[:myEnvironmentConfig]
  )
end

On Mon, May 7, 2012 at 3:50 PM, Soula, William <
"> > wrote:
I guess I can just not use templates and output a file with ruby that contains the values I want and that way I don't have to worry about chef funkiness.
-------------------------------------------------------------
My environment file has a config section with name, value pairs in it.  I am trying to output a template of those name, value pairs by putting the below code into my erb file in chef:
<% @config.each do |setting| -%>
<%= setting[0] %>=<%= setting[1] %>
<%end-%>

This works great the first time as it creates a property file with my name value pairs.

The problem is when the config section changes.  I get a Permission denied error, but if I rerun the recipe then everything works and the new value is in the property file.

How can I create dynamic property files from the environment json file?

Thanks,
Will 



-- 
-Bryan


Archive powered by MHonArc 2.6.16.

§