Kitchen test how to use local vm.box
Asked Answered
L

4

5

Every time I run

kitchen test

it downloads a new vm box. Is there a way to make it re-use a locally downloaded box?

Here is my .kitchen.yml file.

---
driver_plugin: vagrant
driver_config:
  require_chef_omnibus: true

platforms:
  - name: ubuntu-12.04

suites:
  - name: default
    run_list:
      - recipe[my-rails-server::default]
    attributes:

Terminal output:

Downloading Chef  for ubuntu...       
downloading https://www.opscode.com/chef/metadata?v=&prerelease=false&p=ubuntu&pv=12.04&m=x86_64       
to file /tmp/install.sh.1121/metadata.txt       
trying wget...       
url https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef_11.10.0-1.ubuntu.12.04_amd64.deb       
md5 21524287ed5631eb1c092ba7b589e968       
sha256  7a0a898b3682462620de80230c7a73730dde7131ca069e1d926f6faf07e4fa2f       
downloaded metadata file looks valid...       
downloading https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef_11.10.0-1.ubuntu.12.04_amd64.deb       
to file /tmp/install.sh.1121/chef_11.10.0-1.ubuntu.12.04_amd64.deb       
trying wget...       
Checksum compare with sha256sum succeeded.       
Installing Chef        
Leid answered 11/2, 2014 at 9:11 Comment(1)
platforms: - name: ubuntu-12.04 driver: box: ubuntu-12.04 box_url: file:///home/user/doenloads/ubuntu-12.04.boxCyclothymia
R
2

If by "downloads a new VM box", you mean destroys and creates one, yes, that's what kitchen test does. If you want to persist the instance, just run

kitchen converge

If you mean that Vagrant is downloading a new box from the Internet, then that's likely a bug in Vagrant.

Roter answered 11/2, 2014 at 17:34 Comment(2)
Yes, Vagrant downloads a new box every time I run kitchen test.Leid
That's downloading Chef, not the Ubuntu boxRoter
S
11

Test Kitchen creates its own Vagrantfile, based on .kitchen.yml config.

Therefore you have to specify your box (which should be already available for Vagrant, check vagrant box list) in .kitchen.yml. In your example it would be:

platforms:
- name: ubuntu-12.04
  driver:
    box: centos-6.5-x86_64-minimal

And kitchen will use box available for Vagrant, without downloading it.

You can also specify other Vagrant options, e.g.

- name: centos-vagrant
  driver:
    provider: parallels
    box: centos-6.5-x86_64-minimal
    customize:
      memsize: 1024
      cpus: 2

You can see more examples eg. in my Vagrant cookbooks lemp-server or or Opscode's yum.

Starlet answered 25/2, 2014 at 23:2 Comment(2)
Thanks marcin-r it was the driver/box line that I was missingSeabolt
The OP updated the original question, but that's what I was looking for. Thanks!Edmead
R
2

If by "downloads a new VM box", you mean destroys and creates one, yes, that's what kitchen test does. If you want to persist the instance, just run

kitchen converge

If you mean that Vagrant is downloading a new box from the Internet, then that's likely a bug in Vagrant.

Roter answered 11/2, 2014 at 17:34 Comment(2)
Yes, Vagrant downloads a new box every time I run kitchen test.Leid
That's downloading Chef, not the Ubuntu boxRoter
B
0

Use the following command

exec kitchen converge ubuntu

converge will regex of instances

Barnett answered 7/10, 2014 at 12:23 Comment(0)
E
0

Use the following definition in your kitchen.yml to disable box updates

platforms:
  - name: centos-7
    driver:
      box: bento/centos-7
      box_check_update: false

where the box is a locally available vagrant box in your host. Run the following command to get a list of available boxes:

$ vagrant box list
bento/centos-6.7           (virtualbox, 2.2.7)
bento/centos-7             (virtualbox, 201808.24.0)
Evelineevelinn answered 13/11, 2018 at 23:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.