melezhik / cookbooks

perl chef cookbooks
https://github.com/melezhik/cookbooks
21 stars 27 forks source link

/tmp/local-lib/ is deleted and created during every chef run. #20

Open sschueller opened 10 years ago

sschueller commented 10 years ago

Recipe:

include_recipe "cpan::default"

cpan_client 'URI' do
    action 'install'
    version '0'
    install_type 'cpan_module'
    user 'root'
    group 'root'
end

Chef Log:

Recipe: cpan::default
  * directory[/tmp/local-lib/] action delete
    - delete existing directory /tmp/local-lib/

  * directory[/tmp/local-lib/] action create
    - create new directory /tmp/local-lib/
    - change mode from '' to '0777'

  * directory[/tmp/local-lib/install] action create
    - create new directory /tmp/local-lib/install
    - change mode from '' to '0777'

Recipe: iweb_powa::packages
  * cpan_client[URI] action install[2014-03-12T16:46:14+01:00] WARN: Cloning resource attributes for directory[/tmp/local-lib/] from prior resource (CHEF-3694)
[2014-03-12T16:46:14+01:00] WARN: Previous directory[/tmp/local-lib/]: /var/chef/cache/cookbooks/cpan/recipes/default.rb:6:in `from_file'
[2014-03-12T16:46:14+01:00] WARN: Current  directory[/tmp/local-lib/]: /var/chef/cache/cookbooks/cpan/providers/client.rb:220:in `block in class_from_file'
[2014-03-12T16:46:14+01:00] WARN: Cloning resource attributes for directory[/tmp/local-lib/install] from prior resource (CHEF-3694)
[2014-03-12T16:46:14+01:00] WARN: Previous directory[/tmp/local-lib/install]: /var/chef/cache/cookbooks/cpan/recipes/default.rb:11:in `from_file'
[2014-03-12T16:46:14+01:00] WARN: Current  directory[/tmp/local-lib/install]: /var/chef/cache/cookbooks/cpan/providers/client.rb:225:in `block in class_from_file'

Is there a way to only have the dirs deleted and recreated if the cpan module is not installed?

melezhik commented 10 years ago

Sorry for delayed answer. The cpan::default is recipe, but cpan_client is LWRP, initial intention to have a recipe is to do some initialization, like create / delete cache dirs, etc, but I think it's better to move this into LWRP cpan_module and to set initialization logic here. If I got you right you do not want to delete local-lib dir in some cases?

sschueller commented 9 years ago

Hi, sorry for the crazy delay (forgot about this).

The issue is that during each chef run the recipe calling cpan_client is marked as updated (although nothing changed). In our setup we have chef run automatically and all recipes are written in a way to not make any changes if not needed. We log only changes but in the moment cpan_client pollutes the logs.

For example the git LWRP does not mark the recipe as updated unless there was a change in the repository and it was pulled from the remote.