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

Fixed solo clean command and made log level configurable #522

Closed hoffi closed 6 years ago

hoffi commented 6 years ago

The solo clean command did not work for me. It always generated this command: sudo -p \'knife sudo password: \' -p \'knife sudo password: \' rm -rf

This is because KnifeSolo::SshCommand is calling #process_sudo which is replacing "sudo" with the sudo_command. But in this case sudo_command was already present in the command. So i removed this from the Clean-Command and just used "sudo" like in the Cook-Command.

Also the log level for my Cook runs defaulted to debug and generated a lot of output. I added an option to change it and defaulted it to the Chef-Log-Level.

I also made enable_reporting configurable through the solo.rb file.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.02%) to 89.166% when pulling 4a7b83dc16d4b998d7e6a39fe3cfe3e4bcd8705e on Nix-wie-weg:correct-log-level into 98a4d7f08cbd6b053a6c580faab1babc1c390958 on matschaffer:master.

matschaffer commented 6 years ago

@hoffi thanks! Looks like this is causing a test failure as well.

  1) Failure:
SoloCleanTest#test_removes_with_custom_sudo [/home/travis/build/matschaffer/knife-solo/lib/chef/knife/solo_clean.rb:25]:
unexpected invocation: #<Chef::Knife::SoloClean:0x2306860>.run_command("sudo rm -rf ~/chef-solo")
unsatisfied expectations:
- expected exactly once, not yet invoked: #<Chef::Knife::SoloClean:0x2306860>.run_command("/usr/some/sudo rm -rf ~/chef-solo")
satisfied expectations:
- allowed any number of times, not yet invoked: #<Chef::Knife::UI:0x23055a0>.warn(any_parameters)
- allowed any number of times, invoked once: #<Chef::Knife::UI:0x23055a0>.msg(any_parameters)

Likely just a bad expectation but let's get it fixed up before merging.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+1.004%) to 90.153% when pulling 50de524be13da7199529b7334ee5265f27e55ae5 on Nix-wie-weg:correct-log-level into 98a4d7f08cbd6b053a6c580faab1babc1c390958 on matschaffer:master.

hoffi commented 6 years ago

I fixed it and moved the tests for custom sudo commands to SshCommandTest

matschaffer commented 6 years ago

Fantastic. Thanks!

hoffi commented 6 years ago

Do you plan a new release or pre-release of the gem including this fix anytime soon?

matschaffer commented 6 years ago

Could certainly do a pre this evening for you.

I’ve been avoiding a proper release since the integration tests are red but fixing them is so time (and money) consuming.

On Thu, Nov 9, 2017 at 17:14 Stefan Hoffmann notifications@github.com wrote:

Do you plan a new release or pre-release of the gem including this fix anytime soon?

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/matschaffer/knife-solo/pull/522#issuecomment-343078766, or mute the thread https://github.com/notifications/unsubscribe-auth/AAACshHR-Cx842O2TXDRMo5FyZJPxCGEks5s0rRRgaJpZM4QWImz .

--

-Mat

matschaffer.com

hoffi commented 6 years ago

A pre-release would be perfect. 👍

matschaffer commented 6 years ago

Cool. Just pushed 0.7.0.pre2 - unit tests pass but I don't have anything convenient to cross check so let me know if you run into any trouble with it.