matschaffer / knife-solo

DEPRECATED: Please consider using https://knife-zero.github.io/, ansible, or visit https://www.chef.io/ for other ideas
MIT License
786 stars 213 forks source link

Add a --clean-up-command option #518

Closed iashwash closed 7 years ago

iashwash commented 7 years ago

Use Case

If you run chef in local_mode, we end up finding our local chef-solo directory has its local cache populated with files owned by root. So the knife solo clean fails silently on permission denied removing those files. This allows you to override the rm -rf with your own command, in our case sudo rm -rf

Some examples from running knife solo clean with -VV

rm: cannot remove ‘/home/ubuntu/chef-solo/local-mode-cache/cache/cookbooks/rsyslog/resources’: Permission denied
rm: cannot remove ‘/home/ubuntu/chef-solo/local-mode-cache/cache/cookbooks/ohai/recipes/default.rb’: Permission denied
rm: cannot remove ‘/home/ubuntu/chef-solo/local-mode-cache/cache/cookbooks/ohai/libraries/matchers.rb’: Permission denied
rm: cannot remove ‘/home/ubuntu/chef-solo/local-mode-cache/cache/cookbooks/ohai/attributes’: Permission denied
rm: cannot remove ‘/home/ubuntu/chef-solo/local-mode-cache/cache/cookbooks/ohai/providers’: Permission denied
coveralls commented 7 years ago

Coverage Status

Coverage decreased (-37.04%) to 52.07% when pulling 7f0805dc92263a62be7678ba1f1563057c492801 on iashwash:customize_clean_command into a9fdf73346eca21056b33cb85dd0c9cfd779503f on matschaffer:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-37.04%) to 52.07% when pulling 7f0805dc92263a62be7678ba1f1563057c492801 on iashwash:customize_clean_command into a9fdf73346eca21056b33cb85dd0c9cfd779503f on matschaffer:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.005%) to 89.119% when pulling db4f5f8366b6f4f654aa0924ba6a7a0372d5e17f on iashwash:customize_clean_command into a9fdf73346eca21056b33cb85dd0c9cfd779503f on matschaffer:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.005%) to 89.119% when pulling 17fce4997098c113855c04d30248af3ea1e95bde on iashwash:customize_clean_command into a9fdf73346eca21056b33cb85dd0c9cfd779503f on matschaffer:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.005%) to 89.119% when pulling 17fce4997098c113855c04d30248af3ea1e95bde on iashwash:customize_clean_command into a9fdf73346eca21056b33cb85dd0c9cfd779503f on matschaffer:master.

matschaffer commented 7 years ago

What do you specify as a cleanup command? If it's just sudo rm -rf I wonder if it'd make sense to add sudo to the clean command as default.

Seems like anyone else running local mode (or using cookbooks which create any files in the solo tree) would run into this problem as well.

iashwash commented 7 years ago

Yup, exactly - I was specifying sudo rm -rf

I think making sudo the default makes sense to me - I was just trying to make it as non-intrusive as possible. I'll submit a PR with that, and leave it up to you to close the one you don't like.

iashwash commented 7 years ago

Opened #519 - if you prefer a different direction on either PR, just let me know.

matschaffer commented 7 years ago

https://github.com/matschaffer/knife-solo/pull/519 looks perfect. Thanks!