Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Can't run chef generate cookbook with an existing cookbook #12

Closed
rafaelmagu opened this issue Apr 15, 2014 · 3 comments
Closed

Can't run chef generate cookbook with an existing cookbook #12

rafaelmagu opened this issue Apr 15, 2014 · 3 comments

Comments

@rafaelmagu
Copy link

Not quite sure what I expected, to be honest. I was hoping it would behave more like berks cookbook when given an existing cookbook dir (where it just asks if it can override some files and adds missing ones).

Ran this from inside a folder with many cookbooks. Cookbook dir site-users already exists and has files in it:

[10:04:53] rfonseca@cookbooks{510}$ chef generate cookbook site-users
Compiling Cookbooks...
Recipe: code_generator::cookbook
  * directory[/Users/rfonseca/Documents/Code/cookbooks/site-users] action create (up to date)
  * template[/Users/rfonseca/Documents/Code/cookbooks/site-users/metadata.rb] action create
================================================================================
Error executing action `create` on resource 'template[/Users/rfonseca/Documents/Code/cookbooks/site-users/metadata.rb]'
================================================================================


Errno::EACCES
-------------
Permission denied @ dir_s_mkdir - /var/chef


Resource Declaration:
---------------------
# In /opt/chefdk/embedded/apps/chef-dk/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb

 10: template "#{cookbook_dir}/metadata.rb" do
 11:   helpers(ChefDK::Generator::TemplateHelper)
 12: end
 13: 



Compiled Resource:
------------------
# Declared in /opt/chefdk/embedded/apps/chef-dk/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb:10:in `from_file'

template("/Users/rfonseca/Documents/Code/cookbooks/site-users/metadata.rb") do
  provider Chef::Provider::Template
  action "create"
  retries 0
  retry_delay 2
  guard_interpreter :default
  path "/Users/rfonseca/Documents/Code/cookbooks/site-users/metadata.rb"
  backup 5
  atomic_update true
  source "metadata.rb.erb"
  helper_modules [ChefDK::Generator::TemplateHelper]
  cookbook_name :code_generator
  recipe_name "cookbook"
end



/opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:250:in `mkdir': template[/Users/rfonseca/Documents/Code/cookbooks/site-users/metadata.rb] (code_generator::cookbook line 10) had an error: Errno::EACCES: Permission denied @ dir_s_mkdir - /var/chef (Errno::EACCES)
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:250:in `fu_mkdir'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:224:in `block (2 levels) in mkdir_p'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:222:in `reverse_each'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:222:in `block in mkdir_p'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:208:in `each'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:208:in `mkdir_p'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/util/backup.rb:69:in `do_backup'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/util/backup.rb:32:in `backup!'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/provider/file.rb:332:in `do_backup'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/provider/file.rb:340:in `update_file_contents'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/provider/file.rb:372:in `block in do_contents_changes'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/mixin/why_run.rb:52:in `call'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/mixin/why_run.rb:52:in `add_action'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/provider.rb:155:in `converge_by'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/provider/file.rb:371:in `do_contents_changes'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/provider/file.rb:121:in `action_create'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/provider.rb:120:in `run_action'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/resource.rb:637:in `run_action'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/runner.rb:49:in `run_action'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/runner.rb:81:in `block (2 levels) in converge'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/runner.rb:81:in `each'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/runner.rb:81:in `block in converge'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/resource_collection.rb:98:in `block in execute_each_resource'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/resource_collection.rb:96:in `execute_each_resource'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-11.12.2/lib/chef/runner.rb:80:in `converge'
    from /opt/chefdk/embedded/apps/chef-dk/lib/chef-dk/chef_runner.rb:36:in `converge'
    from /opt/chefdk/embedded/apps/chef-dk/lib/chef-dk/command/generator_commands.rb:177:in `run'
    from /opt/chefdk/embedded/apps/chef-dk/lib/chef-dk/command/generate.rb:71:in `run'
    from /opt/chefdk/embedded/apps/chef-dk/lib/chef-dk/command/base.rb:57:in `run_with_default_options'
    from /opt/chefdk/embedded/apps/chef-dk/lib/chef-dk/cli.rb:83:in `run_subcommands'
    from /opt/chefdk/embedded/apps/chef-dk/lib/chef-dk/cli.rb:56:in `run'
    from /opt/chefdk/embedded/apps/chef-dk/bin/chef:25:in `<top (required)>'
    from /usr/bin/chef:31:in `load'
    from /usr/bin/chef:31:in `<main>'
@danielsdeleo
Copy link
Contributor

Actually, it's failing when attempting to create the backup for the files it's changing. So we need to configure that in the chef integration layer.

@danielsdeleo
Copy link
Contributor

@sersut
Copy link

sersut commented May 9, 2014

This will be fixed when https://tickets.opscode.com/browse/CHEF-5259 is fixed.

@sersut sersut closed this as completed May 9, 2014
@chef-boneyard chef-boneyard locked and limited conversation to collaborators Feb 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants