This is a followup article to Using Test Kitchen With Puppet. This time we want to run our tests against an Openstack deployment. You can follow my article Howto Create A Minimal Viable OpenStack Deployment With Devstack In Your Local LAN to install and use one.

Add OpenStack To Test Kitchen

We have to add a new driver to our configuration. There already exists one so lets use kitchen-openstack:

echo 'gem "kitchen-openstack"' >> Gemfile

Install the new dependency

bundle install
Using CFPropertyList (2.2.7)
Using builder (3.2.2)
Using excon (0.33.0)
Using facter (2.0.1)
Using formatador (0.2.4)
Using mime-types (2.2)
Using net-ssh (2.9.0)
Using net-scp (1.2.1)
Using fog-core (1.22.0)
Using multi_json (1.10.0)
Using fog-json (1.0.0)
Using fog-brightbox (0.0.2)
Using mini_portile (0.5.3)
Using nokogiri (1.6.1)
Using fog (1.22.0)
Using json_pure (1.8.1)
Using hiera (1.3.2)
Using highline (1.6.21)
Using json (1.8.1)
Using mixlib-shellout (1.4.0)
Using safe_yaml (1.0.3)
Using thor (0.19.1)
Using test-kitchen (1.2.1)
Using unf_ext (0.0.6)
Using unf (0.1.4)
Using kitchen-openstack (1.4.0)
Using kitchen-puppet (0.0.8)
Using kitchen-vagrant (0.15.0)
Using librarian (0.1.2)
Using librarian-puppet (1.0.1)
Using rgen (0.6.6)
Using puppet (3.5.1)
Using bundler (1.5.3)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

To use it we have to add a configuration to it. From the README:

driver:
  name: openstack
  openstack_username: [YOUR OPENSTACK USERNAME]
  openstack_api_key: [YOUR OPENSTACK API KEY]
  openstack_auth_url: [YOUR OPENSTACK AUTH URL]
  require_chef_omnibus: latest (if you'll be using Chef)
  image_ref: [SERVER IMAGE ID]
  flavor_ref: [SERVER FLAVOR ID]

We can overlay our kitchen.yml with a local configuration to make use of our OpenStack cluster without having this private information in the repo itself.

 cat > .kitchen.local.yml <<CONFIG
---

driver:
  name: openstack
  openstack_username: "demo"
  openstack_api_key: "password"
  openstack_auth_url: "http://192.168.1.222:5000/v2.0/tokens"
  openstack_tenant: "demo"
  disable_ssl_validation: true
  key_name: "ci"
  private_key_path: "/Users/ehaselwanter/.ssh/ci.key"
  public_key_path: "/Users/ehaselwanter/.ssh/ci.key.pub"
  floating_ip_pool: public
  security_groups:
  - default
  - ssh
  network_ref:
  - private

platforms:
- name: ubuntu-12.04
  driver:
    image_ref: Ubuntu 12.04 LTS
    flavor_ref: m1.small
    username: ubuntu
CONFIG

Prepare OpenStack Cluster

To really be able to use this configuration we have to prepare our OpenStack cluster (or update the config according to an existing cluster). Let’s have look at the settings.

  openstack_username: "demo"
  openstack_api_key: "password"
  openstack_auth_url: "http://192.168.1.222:5000/v2.0/tokens"
  openstack_tenant: "demo"

This is very obvious. We need an user, password and endpoint. My OpenStack cluster runs in the local LAN and is accessible at 192.168.1.222. You can follow my quick-start guide on how to use OpenStack for some of the following commands. You do not need to set this up for kitchen, but it helps debugging. Install the command line tools and setup the same credentials as for kitchen:

cat > devstack-demo <<CONFIG
export OS_IDENTITY_API_VERSION=2.0
export OS_PASSWORD=password
export OS_AUTH_URL=http://192.168.1.222:5000/v2.0
export OS_USERNAME=demo
export OS_TENANT_NAME=demo
CONFIG
source devstack-demo

And verify that it is working

nova list
+----+------+--------+------------+-------------+----------+
| ID | Name | Status | Task State | Power State | Networks |
+----+------+--------+------------+-------------+----------+
+----+------+--------+------------+-------------+----------+

We need a ssh key in our tenant. So either add one or create one.

  key_name: "ci"
  private_key_path: "/Users/ehaselwanter/.ssh/ci.key"
  public_key_path: "/Users/ehaselwanter/.ssh/ci.key.pub"

with the key present

nova keypair-list
+------+-------------------------------------------------+
| Name | Fingerprint                                     |
+------+-------------------------------------------------+
| ci   | 85:46:8f:8e:d4:a9:d7:eb:de:a5:dd:70:ed:ae:7a:9f |
+------+-------------------------------------------------+

Test Kitchen must be able to connect to the instance it creates. So we need to have a public network and floating IPs setup and reachable from wherever you want to run the kitchen command.

So let us check if we are able to create floating IPs and from what pool they come from:

nova floating-ip-create
+---------------+-----------+----------+--------+
| Ip            | Server Id | Fixed Ip | Pool   |
+---------------+-----------+----------+--------+
| 192.168.1.131 |           | -        | public |
+---------------+-----------+----------+--------+

We see the pool is named public.

  floating_ip_pool: public

Next up the ssh connection. We need to ensure that we are able to connect with ssh. So we have to add appropriate security groups.

nova secgroup-create ssh ssh
nova secgroup-add-rule ssh tcp 22 22 0.0.0.0/0

And tell test-kitchen to use it:

  security_groups:
  - default
  - ssh

Booting instances in OpenStack requires us to set a network to attach to. Let’s do that. What networks have we got:

nova network-list
+--------------------------------------+---------+------+
| ID                                   | Label   | Cidr |
+--------------------------------------+---------+------+
| 68a61467-5b25-4799-be4a-4b7c368282e5 | public  | -    |
| aeda7456-2452-4ba3-8803-987fdea86867 | private | -    |
+--------------------------------------+---------+------+

So private it is:

  network_ref:
  - private  

Then we need a image in glance to run our tests on. The relevant section is the platforms section. If you did not do so, add Ubuntu

wget https://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img
glance add is_public=true container_format=bare disk_format=qcow2 distro="Ubuntu" name="Ubuntu 12.04 LTS" < ubuntu-12.04-server-cloudimg-amd64-disk1.img

and see if we have got one:

glance image-list
+--------------------------------------+---------------------------------+-------------+------------------+-----------+--------+
| ID                                   | Name                            | Disk Format | Container Format | Size      | Status |
+--------------------------------------+---------------------------------+-------------+------------------+-----------+--------+
| 4048550e-c61c-4de9-814c-b3d1d26b60d7 | Ubuntu 12.04 LTS                | qcow2       | bare             | 255328768 | active |
+--------------------------------------+---------------------------------+-------------+------------------+-----------+--------+

This is the official Ubuntu image. The user ubuntu gets the key injected and we can use it for our testing. The only thing missing is an appropriate flavor. You have to use one which fits your images requirements.

nova flavor-list
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
| 42 | m1.nano   | 64        | 0    | 0         |      | 1     | 1.0         | True      |
| 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
| 84 | m1.micro  | 128       | 0    | 0         |      | 1     | 1.0         | True      |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

We need a flavor big enough for our tests and image. m1.small looks good enough. Disk can hold our OS and RAM is plenty for installing ntp. So finally this section looks like:

platforms:
- name: ubuntu-12.04
  driver:
    image_ref: Ubuntu 12.04 LTS
    flavor_ref: m1.small
    username: ubuntu

Now everything should be in place to focus on test-kitchen again. A final sanity check would be to start an instance, assign it a floating ip, connect to it, and finally check if you have internet in the vm. So lets do that:

nova boot --flavor 2 --image 4048550e-c61c-4de9-814c-b3d1d26b60d7 --key_name ci --nic net-id=aeda7456-2452-4ba3-8803-987fdea86867 kitchen-test
+--------------------------------------+---------------------------------------------------------+
| Property                             | Value                                                   |
+--------------------------------------+---------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                  |
| OS-EXT-AZ:availability_zone          | nova                                                    |
| OS-EXT-STS:power_state               | 0                                                       |
| OS-EXT-STS:task_state                | scheduling                                              |
| OS-EXT-STS:vm_state                  | building                                                |
| OS-SRV-USG:launched_at               | -                                                       |
| OS-SRV-USG:terminated_at             | -                                                       |
| accessIPv4                           |                                                         |
| accessIPv6                           |                                                         |
| adminPass                            | oHmjY68uCybX                                            |
| config_drive                         |                                                         |
| created                              | 2014-05-12T12:25:36Z                                    |
| flavor                               | m1.small (2)                                            |
| hostId                               |                                                         |
| id                                   | d93e8782-8f95-4f57-9813-2ff7e5c92755                    |
| image                                | Ubuntu 12.04 LTS (4048550e-c61c-4de9-814c-b3d1d26b60d7) |
| key_name                             | ci                                                      |
| metadata                             | {}                                                      |
| name                                 | kitchen-test                                            |
| os-extended-volumes:volumes_attached | []                                                      |
| progress                             | 0                                                       |
| security_groups                      | default                                                 |
| status                               | BUILD                                                   |
| tenant_id                            | 8eba7f20d1f342ea921fdbca0650b6f8                        |
| updated                              | 2014-05-12T12:25:36Z                                    |
| user_id                              | 4ad8fc6b05234872a83b06de2430cb2b                        |
+--------------------------------------+---------------------------------------------------------+

Attach a floating ip to the instance:

nova list
+--------------------------------------+--------------+--------+------------+-------------+--------------------+
| ID                                   | Name         | Status | Task State | Power State | Networks           |
+--------------------------------------+--------------+--------+------------+-------------+--------------------+
| d93e8782-8f95-4f57-9813-2ff7e5c92755 | kitchen-test | ACTIVE | -          | Running     | private=172.24.4.3 |
+--------------------------------------+--------------+--------+------------+-------------+--------------------+
neutron port-list
+--------------------------------------+------+-------------------+-----------------------------------------------------------------------------------+
| id                                   | name | mac_address       | fixed_ips                                                                         |
+--------------------------------------+------+-------------------+-----------------------------------------------------------------------------------+
| 2ddd42b2-1507-4f71-a01e-ca9f153848a0 |      | fa:16:3e:48:a0:fc | {"subnet_id": "4066948a-f022-4954-9148-4d9f63f96eee", "ip_address": "172.24.4.3"} |
| c5bb6fe1-280f-4986-91b5-900dab473a41 |      | fa:16:3e:e1:9b:a4 | {"subnet_id": "4066948a-f022-4954-9148-4d9f63f96eee", "ip_address": "172.24.4.1"} |
| d9414f4d-30ce-4597-813c-f46f136a0fbc |      | fa:16:3e:72:e3:68 | {"subnet_id": "4066948a-f022-4954-9148-4d9f63f96eee", "ip_address": "172.24.4.2"} |
+--------------------------------------+------+-------------------+-----------------------------------------------------------------------------------+
neutron floatingip-list
+--------------------------------------+------------------+---------------------+---------+
| id                                   | fixed_ip_address | floating_ip_address | port_id |
+--------------------------------------+------------------+---------------------+---------+
| 1b19cc96-354e-4628-8304-762fa68042c1 |                  | 192.168.1.130       |         |
| e4cee676-0fbf-4d53-826c-1b595c6d4b87 |                  | 192.168.1.131       |         |
| e9682325-b2d8-419c-bb1c-6e3fb4fcfdbf |                  | 192.168.1.129       |         |
+--------------------------------------+------------------+---------------------+---------+

This information can be used to associate the floating IP

neutron floatingip-associate e4cee676-0fbf-4d53-826c-1b595c6d4b87 2ddd42b2-1507-4f71-a01e-ca9f153848a0
Associated floatingip e4cee676-0fbf-4d53-826c-1b595c6d4b87

And we can test to connect

ssh -i ~/.ssh/ci.key ubuntu@192.168.1.131
The authenticity of host '192.168.1.131 (192.168.1.131)' can't be established.
RSA key fingerprint is c1:a3:f9:8a:c4:0c:17:b3:4b:b2:3a:10:5d:a5:66:34.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.131' (RSA) to the list of known hosts.
Welcome to Ubuntu 12.04.4 LTS (GNU/Linux 3.2.0-59-virtual x86_64)

and see if we got internet

ubuntu@kitchen-test:~$ curl -I http://getchef.com
HTTP/1.1 301 Moved Permanently
Server: ngx_openresty
Date: Mon, 12 May 2014 12:35:03 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Location: http://www.getchef.com/
P3P: CP="CAO PSA OUR"

With this we confirmed that we have an OpenStack cluster ready to be consumed by test-kitchen:

kitchen list
Instance             Driver     Provisioner  Last Action
default-ubuntu-1204  Openstack  PuppetApply  <Not Created>

So step by step. First create the instance:

± kitchen create
-----> Starting Kitchen (v1.2.1)
-----> Creating <default-ubuntu-1204>...
       OpenStack instance <f7b3177e-7056-4d44-9583-6bbaf8abb82e> created.
.....
(server ready)
       Attaching floating IP from <public> pool
       Attaching floating IP <192.168.1.130>
       Waiting for 192.168.1.130:22...
[ ... snipped waiting lines ...]
       Waiting for 192.168.1.130:22...
       (ssh ready)
       Using OpenStack keypair <ci>
       Using public SSH key </Users/ehaselwanter/.ssh/ci.key.pub>
       Using private SSH key </Users/ehaselwanter/.ssh/ci.key>
       Finished creating <default-ubuntu-1204> (2m10.92s).
-----> Kitchen is finished. (2m12.38s)

This is working. Let us verify our manifest:

kitchen verify
-----> Starting Kitchen (v1.2.1)
-----> Converging <default-ubuntu-1204>...
       Preparing files for transfer
       Preparing modules
       Resolving module dependencies with Librarian-Puppet 1.0.1...
       Preparing manifests
       Preparing hiera data
       Finished Preparing files for transfer
       Installing puppet, will try to determine platform os
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
       --2014-05-12 12:41:40--  http://apt.puppetlabs.com/puppetlabs-release-precise.deb
Resolving apt.puppetlabs.com (apt.puppetlabs.com)... 198.58.114.168, 2600:3c00::f03c:91ff:fe69:6bf0
Connecting to apt.puppetlabs.com (apt.puppetlabs.com)|198.58.114.168|:80...        connected.
HTTP request sent, awaiting response...        200 OK
Length: 3430 (3.3K)        [application/x-debian-package]
       Saving to: `puppetlabs-release-precise.deb'

100%[======================================>] 3,430       --.-K/s   in 0s

       2014-05-12 12:41:41 (18.8 MB/s) - `puppetlabs-release-precise.deb' saved [3430/3430]

sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
       Selecting previously unselected package puppetlabs-release.
(Reading database ...        47501 files and directories currently installed.)
       Unpacking puppetlabs-release (from puppetlabs-release-precise.deb) ...
       Setting up puppetlabs-release (1.0-7) ...
       Processing triggers for initramfs-tools ...
       update-initramfs: Generating /boot/initrd.img-3.2.0-59-virtual
[ ... snipped ... ]
Get:34 http://nova.clouds.archive.ubuntu.com precise-updates/universe Translation-en [140 kB]
       Fetched 10.8 MB in 16s (636 kB/s)
        package lists... Done
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
        package lists... Done
       g dependency tree
        state information... Done
       The following extra packages will be installed:
         augeas-lenses debconf-utils facter hiera libaugeas-ruby libaugeas-ruby1.8
         libaugeas0 libjson-ruby libreadline5 libruby libruby1.8 libshadow-ruby1.8
         puppet-common ruby ruby-json ruby-rgen ruby1.8 virt-what
       Suggested packages:
         augeas-doc augeas-tools puppet-el vim-puppet ruby-selinux libselinux-ruby1.8
         librrd-ruby1.9.1 librrd-ruby1.8 ri ruby-dev ruby1.8-examples ri1.8
       Recommended packages:
         rdoc
       The following NEW packages will be installed:
         augeas-lenses debconf-utils facter hiera libaugeas-ruby libaugeas-ruby1.8
         libaugeas0 libjson-ruby libreadline5 libruby libruby1.8 libshadow-ruby1.8
         puppet puppet-common ruby ruby-json ruby-rgen ruby1.8 virt-what
       0 upgraded, 19 newly installed, 0 to remove and 32 not upgraded.
       Need to get 3,900 kB of archives.
       After this operation, 15.0 MB of additional disk space will be used.
Get:1 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise/main libreadline5 amd64 5.2-11 [128 kB]
Get:2 http://apt.puppetlabs.com/ precise/main facter amd64 2.0.1-1puppetlabs1 [73.8 kB]
Get:3 http://apt.puppetlabs.com/ precise/main hiera all 1.3.2-1puppetlabs1 [12.6 kB]
Get:4 http://apt.puppetlabs.com/ precise/dependencies ruby-rgen all 0.6.5-1puppetlabs1 [82.2 kB]
Get:5 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise/main augeas-lenses all 0.10.0-0ubuntu4 [175 kB]
Get:6 http://apt.puppetlabs.com/ precise/main puppet-common all 3.5.1-1puppetlabs1 [1,242 kB]
Get:7 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise/main debconf-utils all 1.5.42ubuntu1 [54.9 kB]
Get:8 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise-updates/main libruby1.8 amd64 1.8.7.352-2ubuntu1.4 [1,797 kB]
Get:9 http://apt.puppetlabs.com/ precise/main puppet all 3.5.1-1puppetlabs1 [9,616 B]
Get:10 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise-updates/main ruby1.8 amd64 1.8.7.352-2ubuntu1.4 [33.8 kB]
Get:11 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise/main ruby all 4.8 [5,054 B]
Get:12 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise/universe virt-what amd64 1.11-1 [12.9 kB]
Get:13 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise/main libaugeas0 amd64 0.10.0-0ubuntu4 [171 kB]
Get:14 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise/main libaugeas-ruby1.8 amd64 0.3.0-1.1ubuntu4 [9,642 B]
Get:15 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise/universe libaugeas-ruby all 0.3.0-1.1ubuntu4 [3,354 B]
Get:16 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise/universe ruby-json amd64 1.6.3-1 [73.3 kB]
Get:17 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise/universe libjson-ruby all 1.6.3-1 [1,588 B]
Get:18 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise/main libruby all 4.8 [4,766 B]
Get:19 http://nova.clouds.archive.ubuntu.com/ubuntu/ precise/main libshadow-ruby1.8 amd64 1.4.1-8build1 [9,416 B]
       Fetched 3,900 kB in 8s (485 kB/s)
       Selecting previously unselected package libreadline5.
(Reading database ...        47507 files and directories currently installed.)
       Unpacking libreadline5 (from .../libreadline5_5.2-11_amd64.deb) ...
       Selecting previously unselected package augeas-lenses.
       Unpacking augeas-lenses (from .../augeas-lenses_0.10.0-0ubuntu4_all.deb) ...
       Selecting previously unselected package debconf-utils.
       Unpacking debconf-utils (from .../debconf-utils_1.5.42ubuntu1_all.deb) ...
       Selecting previously unselected package libruby1.8.
       Unpacking libruby1.8 (from .../libruby1.8_1.8.7.352-2ubuntu1.4_amd64.deb) ...
       Selecting previously unselected package ruby1.8.
       Unpacking ruby1.8 (from .../ruby1.8_1.8.7.352-2ubuntu1.4_amd64.deb) ...
       Selecting previously unselected package ruby.
       Unpacking ruby (from .../apt/archives/ruby_4.8_all.deb) ...
       Selecting previously unselected package virt-what.
       Unpacking virt-what (from .../virt-what_1.11-1_amd64.deb) ...
       Selecting previously unselected package facter.
       Unpacking facter (from .../facter_2.0.1-1puppetlabs1_amd64.deb) ...
       Selecting previously unselected package libaugeas0.
       Unpacking libaugeas0 (from .../libaugeas0_0.10.0-0ubuntu4_amd64.deb) ...
       Selecting previously unselected package libaugeas-ruby1.8.
       Unpacking libaugeas-ruby1.8 (from .../libaugeas-ruby1.8_0.3.0-1.1ubuntu4_amd64.deb) ...
       Selecting previously unselected package libaugeas-ruby.
       Unpacking libaugeas-ruby (from .../libaugeas-ruby_0.3.0-1.1ubuntu4_all.deb) ...
       Selecting previously unselected package ruby-json.
       Unpacking ruby-json (from .../ruby-json_1.6.3-1_amd64.deb) ...
       Selecting previously unselected package libjson-ruby.
       Unpacking libjson-ruby (from .../libjson-ruby_1.6.3-1_all.deb) ...
       Selecting previously unselected package libruby.
       Unpacking libruby (from .../archives/libruby_4.8_all.deb) ...
       Selecting previously unselected package libshadow-ruby1.8.
       Unpacking libshadow-ruby1.8 (from .../libshadow-ruby1.8_1.4.1-8build1_amd64.deb) ...
       Selecting previously unselected package hiera.
       Unpacking hiera (from .../hiera_1.3.2-1puppetlabs1_all.deb) ...
       Selecting previously unselected package ruby-rgen.
       Unpacking ruby-rgen (from .../ruby-rgen_0.6.5-1puppetlabs1_all.deb) ...
       Selecting previously unselected package puppet-common.
       Unpacking puppet-common (from .../puppet-common_3.5.1-1puppetlabs1_all.deb) ...
       Selecting previously unselected package puppet.
       Unpacking puppet (from .../puppet_3.5.1-1puppetlabs1_all.deb) ...
       Processing triggers for man-db ...
       Processing triggers for ureadahead ...
       Setting up libreadline5 (5.2-11) ...
       Setting up augeas-lenses (0.10.0-0ubuntu4) ...
       Setting up debconf-utils (1.5.42ubuntu1) ...
       Setting up libruby1.8 (1.8.7.352-2ubuntu1.4) ...
       Setting up ruby1.8 (1.8.7.352-2ubuntu1.4) ...
update-alternatives: using /usr/bin/ruby1.8 to provide /usr/bin/ruby (ruby) in auto mode.
       Setting up ruby (4.8) ...
       Setting up virt-what (1.11-1) ...
       Setting up facter (2.0.1-1puppetlabs1) ...
       Setting up libaugeas0 (0.10.0-0ubuntu4) ...
       Setting up libaugeas-ruby1.8 (0.3.0-1.1ubuntu4) ...
       Setting up libaugeas-ruby (0.3.0-1.1ubuntu4) ...
       Setting up ruby-json (1.6.3-1) ...
       Setting up libjson-ruby (1.6.3-1) ...
       Setting up libruby (4.8) ...
       Setting up libshadow-ruby1.8 (1.4.1-8build1) ...
       Setting up hiera (1.3.2-1puppetlabs1) ...
       Setting up ruby-rgen (0.6.5-1puppetlabs1) ...
       Setting up puppet-common (3.5.1-1puppetlabs1) ...
       Setting up puppet (3.5.1-1puppetlabs1) ...
 * Starting puppet agent
       puppet not configured to start, please edit /etc/default/puppet to enable
                                                                                [ OK ]
       Processing triggers for libc-bin ...
       ldconfig deferred processing now taking place
-----> Installing Chef Omnibus to install busser to run tests
  % Total    % Received % Xferd  Average Speed          Time    Time     Time  Current

             Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0
100 15934  100 15934    0     0  14445      0  0:00:01  0:00:01 --:--:-       - 19769
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
       Downloading Chef  for ubuntu...
       downloading https://www.getchef.com/chef/metadata?v=&prerelease=false&nightlies=false&p=ubuntu&pv=12.04&m=x86_64
         to file /tmp/install.sh.4090/metadata.txt
       trying wget...
       url  https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef_11.12.4-1_amd64.deb
       md5  c45e1d4f7842af1048f788c4452d6cc0
       sha256 595cd1e884efd21f8f5e34bdbe878421a9d5c1c24abd3c669a84e8ed261317a3
       downloaded metadata file looks valid...
       downloading https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef_11.12.4-1_amd64.deb
         to file /tmp/install.sh.4090/chef_11.12.4-1_amd64.deb
       trying wget...
       Comparing checksum with sha256sum...
       Installing Chef
       installing with dpkg...
       Selecting previously unselected package chef.
(Reading database ...        50163 files and directories currently installed.)
       Unpacking chef (from .../chef_11.12.4-1_amd64.deb) ...
       Setting up chef (11.12.4-1) ...
       Thank you for installing Chef!
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
       Transfering files to <default-ubuntu-1204>
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora

installed :-) now converge …

sudo:        unable to resolve host default-ubuntu-1204-ehaselwanter-cora
Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
Notice: Compiled catalog for default-ubuntu-1204-ehaselwanter-cora.openstacklocal in environment production in 1.90 seconds
Notice: /Stage[main]/Ntp::Install/Package[ntp]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Ntp::Config/File[/etc/ntp.conf]/content: content changed '{md5}32280703a4ba7aa1148c48895097ed07' to '{md5}29301de88a4464768ee3a4969989a448'
Notice: /Stage[main]/Ntp::Service/Service[ntp]: Triggered 'refresh' from 1 events
Notice: Finished catalog run in 49.96 seconds
       Finished converging <default-ubuntu-1204> (6m12.75s).

and testing setup …

-----> Setting up <default-ubuntu-1204>...
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
Fetching: thor-0.19.0.gem (100%)
Fetching: busser-0.6.2.gem (100%)
Successfully installed thor-0.19.0
Successfully installed busser-0.6.2
2 gems installed
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
-----> Setting up Busser
       Creating BUSSER_ROOT in /tmp/busser
       Creating busser binstub
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
       Plugin bats installed (version 0.2.0)
-----> Running postinstall for bats plugin
       Installed Bats to /tmp/busser/vendor/bats/bin/bats
       Plugin serverspec installed (version 0.2.6)
-----> Running postinstall for serverspec plugin
       Finished setting up <default-ubuntu-1204> (2m2.83s).
-----> Verifying <default-ubuntu-1204>...
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
       Suite path directory /tmp/busser/suites does not exist, skipping.
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
       Uploading /tmp/busser/suites/bats/verify_installed.bats (mode=0644)
sudo:        unable to resolve host default-ubuntu-1204-ehaselwanter-cora
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
       Uploading /tmp/busser/suites/serverspec/ntp_spec.rb (mode=0644)
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora
sudo: unable to resolve host default-ubuntu-1204-ehaselwanter-cora

and testing …

-----> Running bats test suite
 ✓ ntp is up and running
 ✓ ntp.conf contains correct servers

2 tests, 0 failures
-----> Running serverspec test suite
/opt/chef/embedded/bin/ruby -I/tmp/busser/suites/serverspec -S /opt/chef/embedded/bin/rspec /tmp/busser/suites/serverspec/ntp_spec.rb --color --format documentation

Package "ntp"
  should be installed

Service "ntp"
  should be enabled
  should be running

       Finished in 2.88 seconds
3 examples, 0 failures
       Finished verifying <default-ubuntu-1204> (0m28.04s).
-----> Kitchen is finished. (8m45.06s)

Common Errors

  • wrong flavor for image. especially the disk size must be able to hold the os of choice
  • wrong cloud user or cloud init not working.
  • ssh keys not accessible from kitchen
  • public IP not reachable by kitchen
  • cached value in .kitchen for provider (config change during same run e.g. ssh key path)
cat .kitchen/default-ubuntu-1204.yml
---
  server_id: f7b3177e-7056-4d44-9583-6bbaf8abb82e
  hostname: "192.168.1.130"
  ssh_key: /Users/ehaselwanter/.ssh/ci.key
  last_action: verify%

Interested in Cloud or Chef Trainings? Have a look at our Commandemy Trainings page. Need help migrating to the cloud? Check out Infralovers.

comments powered by Disqus
Blog Tags