Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to test cookbooks with vagrant + virtualbox or lxc? #1916

Closed
ArturT opened this issue Oct 4, 2015 · 4 comments
Closed

Is it possible to test cookbooks with vagrant + virtualbox or lxc? #1916

ArturT opened this issue Oct 4, 2015 · 4 comments
Labels

Comments

@ArturT
Copy link

ArturT commented Oct 4, 2015

I would like to test my cookbooks on shippable so I installed on minion the vagrant:

#!/bin/bash

mkdir -p ~/tmp
cd ~/tmp

VERSION=1.7.4

if [ ! -f vagrant_${VERSION}_x86_64.deb ]; then
  wget https://dl.bintray.com/mitchellh/vagrant/vagrant_${VERSION}_x86_64.deb
fi

sudo dpkg -i vagrant_${VERSION}_x86_64.deb

# install required vagrant plugins
vagrant plugin install vagrant-berkshelf
vagrant plugin install vagrant-omnibus

# try lxc which requires those thing
sudo apt-get install uuid-runtime
sudo apt-get install cgroup-lite
sudo apt-get install redir
sudo apt-get install lxc
sudo apt-get install lxc-templates

vagrant plugin install vagrant-lxc

When I tried lxc then this bug occurs:

sudo apt-get install lxc-templates # cannot be installed because of below failure

Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 lxc-templates : Depends: lxc (>= 0.8.0~rc1-4ubuntu43) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I also tried virtualbox but without success. Is there any recommended way of testing cookbooks with vagrant on shippable minion?

  - sudo apt-get update
  - sudo apt-get install linux-headers-generic
  - sudo apt-get install linux-headers-`uname -r`
  - sudo apt-get install virtualbox
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  libnet-daemon-perl libdbi-perl libterm-readkey-perl libhtml-template-perl
  mysql-client-core-5.5 libdbd-mysql-perl libplrpc-perl mysql-client-5.5
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  dkms libgsoap1 libsdl1.2debian libvncserver0 python-central virtualbox-dkms
  virtualbox-qt
Suggested packages:
  libvncserver0-dbg virtualbox-guest-additions-iso vde2
The following NEW packages will be installed:
  dkms libgsoap1 libsdl1.2debian libvncserver0 python-central virtualbox
  virtualbox-dkms virtualbox-qt
0 upgraded, 8 newly installed, 0 to remove and 328 not upgraded.
Need to get 23.8 MB of archives.
After this operation, 71.3 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ precise-updates/main libsdl1.2debian amd64 1.2.14-6.4ubuntu3.1 [197 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ precise-updates/main dkms all 2.2.0.3-1ubuntu3.6 [73.3 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ precise/universe libgsoap1 amd64 2.8.4-2 [507 kB]
Get:4 http://archive.ubuntu.com/ubuntu/ precise-updates/main libvncserver0 amd64 0.9.8.2-2ubuntu1.1 [187 kB]
Get:5 http://archive.ubuntu.com/ubuntu/ precise-updates/universe python-central all 0.6.17ubuntu2 [41.4 kB]
Get:6 http://archive.ubuntu.com/ubuntu/ precise-updates/universe virtualbox amd64 4.1.12-dfsg-2ubuntu0.10 [15.6 MB]
Get:7 http://archive.ubuntu.com/ubuntu/ precise-updates/universe virtualbox-dkms all 4.1.12-dfsg-2ubuntu0.10 [674 kB]
Get:8 http://archive.ubuntu.com/ubuntu/ precise-updates/universe virtualbox-qt amd64 4.1.12-dfsg-2ubuntu0.10 [6,489 kB]
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin: 
Fetched 23.8 MB in 0s (26.3 MB/s)
Selecting previously unselected package libsdl1.2debian.
(Reading database ... 104258 files and directories currently installed.)
Unpacking libsdl1.2debian (from .../libsdl1.2debian_1.2.14-6.4ubuntu3.1_amd64.deb) ...
Selecting previously unselected package dkms.
Unpacking dkms (from .../dkms_2.2.0.3-1ubuntu3.6_all.deb) ...
Selecting previously unselected package libgsoap1.
Unpacking libgsoap1 (from .../libgsoap1_2.8.4-2_amd64.deb) ...
Selecting previously unselected package libvncserver0.
Unpacking libvncserver0 (from .../libvncserver0_0.9.8.2-2ubuntu1.1_amd64.deb) ...
Selecting previously unselected package python-central.
Unpacking python-central (from .../python-central_0.6.17ubuntu2_all.deb) ...
Selecting previously unselected package virtualbox.
Unpacking virtualbox (from .../virtualbox_4.1.12-dfsg-2ubuntu0.10_amd64.deb) ...
Selecting previously unselected package virtualbox-dkms.
Unpacking virtualbox-dkms (from .../virtualbox-dkms_4.1.12-dfsg-2ubuntu0.10_all.deb) ...
Selecting previously unselected package virtualbox-qt.
Unpacking virtualbox-qt (from .../virtualbox-qt_4.1.12-dfsg-2ubuntu0.10_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
Processing triggers for hicolor-icon-theme ...
Processing triggers for shared-mime-info ...
Setting up libsdl1.2debian (1.2.14-6.4ubuntu3.1) ...
Setting up dkms (2.2.0.3-1ubuntu3.6) ...
Setting up libgsoap1 (2.8.4-2) ...
Setting up libvncserver0 (0.9.8.2-2ubuntu1.1) ...
Setting up python-central (0.6.17ubuntu2) ...
Setting up virtualbox (4.1.12-dfsg-2ubuntu0.10) ...
invoke-rc.d: policy-rc.d denied execution of restart.
Processing triggers for python-central ...
Setting up virtualbox-dkms (4.1.12-dfsg-2ubuntu0.10) ...
Loading new virtualbox-4.1.12 DKMS files...
First Installation: checking all kernels...
dpkg: warning: version '*-*' has bad syntax: version number does not start with digit
It is likely that 3.13.0-57-generic belongs to a chroot's host
Building initial module for 3.13.0-57-generic
Done.

vboxdrv:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.13.0-57-generic/updates/dkms/

vboxnetadp.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.13.0-57-generic/updates/dkms/

vboxnetflt.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.13.0-57-generic/updates/dkms/

vboxpci.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.13.0-57-generic/updates/dkms/

depmod....

DKMS: install completed.
invoke-rc.d: policy-rc.d denied execution of restart.
Setting up virtualbox-qt (4.1.12-dfsg-2ubuntu0.10) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

  - sudo apt-get install virtualbox-ose-dkms
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  libnet-daemon-perl libdbi-perl libterm-readkey-perl libhtml-template-perl
  mysql-client-core-5.5 libdbd-mysql-perl libplrpc-perl mysql-client-5.5
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
  virtualbox-ose-dkms
0 upgraded, 1 newly installed, 0 to remove and 328 not upgraded.
Need to get 22.2 kB of archives.
After this operation, 122 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ precise-updates/universe virtualbox-ose-dkms all 4.1.12-dfsg-2ubuntu0.10 [22.2 kB]
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin: 
Fetched 22.2 kB in 0s (448 kB/s)
Selecting previously unselected package virtualbox-ose-dkms.
(Reading database ... 104904 files and directories currently installed.)
Unpacking virtualbox-ose-dkms (from .../virtualbox-ose-dkms_4.1.12-dfsg-2ubuntu0.10_all.deb) ...
Setting up virtualbox-ose-dkms (4.1.12-dfsg-2ubuntu0.10) ...

  - sudo dpkg-reconfigure virtualbox-dkms
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype

-------- Uninstall Beginning --------
Module:  virtualbox
Version: 4.1.12
Kernel:  3.13.0-57-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

vboxdrv.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.13.0-57-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vboxnetadp.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.13.0-57-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vboxnetflt.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.13.0-57-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vboxpci.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.13.0-57-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod....

DKMS: uninstall completed.

------------------------------
Deleting module version: 4.1.12
completely from the DKMS tree.
------------------------------
Done.
Loading new virtualbox-4.1.12 DKMS files...
dpkg: warning: version '*-*' has bad syntax: version number does not start with digit
It is likely that 3.13.0-57-generic belongs to a chroot's host
Building initial module for 3.13.0-57-generic
Done.

vboxdrv:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.13.0-57-generic/updates/dkms/

vboxnetadp.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.13.0-57-generic/updates/dkms/

vboxnetflt.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.13.0-57-generic/updates/dkms/

vboxpci.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.13.0-57-generic/updates/dkms/

depmod....

DKMS: install completed.
invoke-rc.d: policy-rc.d denied execution of restart.

  - sudo dpkg-reconfigure virtualbox
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
invoke-rc.d: policy-rc.d denied execution of restart.

  - VBoxManage --version
WARNING: The character device /dev/vboxdrv does not exist.
     Please install the virtualbox-ose-dkms package and the appropriate
     headers, most likely linux-headers-generic.

     You will not be able to start VMs until this problem is fixed.
4.1.12_Ubuntur77245

  vagrant up
parsing /home/shippable/workspace/src/bitbucket.org/knapsackpro/knapsack-pro-cookbooks/nodes/api-staging.knapsackpro.com.json
VirtualBox is complaining that the installation is incomplete. Please
run `VBoxManage --version` to see the error message which should contain
instructions on how to fix this error.
@avinci
Copy link
Member

avinci commented Oct 6, 2015

@ArturT Is there any particular reason you want to use Vagrant? A docker container is pretty much a replacement for Vagrant.

At this point, you can only use Docker containers to test out VM like deployments. In a few weeks we are announcing a few new plans where you could potentially do this. I am happy to help if you need some guidance on using Docker to test cookbooks.

@ArturT
Copy link
Author

ArturT commented Oct 6, 2015

@avdrav Oh, so using docker might be a good idea. I need to test cookbooks on fresh ubuntu 14.04. My repo contains only cookbooks. I'll try to play and figure out how to do it.

@avinci
Copy link
Member

avinci commented Oct 6, 2015

Our docker containers or minions are ubuntu 14.04. There is an image tag that you can add to your YML which should instruct what image you want your cook books tested against. It should be super straight forward and happy to help

@avinci avinci closed this as completed Oct 6, 2015
@ArturT
Copy link
Author

ArturT commented Oct 9, 2015

I end up with yml file like this

---
language: ruby
rvm:
  - 2.1.1
build_image: shippableimages/ubuntu1204_ruby
before_install:
  - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
  - source ~/.rvm/scripts/rvm
  - rvm install $SHIPPABLE_RUBY --verify-downloads 1
  - source ~/.bashrc && ~/.rvm/scripts/rvm && rvm use $SHIPPABLE_RUBY
install:
  - bundle install --gemfile="Gemfile"
before_script:
  - bundle exec berks install
  - bundle exec berks vendor cookbooks
  - apt-get update
  - mkdir -p /var/run/sshd
script:
  - bundle exec chef-solo -c solo.rb -j nodes/example.com.json

But know I have problem with firewall cookbook which requires root access.

================================================================================
Error executing action `enable` on resource 'firewall[ufw]'
================================================================================

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of ufw status ----
STDOUT: 
STDERR: ERROR: problem running iptables: iptables v1.4.12: can't initialize iptables table `filter': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
---- End output of ufw status ----
Ran ufw status returned 1

I found out moby/moby#4424 that docker needs to be started with -privileged but is it possible to set up this in yml file somehow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants