Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

sudo wrapper is failing when vagrant started from test-kitchen #281

Closed
AlexeyDemidov opened this issue May 5, 2014 · 7 comments
Closed

Comments

@AlexeyDemidov
Copy link

I'm trying to use LXC to run test-kitchen. When I use following .kitchen.yml

driver:
  name: vagrant

provisioner:
  name: chef_solo
platforms:
  - name: ubuntu-12.04
    driver:
      box: precise-lxc
      provider: lxc

kitchen-converge fails with following output

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #create action: [Expected process to exit with [0], but received '1'
---- Begin output of vagrant up --no-provision --provider=lxc ----
STDOUT: 
STDERR: The `lxc` package does not seem to be installed or is not accessible on the PATH.
---- End output of vagrant up --no-provision --provider=lxc ----
Ran vagrant up --no-provision --provider=lxc returned 1]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

I can successfully run 'sudo which lxc-create`, I have changed my user to 'NOPASSWD' in /etc/sudoers. If I run 'vagrant up' in .kitchen/kitchen-vagrant/default-ubuntu-1204 VM starts normally, I can 'vagrant ssh' into it and can see it running with 'lxc-ls' on host system.

I have tried to dive into code and commented out temporarily ensure_lxc_installed! call in lib/vagrant-lxc/provider.rb. 'kitchen converget' failed with following message:

-----> Starting Kitchen (v1.2.1)
-----> Creating <default-ubuntu-1204>...
       Bringing machine 'default' up with 'lxc' provider...
       ==> default: HandleBoxUrl middleware is deprecated. Use HandleBox instead.
==> default: This is a bug with the provider. Please contact the creator       ==> default: of the provider you use to fix this.
       ==> default: Importing base box 'precise-lxc'...
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #create action: [Expected process to exit with [0], but received '1'
---- Begin output of vagrant up --no-provision --provider=lxc ----
STDOUT: Bringing machine 'default' up with 'lxc' provider...
==> default: HandleBoxUrl middleware is deprecated. Use HandleBox instead.
==> default: This is a bug with the provider. Please contact the creator
==> default: of the provider you use to fix this.
==> default: Importing base box 'precise-lxc'...
STDERR: There was an error executing ["sudo", "rm", "/usr/share/lxc/templates/lxc-vagrant-tmp-default-ubuntu-1204_default_1399314523513_48531"]

For more information on the failure, enable detailed logging by setting
the environment variable VAGRANT_LOG to DEBUG.
---- End output of vagrant up --no-provision --provider=lxc ----
Ran vagrant up --no-provision --provider=lxc returned 1]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

Environment: Linux Mint 16, kernel 3.11.0-20, vagrant 1.5.4, vagrant-lxc 0.8, test-kitchen 1.2.1, lxc 1.0.0~alpha1-0ubuntu14.1, sudo 1.8.6p3-0ubuntu3.1

Output of kitchen diagnose --all https://gist.github.com/AlexeyDemidov/11544964

@fgrehm
Copy link
Owner

fgrehm commented May 8, 2014

@AlexeyDemidov I don't have access to a Mint machine down here, are you aware of a Vagrant VBox Mint box that I can use to try debugging this issue? If you don't, would you be able to try using test-kitchen from an Ubuntu machine to check if it works?

Thanks in advance.

@AlexeyDemidov
Copy link
Author

@fgrehm I have finally got time to debug this issue and resolved it. I have replaced call to sudo_wrapper.run("which", "lxc-create") with plain old puts sudo which lxc-create and got output that sudo requires tty. Commenting out line 'Defaults requiretty' in /etc/sudoers resolved this problem. I think it would be good to capture stderr from sudo_wrapper and show it to user in case of errors.

@jefmathiot
Copy link
Contributor

@AlexeyDemidov you can get the commands stdout and stderr by setting VAGRANT_LOG=DEBUG before calling vagrant up.

@AlexeyDemidov
Copy link
Author

@jefmathiot yeah, missed that somehow, even my own console output above contains suggestion to set VAGRANT_LOG=DEBUG for further information.

@jefmathiot
Copy link
Contributor

:)

@morrizon
Copy link

I found that sudo_wrapper tries to run the command adding the wrapper_path:

    class SudoWrapper
      #...
      def run(*command)
        options = command.last.is_a?(Hash) ? command.last : {}
        command.unshift @wrapper_path if @wrapper_path && !options[:no_wrapper]
        execute *(['sudo'] + command)
      end
     # run execute(["sudo", "/usr/local/bin/vagrant-lxc-wrapper-1.0.0.alpha.2", "which", "lxc-create"])

/usr/local/bin/vagrant-lxc-wrapper-1.0.0.alpha.2 doesn't exist and the command fail. Also the sudoers doesn't work for me. See #289.

# /etc/sudoers.d/vagrant-lxc-1-0-0-alpha-2
# Automatically created by vagrant-lxc
Cmnd_Alias LXC = /usr/local/bin/vagrant-lxc-wrapper-1.0.0.alpha.2
myuser ALL=(root) NOPASSWD: LXC

Test in Ubuntu 12.04.4, lxc 1.0.3-0ubuntu2, vagrant 1.6.2 and vagrant-lxc 1.0.0.alpha.2. The version vagrant-lxc 1.0.0.alpha.1 works fine.

@fgrehm
Copy link
Owner

fgrehm commented May 28, 2014

Ok, so it seems that the original issue @AlexeyDemidov reported was solved. I've added a link to this issue on our Troubleshooting wiki so that other users can find it easier on the future.

@morrizon would you mind opening up a new issue so that we can keep a better track of your problem if it is still an issue for you? I've been using alpha2 with the sudoers file without problems for a while now. Thanks in advance

@fgrehm fgrehm closed this as completed May 28, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants