From: Denis Uraganov
I have few small questions about test kitchen
- How can I create synced_folder in test kitchen as "config.vm.synced_folder 'shared/', '/vagrant/'" in vagrant?
- How can I use vagrant plugins in test kitchen (For example, hostmanager https://github.com/smdahlen/vagrant-hostmanager)?
- At this moment test kitchen does not support Ubuntu 14.04 as sandbox environments. Could you point me to the way how to create/integrate custom sandbox platform?
I'm looking forward to your response
Best Regards
Denis Uraganov
Re 1: How can I create synced_folder in test kitchen as "config.vm.synced_folder 'shared/', '/vagrant/'" in vagrant?
Test Kitchen supports a synced_folders block as a pass-through to vagrant with the same parameters as config.vm.synced_folder. The first parameter is a path to a directory on the host machine (can be relative). The second parameter is an absolute path specifying a mount point within the guest. You can also add all the modifiers Vagrant supports for specifying NFS, RSync & SMB shares as an optional third parameter. The parameters need to be passed as an array in the .kitchen.yml. If you want to specify more than one share, just use the YAML list construct.
For example:
driver: synced_folders: |
One thing that isn't documented very well about using relative paths in the .kitchen.yml is that it is relative to where the actual Vagrantfile lives, not where the .kitchen.yml file resides, which is what you might expect. Behind the scenes, Test Kitchen is creating Vagrantfiles in .kitchen/kitchen-vagrant/{instance_name}. So if you want to specify a relative path to say, shared/, relative to where the .kitchen.yml lives in the cookbook root, you need to specify the relative path like so: ../../shared
Here's a more complete example of a full .kitchen.yml using this example:
--- driver: provisioner: platforms: suites: |
Assuming that the cookbook structure resembles the following:
. ├── .bundle |
Re 2: How can I use vagrant plugins in test kitchen (For example, hostmanager https://github.com/smdahlen/vagrant-hostmanager)?
Test Kitchen uses Vagrant behind the scenes, so as long as you have the proper vagrant plugins installed, they will still work when Test Kitchen drives the VM lifecycle, executing whatever hooks a plugin monitors for vagrant processes. The trick is to make sure that the Vagrantfile gets written out properly to .kitchen/kitchen-vagrant/{instance_name}/Vagrantfile if the plugin relies on special extensions to the Vagrantfile format.
You can override the Vagrantfile that is generated by using the vagrantfile_erb directive in the .kitchen.yml It's documented here: https://github.com/test-kitchen/kitchen-vagrant#-vagrantfile_erb
And if needed, you can add a special pre_create_command to run things before "vagrant up" to prep things if that's needed: https://github.com/test-kitchen/kitchen-vagrant#-pre_create_command
That being said a many vagrant plugins duplicate functionality that is either already in Test Kitchen or Chef. For example you can set the hostname with the vm_hostname setting in the .kitchen.yml. Internally at Chef Software, we're fond of using the hostfile LWRP to manage /etc/hosts: http://community.opscode.com/cookbooks/hostsfile (a.k.a. using Chef to manage our Vagrant boxes for anything above the OS level). And now with chef-metal, it makes things even easier to create clusters of machines managed by Chef. There's also an evolving Test Kitchen driver being written to integrate chef-metal into Test Kitchen: https://github.com/doubt72/kitchen-metal but it is not yet usable - waiting on a few changes to Test Kitchen to get merged in first.
Just something to consider, that since Test Kitchen was built from the ground up to integrate well with Chef, you can use Chef more in the instance/machine creating process, where you used to need to rely more on vagrant-plugins.
--- driver: provisioner: platforms: |
suites: |
--- driver: name: vagrant provisioner: name: chef_solo platforms: - name: ubuntu1404 driver: |
provider: vmware_fusion box: ubuntu1404 customize: memory: 1024 suites: - name: default |
--- driver: name: vagrant provisioner: name: chef_solo platforms: |
- name: ubuntu-14.04 suites: - name: default |
--- driver: name: docker binary: docker.io provisioner: name: chef_solo platforms: - name: ubuntu-14.04 driver: image: ubuntu:14.04 platform: ubuntu |
suites: - name: default run_list: attributes: |
--- driver: name: docker provisioner: name: chef_solo platforms: - name: ubuntu-14.04 driver: image: ubuntu:14.04 platform: ubuntu |
suites: - name: default run_list: attributes: |
Question :
1) Why testkitchen is not using my ip address defined in kitchen.yml and going with 127.0.0.1 and port 2222 which are part of the existing BOX. how to pass new network parameter for sandbox created by test kitchen??