GithubHelp home page GithubHelp logo

chef-provisioning-docker's Introduction

chef-provisioning-docker

Build Status Gem Version

How to use:

First you need to ensure that Docker is running. This can be done on a Linux host using Docker's installers or on OSX using boot2docker. Once you have that, you can install the dependencies with Bundler and then use the Docker like the following:

CHEF_DRIVER=docker bundle exec chef-client -z docker_ubuntu_image.rb

This will run Chef-zero and use the description stored in docker_ubuntu_image.rb (the second example below). Note that some configuration syntax is likely to change a little bit so be sure to check the documentation.

Machine creation

Using this , you can then define a machine similar to the following example:

require 'chef/provisioning/docker_driver'
with_driver 'docker'

machine 'wario' do
  recipe 'openssh::default'

  machine_options(
    docker_options: {
      base_image: {
        name: 'ubuntu',
        repository: 'ubuntu',
        tag: '14.04'
        },
        :command => '/usr/sbin/sshd -p 8022 -D',

        #ENV (Environment Variables)
        #Set any env var in the container by using one or more -e flags, even overriding those already defined by the developer with a Dockerfile ENV
        :env => {
           "deep" => 'purple',
           "led" => 'zeppelin'
        },

        # Ports can be one of two forms:
        # src_port (string or integer) is a pass-through, i.e 8022 or "9933"
        # src:dst (string) is a map from src to dst, i.e "8022:8023" maps 8022 externally to 8023 in the container

        # Example (multiple):
        :ports => [8022, "8023:9000", "9500"],

        # Examples (single):
        :ports => 1234,
        :ports => "2345:6789",

        # Volumes can be one of three forms:
        # src_volume (string) is volume to add to container, i.e. creates new volume inside container at "/tmp"
        # src:dst (string) mounts host's directory src to container's dst, i.e "/tmp:/tmp1" mounts host's directory /tmp to container's /tmp1
        # src:dst:mode (string) mounts host's directory src to container's dst with the specified mount option, i.e "/:/rootfs:ro" mounts read-only host's root (/) folder to container's /rootfs
        # See more details on Docker volumes at https://github.com/docker/docker/blob/master/docs/sources/userguide/dockervolumes.md .

        # Example (single):
        :volumes => "/tmp",

        # Example (multiple):
        :volumes => ["/tmp:/tmp", "/:/rootfs:ro"],

        # if you need to keep stdin open (i.e docker run -i)
        # :keep_stdin_open => true

      },
      # optional, default timeout is 600
      docker_connection: {
       :read_timeout => 1000,
      }
  )

end

Machine images

This supports the new machine image paradigm; with Docker you can build a base image, save that and use it to create a new container. Here is an example of this:

require 'chef/provisioning/docker_driver'

machine_image 'ssh_server' do
  recipe 'openssh'

  machine_options(
    :docker_options => {
      :base_image => {
          :name => 'ubuntu',
          :repository => 'ubuntu',
          :tag => '14.04'
      }
    }
  )
end

machine 'ssh00' do
  from_image 'ssh_server'

  machine_options(
    :docker_options => {
      :command => '/usr/sbin/sshd -D -o UsePAM=no -o UsePrivilegeSeparation=no -o PidFile=/tmp/sshd.pid',
      :ports => [22]
    }
  )
end

This will create a docker container based on Ubuntu 14.04 and then execute the openssh recipe and run the /usr/sbin/sshd command as the container's run command.

chef-provisioning-docker's People

Contributors

breezeight avatar dafyddcrosby avatar jgoulah avatar jkeiser avatar johnewart avatar marc- avatar matiasdecarli avatar mwrock avatar randomcamel avatar tas50 avatar tyler-ball avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chef-provisioning-docker's Issues

Weird :from_image value stored in machine_image.reference

Related to #27 (which was closed as part of #47) we have a very confusing attribute we store in the machine_spec.reference. We store :from_image as a boolean, but that is also accepted as an attribute in the machine and machine_image resources. This is confusing to users - they don't know whether to specify :from_image in the docker options or from_image as a resource attribute.

There are a couple scenarios we need to support:

  1. Creating docker images from a public repository, currently done through the :base_image docker options.
  2. Creating docker images from a local repository (via a Dockerfile, for example). This should work now through the :base_image docker options.
  3. Creating docker images from other machine_image resources.

Whatever we do, it needs to be backwards compatible unless we wait to make this change until we move to the next major patch version (undesirable to wait that long).

The only time :from_image is referenced is to determine whether we converge the machine or not. I'm currently not sure why this is necessary. Is it because we assume Chef isn't installed on an existing Docker container?

\cc @jkeiser @marc- @randomcamel

403 errors where provisioning to docker

I've been receiving very similar messages that have been experienced with provisioning to aws (chef-boneyard/chef-provisioning#469) trying to provision to docker.

[2015-11-04T09:32:12-05:00] DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
[2015-11-04T09:32:12-05:00] DEBUG: Signing the request as server1
[2015-11-04T09:32:12-05:00] DEBUG: String to sign: 'Method:GET
Hashed Path:3mWqCJcr2509dd2k11DLwRpSHl4=
X-Ops-Content-Hash:2jmj7l5rSw0yVb/vlWAYkK/YBwk=
X-Ops-Timestamp:2015-11-04T14:32:12Z
X-Ops-UserId:server1'
Header hash: {"X-Ops-Sign"=>"algorithm=sha1;version=1.0;", "X-Ops-Userid"=>"server1", "X-Ops-Timestamp"=>"2015-11-04T14:32:12Z", "X-Ops-Content-Hash"=>"2jmj7l5rSw0yVb/vlWAYkK/YBwk=", "X-Ops-Authorization-1"=>"SdmjkCyepkKHyMFIQTR1c4HV6PkNiYd1/23qpn7pm2hrHjkCXca3GMSMdxTM", "X-Ops-Authorization-2"=>"IHL9OipB3fHNA2T4zrY+ohAriBrwEf5bcyYnzSz84Y3ktGATA0aoTM2mfkg/", "X-Ops-Authorization-3"=>"qNQ1jfFI6O1ljBv3K3mE5pDuyST4fzgJDQg4aeuHqV5aepY+Bp+8M8u3ZvFD", "X-Ops-Authorization-4"=>"RWeQ4HU1rMt1dzRg1HrsNQPTraIpFG2EDdDhS0uIWvS4lXQCoJ38GQqYdSlC", "X-Ops-Authorization-5"=>"wRVS1RSpM2i7iD5eTvq3+zxS1n24xfJcq5jXZbNMCR5fjT0qZCsXK7+f0Nq5", "X-Ops-Authorization-6"=>"Ag78sfQAyCE0JZiK5WokfWa/W60o1rOU9eKXMdenpA=="}
[2015-11-04T09:32:12-05:00] DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
[2015-11-04T09:32:12-05:00] DEBUG: Initiating GET to https://server1/organizations/my_org/clients/app.myapp.local
[2015-11-04T09:32:12-05:00] DEBUG: ---- HTTP Request Header Data: ----
[2015-11-04T09:32:12-05:00] DEBUG: Accept: application/json
[2015-11-04T09:32:12-05:00] DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.0;
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-USERID: server1
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-TIMESTAMP: 2015-11-04T14:32:12Z
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-CONTENT-HASH: 2jmj7l5rSw0yVb/vlWAYkK/YBwk=
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-1: SdmjkCyepkKHyMFIQTR1c4HV6PkNiYd1/23qpn7pm2hrHjkCXca3GMSMdxTM
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-2: IHL9OipB3fHNA2T4zrY+ohAriBrwEf5bcyYnzSz84Y3ktGATA0aoTM2mfkg/
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-3: qNQ1jfFI6O1ljBv3K3mE5pDuyST4fzgJDQg4aeuHqV5aepY+Bp+8M8u3ZvFD
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-4: RWeQ4HU1rMt1dzRg1HrsNQPTraIpFG2EDdDhS0uIWvS4lXQCoJ38GQqYdSlC
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-5: wRVS1RSpM2i7iD5eTvq3+zxS1n24xfJcq5jXZbNMCR5fjT0qZCsXK7+f0Nq5
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-6: Ag78sfQAyCE0JZiK5WokfWa/W60o1rOU9eKXMdenpA==
[2015-11-04T09:32:12-05:00] DEBUG: HOST: server1:443
[2015-11-04T09:32:12-05:00] DEBUG: X-Ops-Server-API-Version: 0
[2015-11-04T09:32:12-05:00] DEBUG: X-REMOTE-REQUEST-ID: dd6e97f5-36b2-4aa5-a4c4-e40249375a90
[2015-11-04T09:32:12-05:00] DEBUG: ---- End HTTP Request Header Data ----
[2015-11-04T09:32:12-05:00] DEBUG: ---- HTTP Status and Header Data: ----
[2015-11-04T09:32:12-05:00] DEBUG: HTTP 1.1 404 Object Not Found
[2015-11-04T09:32:12-05:00] DEBUG: server: openresty/1.7.10.1
[2015-11-04T09:32:12-05:00] DEBUG: date: Wed, 04 Nov 2015 14:32:12 GMT
[2015-11-04T09:32:12-05:00] DEBUG: content-length: 48
[2015-11-04T09:32:12-05:00] DEBUG: connection: close
[2015-11-04T09:32:12-05:00] DEBUG: x-ops-server-api-version: {"min_version":"0","max_version":"1","request_version":"0","response_version":"0"}
[2015-11-04T09:32:12-05:00] DEBUG: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=12.2.0
[2015-11-04T09:32:12-05:00] DEBUG: ---- End HTTP Status/Header Data ----
[2015-11-04T09:32:12-05:00] DEBUG: ---- HTTP Response Body ----
[2015-11-04T09:32:12-05:00] DEBUG: {"error":["Cannot load client app.myapp.local"]}
[2015-11-04T09:32:12-05:00] DEBUG: ---- End HTTP Response Body -----
[2015-11-04T09:32:12-05:00] DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
[2015-11-04T09:32:12-05:00] DEBUG: Signing the request as server1
[2015-11-04T09:32:12-05:00] DEBUG: String to sign: 'Method:POST
Hashed Path:7rYlcOytWR8a1ZiIxpZPRmUy8xA=
X-Ops-Content-Hash:J5TyHmssKcpwEL8FQA32QZI0LeY=
X-Ops-Timestamp:2015-11-04T14:32:12Z
X-Ops-UserId:server1'
Header hash: {"X-Ops-Sign"=>"algorithm=sha1;version=1.0;", "X-Ops-Userid"=>"server1", "X-Ops-Timestamp"=>"2015-11-04T14:32:12Z", "X-Ops-Content-Hash"=>"J5TyHmssKcpwEL8FQA32QZI0LeY=", "X-Ops-Authorization-1"=>"jUEvxi1CSm52Hp1mr7QD3GNRNw+O7Z+2j9np1yi8fC2tqSVnf2sX8ZEJN/bp", "X-Ops-Authorization-2"=>"nHhcJreQrCTTo6Jmno8ru/6JkYjcw5LOjVOFHw1ppllULc/hNb+OrTmBTAhF", "X-Ops-Authorization-3"=>"EDljqAbXPdKM8kEH3JxFxop0vrfnB3vvR1j9UgnusTCjVEH8Wcd0rUsxLQQX", "X-Ops-Authorization-4"=>"ATczcl2AX5S8S5DrqQLZGQZE+DpJEUpmGRy1hQpPcVttc9JJzW0bZAHbSnr1", "X-Ops-Authorization-5"=>"fE6mMxpbK2UjMPBTI27bN8MvHvPfT7QZNdpF+jwOEM+IDWcAM0fbnZFOcIqp", "X-Ops-Authorization-6"=>"R69MJdoYMiLyLEQEAPk43p09znhRYOmQZTGgAHerHg=="}
[2015-11-04T09:32:12-05:00] DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
[2015-11-04T09:32:12-05:00] DEBUG: Initiating POST to https://server1/organizations/my_org/clients
[2015-11-04T09:32:12-05:00] DEBUG: ---- HTTP Request Header Data: ----
[2015-11-04T09:32:12-05:00] DEBUG: Content-Type: application/json
[2015-11-04T09:32:12-05:00] DEBUG: Accept: application/json
[2015-11-04T09:32:12-05:00] DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.0;
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-USERID: server1
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-TIMESTAMP: 2015-11-04T14:32:12Z
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-CONTENT-HASH: J5TyHmssKcpwEL8FQA32QZI0LeY=
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-1: jUEvxi1CSm52Hp1mr7QD3GNRNw+O7Z+2j9np1yi8fC2tqSVnf2sX8ZEJN/bp
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-2: nHhcJreQrCTTo6Jmno8ru/6JkYjcw5LOjVOFHw1ppllULc/hNb+OrTmBTAhF
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-3: EDljqAbXPdKM8kEH3JxFxop0vrfnB3vvR1j9UgnusTCjVEH8Wcd0rUsxLQQX
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-4: ATczcl2AX5S8S5DrqQLZGQZE+DpJEUpmGRy1hQpPcVttc9JJzW0bZAHbSnr1
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-5: fE6mMxpbK2UjMPBTI27bN8MvHvPfT7QZNdpF+jwOEM+IDWcAM0fbnZFOcIqp
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-6: R69MJdoYMiLyLEQEAPk43p09znhRYOmQZTGgAHerHg==
[2015-11-04T09:32:12-05:00] DEBUG: HOST: server1:443
[2015-11-04T09:32:12-05:00] DEBUG: X-Ops-Server-API-Version: 0
[2015-11-04T09:32:12-05:00] DEBUG: X-REMOTE-REQUEST-ID: dd6e97f5-36b2-4aa5-a4c4-e40249375a90
[2015-11-04T09:32:12-05:00] DEBUG: Content-Length: 586
[2015-11-04T09:32:12-05:00] DEBUG: ---- End HTTP Request Header Data ----
[2015-11-04T09:32:12-05:00] DEBUG: ---- HTTP Status and Header Data: ----
[2015-11-04T09:32:12-05:00] DEBUG: HTTP 1.1 403 Forbidden
[2015-11-04T09:32:12-05:00] DEBUG: server: openresty/1.7.10.1
[2015-11-04T09:32:12-05:00] DEBUG: date: Wed, 04 Nov 2015 14:32:12 GMT
[2015-11-04T09:32:12-05:00] DEBUG: content-length: 39
[2015-11-04T09:32:12-05:00] DEBUG: connection: close
[2015-11-04T09:32:12-05:00] DEBUG: x-ops-server-api-version: {"min_version":"0","max_version":"1","request_version":"0","response_version":"0"}
[2015-11-04T09:32:12-05:00] DEBUG: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=12.2.0
[2015-11-04T09:32:12-05:00] DEBUG: ---- End HTTP Status/Header Data ----
[2015-11-04T09:32:12-05:00] DEBUG: ---- HTTP Response Body ----
[2015-11-04T09:32:12-05:00] DEBUG: {"error":["missing create permission"]}
[2015-11-04T09:32:12-05:00] DEBUG: ---- End HTTP Response Body -----
[2015-11-04T09:32:12-05:00] DEBUG: ---- HTTP Request Body ----
[2015-11-04T09:32:12-05:00] DEBUG: {"name":"app.myapp.local","clientname":"app.myapp.local","admin":false,"validator":false,"chef_type":"client","public_key":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyMY98wd6iTOBiCxOYfNe\nO/Q+Q8t2e0Iv/GLiBunvRxirsIP2gsTUNbtYaOvUJP6A4nWpv2b7XJXczxVBw9nl\neQKB6qb4t9FIxZaElH7wzp5+74RQkl7jPvkh9qcWZBWcNCa5kRaPEif9unKqG6NM\nS4OhDFdxt6tXqMlVXhk8/PLFXY7/G7Y5JE+k9DqxgpiQFbBeeCjTcQJr6MHvt/Cl\nNh8T3hy2BqQCJyssBSvSIsJfhfc9XNEkcohq3LhBbGyojGWXA9LlUjphGIv010QY\nXP6gCpXD/sTCegbnGdeplUyi62gZZSLcgSNPr5UqTXZVGY0oW+0Fa1JnnV9BEbGx\n/wIDAQAB\n-----END PUBLIC KEY-----\n"}
[2015-11-04T09:32:12-05:00] DEBUG: ---- End HTTP Request Body ----
[2015-11-04T09:32:12-05:00] DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
[2015-11-04T09:32:12-05:00] DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
[2015-11-04T09:32:12-05:00] DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
[2015-11-04T09:32:12-05:00] DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
[2015-11-04T09:32:12-05:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_response
[2015-11-04T09:32:12-05:00] DEBUG: Expected JSON response, but got content-type ''
[2015-11-04T09:32:12-05:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
[2015-11-04T09:32:12-05:00] INFO: HTTP Request Returned 403 Forbidden: error
[2015-11-04T09:32:12-05:00] INFO: Running queued delayed notifications before re-raising exception
[2015-11-04T09:32:12-05:00] INFO: Running queued delayed notifications before re-raising exception
[2015-11-04T09:32:12-05:00] DEBUG: Re-raising exception: Net::HTTPServerException - machine[app.myapp.local] (tomcat_cluster::default line 12) had an error: Net::HTTPServerException: chef_client[app.myapp.local] (basic_chef_client::block line 145) had an error: Net::HTTPServerException: 403 "Forbidden"
/opt/chefdk/embedded/lib/ruby/2.1.0/net/http/response.rb:119:in `error!'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/http.rb:145:in `request'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/http.rb:126:in `post'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/cheffish-1.5.0/lib/cheffish/actor_provider_base.rb:30:in `block in create_actor'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/mixin/why_run.rb:52:in `call'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/mixin/why_run.rb:52:in `add_action'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider.rb:175:in `converge_by'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/cheffish-1.5.0/lib/cheffish/actor_provider_base.rb:29:in `create_actor'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/cheffish-1.5.0/lib/chef/provider/chef_client.rb:23:in `block in <class:ChefClient>'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider/lwrp_base.rb:86:in `instance_eval'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider/lwrp_base.rb:86:in `block in action'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider.rb:144:in `run_action'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource.rb:585:in `run_action'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:49:in `run_action'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `block (2 levels) in converge'
 /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `each'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `block in converge'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/resource_list.rb:83:in `block in execute_each_resource'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/resource_list.rb:81:in `execute_each_resource'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:80:in `converge'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/cheffish-1.5.0/lib/cheffish/basic_chef_client.rb:69:in `block in converge'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/cheffish-1.5.0/lib/cheffish/basic_chef_client.rb:133:in `call'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/cheffish-1.5.0/lib/cheffish/basic_chef_client.rb:133:in `with_chef_config'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/cheffish-1.5.0/lib/cheffish/basic_chef_client.rb:68:in `converge'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/cheffish-1.5.0/lib/cheffish/basic_chef_client.rb:109:in `converge_block'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-1.4.1/lib/chef/provisioning.rb:12:in `inline_resource'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-1.4.1/lib/chef/provisioning/convergence_strategy/precreate_chef_objects.rb:143:in `create_chef_objects'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-1.4.1/lib/chef/provisioning/convergence_strategy/precreate_chef_objects.rb:27:in `setup_convergence'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-1.4.1/lib/chef/provisioning/convergence_strategy/install_cached.rb:47:in `setup_convergence'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-1.4.1/lib/chef/provisioning/machine/basic_machine.rb:17:in `setup_convergence'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-1.4.1/lib/chef/provider/machine.rb:58:in `block in <class:Machine>'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider.rb:362:in `action_converge'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider.rb:144:in `run_action'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource.rb:585:in `run_action'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:49:in `run_action'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `block (2 levels) in converge'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `each'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `block in converge'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/resource_list.rb:83:in `block in execute_each_resource'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/resource_list.rb:81:in `execute_each_resource'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:80:in `converge'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/client.rb:653:in `block in converge'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/client.rb:648:in `catch'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/client.rb:648:in `converge'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/client.rb:687:in `converge_and_save'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/client.rb:269:in `run'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application.rb:270:in `block in fork_chef_client'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application.rb:258:in `fork'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application.rb:258:in `fork_chef_client'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application.rb:224:in `block in run_chef_client'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/local_mode.rb:44:in `with_server_connectivity'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application.rb:212:in `run_chef_client'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application/client.rb:408:in `block in interval_run_chef_client'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application/client.rb:398:in `loop'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application/client.rb:398:in `interval_run_chef_client'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application/client.rb:388:in `run_application'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application.rb:60:in `run'
  /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/bin/chef-client:26:in `<top (required)>'
  /bin/chef-client:54:in `load'
  /bin/chef-client:54:in `<main>'
[2015-11-04T09:32:12-05:00] ERROR: Running exception handlers
[2015-11-04T09:32:12-05:00] ERROR: Exception handlers complete
[2015-11-04T09:32:12-05:00] INFO: Sending resource update report (run-id: dd6e97f5-36b2-4aa5-a4c4-e40249375a90)
Header hash: {"X-Ops-Sign"=>"algorithm=sha1;version=1.0;", "X-Ops-Userid"=>"server1", "X-Ops-Timestamp"=>"2015-11-04T14:32:12Z", "X-Ops-Content-Hash"=>"5XSRGmqY8rm0jKWTWesRTgdwBFw=", "X-Ops-Authorization-1"=>"o0+77820zTvsFwvlGLycQdB+WBgOqAn9SaIYl2m2AptPic/HuGmSnqECtz4B", "X-Ops-Authorization-2"=>"VzhqBz13e7QbjgJw9KBGOi66zymqtE+3577xnVyyTpkWW/tbe19DS7SP43Rx", "X-Ops-Authorization-3"=>"PScjspFz/zlJUa4wE47y4Nmnety2H+psYnNn8PqwblF6HEDCF4OUPZ+uQCgK", "X-Ops-Authorization-4"=>"5hC7G6/uue/3yFno6fHg4/KoYKZsMvXYGhPG6of9JOziNeWIKVqqxhleQF57", "X-Ops-Authorization-5"=>"6s0NpcPrX3CEXR9j4GLbqQygqE1P+N4I0UIViRHVRmgwxD07hP57bcjT71RK", "X-Ops-Authorization-6"=>"fsTBC3zaoPzHPPgMeE5lx2+Mb60bOJam2xqyfa1rCA=="}
[2015-11-04T09:32:12-05:00] DEBUG: Initiating POST to https://server1/organizations/my_org/reports/nodes/server1/runs/dd6e97f5-36b2-4aa5-a4c4-e40249375a90
[2015-11-04T09:32:12-05:00] DEBUG: ---- HTTP Request Header Data: ----
[2015-11-04T09:32:12-05:00] DEBUG: X-Ops-Reporting-Protocol-Version: 0.1.0
[2015-11-04T09:32:12-05:00] DEBUG: Content-Encoding: gzip
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.0;
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-USERID: server1
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-TIMESTAMP: 2015-11-04T14:32:12Z
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-CONTENT-HASH: 5XSRGmqY8rm0jKWTWesRTgdwBFw=
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-1: o0+77820zTvsFwvlGLycQdB+WBgOqAn9SaIYl2m2AptPic/HuGmSnqECtz4B
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-2: VzhqBz13e7QbjgJw9KBGOi66zymqtE+3577xnVyyTpkWW/tbe19DS7SP43Rx
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-3: PScjspFz/zlJUa4wE47y4Nmnety2H+psYnNn8PqwblF6HEDCF4OUPZ+uQCgK
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-4: 5hC7G6/uue/3yFno6fHg4/KoYKZsMvXYGhPG6of9JOziNeWIKVqqxhleQF57
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-5: 6s0NpcPrX3CEXR9j4GLbqQygqE1P+N4I0UIViRHVRmgwxD07hP57bcjT71RK
[2015-11-04T09:32:12-05:00] DEBUG: X-OPS-AUTHORIZATION-6: fsTBC3zaoPzHPPgMeE5lx2+Mb60bOJam2xqyfa1rCA==
[2015-11-04T09:32:12-05:00] DEBUG: HOST: server1:443
[2015-11-04T09:32:12-05:00] DEBUG: X-Ops-Server-API-Version: 1
[2015-11-04T09:32:12-05:00] DEBUG: X-REMOTE-REQUEST-ID: dd6e97f5-36b2-4aa5-a4c4-e40249375a90
[2015-11-04T09:32:12-05:00] DEBUG: Content-Length: 2120
[2015-11-04T09:32:12-05:00] DEBUG: ---- End HTTP Request Header Data ----
[2015-11-04T09:32:12-05:00] DEBUG: ---- HTTP Status and Header Data: ----
[2015-11-04T09:32:12-05:00] DEBUG: HTTP 1.1 200 OK
[2015-11-04T09:32:12-05:00] DEBUG: server: openresty/1.7.10.1
[2015-11-04T09:32:12-05:00] DEBUG: date: Wed, 04 Nov 2015 14:32:12 GMT
[2015-11-04T09:32:12-05:00] DEBUG: content-type: application/json
[2015-11-04T09:32:12-05:00] DEBUG: content-length: 2
[2015-11-04T09:32:12-05:00] DEBUG: connection: close
[2015-11-04T09:32:12-05:00] DEBUG: ---- End HTTP Status/Header Data ----
[2015-11-04T09:32:12-05:00] DEBUG: Audit Reports are disabled. Skipping sending reports.
[2015-11-04T09:32:12-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-11-04T09:32:12-05:00] DEBUG: Net::HTTPServerException: machine[app.myapp.local] (tomcat_cluster::default line 12) had an error: Net::HTTPServerException: chef_client[app.myapp.local] (basic_chef_client::block line 145) had an error: Net::HTTPServerException: 403 "Forbidden"
/opt/chefdk/embedded/lib/ruby/2.1.0/net/http/response.rb:119:in `error!'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/http.rb:145:in `request'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/http.rb:126:in `post'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/cheffish-1.5.0/lib/cheffish/actor_provider_base.rb:30:in `block in create_actor'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/mixin/why_run.rb:52:in `call'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/mixin/why_run.rb:52:in `add_action'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider.rb:175:in `converge_by'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/cheffish-1.5.0/lib/cheffish/actor_provider_base.rb:29:in `create_actor'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/cheffish-1.5.0/lib/chef/provider/chef_client.rb:23:in `block in <class:ChefClient>'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider/lwrp_base.rb:86:in `instance_eval'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider/lwrp_base.rb:86:in `block in action'
[2015-11-04T09:32:12-05:00] ERROR: machine[app.myapp.local] (tomcat_cluster::default line 12) had an error: Net::HTTPServerException: chef_client[app.myapp.local] (basic_chef_client::block line 145) had an error: Net::HTTPServerException: 403 "Forbidden"
[2015-11-04T09:32:12-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

superclass mismatch for class DockerContainer

I'm attempting to use the follow recipe, named "role_docker":

chef_gem "chef-metal-docker"
require "chef_metal_docker"
include_recipe "docker"
machine 'testserver' do
   machine_options :docker_options => {
   ยฆ  :base_image => {
   ยฆ  ยฆ  :name => 'ubuntu',
   ยฆ  ยฆ  :repository => 'ubuntu',
   ยฆ  ยฆ  :tag => '14.04'
   ยฆ  }
   }
end

The result is the following:

root@sol:~# chef-client
[2014-08-25T00:31:06-07:00] WARN: 
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SSL validation of HTTPS requests is disabled. HTTPS connections are still
encrypted, but chef is not able to detect forged replies or man in the middle
attacks.

To fix this issue add an entry like this to your configuration file:

  # Verify all HTTPS connections (recommended)
  ssl_verify_mode :verify_peer

  # OR, Verify only connections to chef-server
  verify_api_cert true

To check your SSL configuration, or troubleshoot errors, you can use the
`knife ssl check` command like so:

  knife ssl check -c /etc/chef/client.rb

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Starting Chef Client, version 11.14.6
resolving cookbooks for run list: ["linuxguru::role_linuxguru", "linuxguru::role_docker"]
Synchronizing Cookbooks:
  - linuxguru
  - apache2
  - iptables
  - logrotate
  - pacman
  - apt
  - asterisk
  - build-essential
  - unimrcp
  - yum
  - bind
  - bind9
  - chef-client
  - cron
  - chef-server
  - docker
  - aufs
  - modules
  - device-mapper
  - git
  - dmg
  - windows
  - chef_handler
  - runit
  - yum-epel
  - golang
  - homebrew
  - lxc
  - dpkg_autostart
  - sysctl
  - ohai
  - elasticsearch
  - ark
  - 7-zip
  - gitolite
  - perl
  - hostname
  - hostsfile
  - iptables-ng
  - java
  - jenkins
  - kibana
  - mysql
  - yum-mysql-community
  - nfs
  - line
  - openvpn
  - rsyslog
  - selinux
  - ssh-keys
  - sudo
  - swap
  - td-agent
  - users
Compiling Cookbooks...
[2014-08-25T00:31:10-07:00] WARN: node['build_essential'] has been changed to node['build-essential'] to match the
cookbook name and community standards. I have gracefully converted the attribute
for you, but this warning and conversion will be removed in the next major
release of the build-essential cookbook.

[2014-08-25T00:31:10-07:00] WARN: node['build-essential']['compiletime'] has been deprecated. Please use
node['build-essential']['compile_time'] instead. I have gracefully converted the
attribute for you, but this warning and converstion will be removed in the next
major release of the build-essential cookbook.

Recipe: build-essential::_debian
  * package[autoconf] action install (up to date)
  * package[binutils-doc] action install (up to date)
  * package[bison] action install (up to date)
  * package[build-essential] action install (up to date)
  * package[flex] action install (up to date)
  * package[gettext] action install (up to date)
  * package[ncurses-dev] action install (up to date)
Recipe: linuxguru::rubyshadow
  * package[ruby-dev] action install (up to date)
  * chef_gem[ruby-shadow] action install (up to date)
Recipe: linuxguru::role_docker
  * chef_gem[chef-metal-docker] action install (up to date)

  ================================================================================
  Recipe Compile Error in /var/chef/cache/cookbooks/linuxguru/recipes/role_docker.rb
  ================================================================================

  TypeError
  ---------
  superclass mismatch for class DockerContainer

  Cookbook Trace:
  ---------------
    /var/chef/cache/cookbooks/linuxguru/recipes/role_docker.rb:3:in `from_file'

  Relevant File Content:
  ----------------------
  /var/chef/cache/cookbooks/linuxguru/recipes/role_docker.rb:

    1:  chef_gem "chef-metal-docker"
    2:  
    3>> require "chef_metal_docker"
    4:  
    5:  include_recipe "docker"
    6:  
    7:  machine 'testserver' do
    8:     machine_options :docker_options => {
    9:        :base_image => {
   10:           :name => 'ubuntu',
   11:           :repository => 'ubuntu',
   12:           :tag => '14.04'


  Running handlers:
[2014-08-25T00:31:12-07:00] ERROR: Running exception handlers
  Running handlers complete
[2014-08-25T00:31:12-07:00] ERROR: Exception handlers complete
[2014-08-25T00:31:12-07:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
  Chef Client failed. 0 resources updated in 6.571272146 seconds
[2014-08-25T00:31:12-07:00] ERROR: superclass mismatch for class DockerContainer
[2014-08-25T00:31:12-07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

In fresh container : /etc/chef/client.pem: no such file or directory

Hey all,

I'm using the unedited web_server example in the README.md of this repo.

The chef-client is ending with the following error :

[2015-04-09T11:33:50-04:00] ERROR: machine_image[web_server] (@recipe_files::/home/jpellet/dev/ci/chef-zero/example.rb line 3) had an error: Docker::Error::NotFoundError: Expected([200, 
201, 202, 203, 204, 304]) <=> Actual(404 Not Found)

The docker logs are showing that the container is properly created, the chef-client is trying to create the key in /etc/chef/client.pem but the file is apparently not properly created as you can see in the following docker logs:

INFO[5556] GET /v1.16/images/chef:web_server/json       
INFO[5556] +job image_inspect(chef:web_server)          
INFO[5556] -job image_inspect(chef:web_server) = OK (0) 
INFO[5556] POST /v1.16/containers/create                
INFO[5556] +job create()                                
INFO[5556] +job log(create, 9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f416dff1b, chef:mario) 
INFO[5556] -job log(create, 9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f416dff1b, chef:mario) = OK (0) 
INFO[5556] -job create() = OK (0)                       
INFO[5556] POST /v1.16/containers/9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f416dff1b/copy 
INFO[5556] +job container_copy(9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f416dff1b, etc/chef/client.pem) 
stat /var/lib/docker/aufs/mnt/9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f416dff1b/etc/chef/client.pem: no such file or directory
INFO[5556] -job container_copy(9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f416dff1b, etc/chef/client.pem) = ERR (1) 
ERRO[5556] stat /var/lib/docker/aufs/mnt/9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f416dff1b/etc/chef/client.pem: no such file or directory 
ERRO[5556] Handler for POST /containers/{name:.*}/copy returned error: Could not find the file /etc/chef/client.pem in container 9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f4
16dff1b 
ERRO[5556] HTTP Error: statusCode=500 Could not find the file /etc/chef/client.pem in container 9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f416dff1b 
INFO[5556] DELETE /v1.16/containers/9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f416dff1b 
INFO[5556] +job rm(9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f416dff1b) 
INFO[5556] +job log(destroy, 9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f416dff1b, chef:mario) 
INFO[5556] -job log(destroy, 9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f416dff1b, chef:mario) = OK (0) 
INFO[5556] -job rm(9804928d1b06ae1044f77af55a4abd4f2a7740e898e3995a1d54a73f416dff1b) = OK (0) 
INFO[5557] POST /v1.16/containers/web_server/stop?t=0?  
INFO[5557] +job stop(web_server)                        
Container already stopped

chef-client output :

jpellet@box:~/dev/ci/chef-zero$ CHEF_DRIVER=docker chef-client -z example.rb 
[2015-04-09T11:33:47-04:00] WARN: No config file found or specified on command line, using command line options.
[2015-04-09T11:33:47-04:00] WARN: No cookbooks directory found at or above current directory.  Assuming /home/jpellet/dev/ci/chef-zero.
Starting Chef Client, version 12.2.1
resolving cookbooks for run list: []
Synchronizing Cookbooks:
Compiling Cookbooks...
[2015-04-09T11:33:48-04:00] WARN: Node box has an empty run list.
Converging 2 resources
Recipe: @recipe_files::/home/jpellet/dev/ci/chef-zero/example.rb
  * machine_image[web_server] action create
    - update node web_server at http://localhost:8889
    -   update normal.chef_provisioning.reference.allocated_at from "2015-04-09 15:18:44 UTC" to "2015-04-09 15:33:48 UTC"
    -   remove normal.chef_provisioning.reference.container_id
    - update node web_server at http://localhost:8889
    -   add normal.chef_provisioning.reference.container_id = "a63ce0dfeed12b8cb9eb0caae0310b6812b76fec6e618dfed82ce67b6771bb6f"
    - generate private key (2048 bits)
    ================================================================================
    Error executing action `create` on resource 'machine_image[web_server]'
    ================================================================================

    Docker::Error::NotFoundError
    ----------------------------
    Expected([200, 201, 202, 203, 204, 304]) <=> Actual(404 Not Found)

    Resource Declaration:
    ---------------------
    # In /home/jpellet/dev/ci/chef-zero/example.rb

      3: machine_image 'web_server' do
      4:   recipe 'apache'
      5: 
      6:   machine_options :docker_options => {
      7:       :base_image => {
      8:           :name => 'ubuntu',
      9:           :repository => 'ubuntu',
     10:           :tag => '14.04'
     11:       }
     12:   }
     13: end
     14: 

    Compiled Resource:
    ------------------
    # Declared in /home/jpellet/dev/ci/chef-zero/example.rb:3:in `from_file'

    machine_image("web_server") do
      action :create
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      chef_server {:chef_server_url=>"http://localhost:8889", :options=>{:client_name=>"box", :signing_key_filename=>nil}}
      driver "docker"
      machine_options {:docker_options=>{:base_image=>{:name=>"ubuntu", :repository=>"ubuntu", :tag=>"14.04"}}}
      declared_type :machine_image
      cookbook_name "@recipe_files"
      recipe_name "/home/jpellet/dev/ci/chef-zero/example.rb"
      run_list_modifiers [#<Chef::RunList::RunListItem:0x007fc949cbbf00 @version=nil, @type=:recipe, @name="apache">]
    end


Running handlers:
[2015-04-09T11:33:49-04:00] ERROR: Running exception handlers
Running handlers complete
[2015-04-09T11:33:49-04:00] ERROR: Exception handlers complete
[2015-04-09T11:33:49-04:00] FATAL: Stacktrace dumped to /home/jpellet/.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 2.872126338 seconds
[2015-04-09T11:33:50-04:00] ERROR: machine_image[web_server] (@recipe_files::/home/jpellet/dev/ci/chef-zero/example.rb line 3) had an error: Docker::Error::NotFoundError: Expected([200, 201, 202, 203, 204, 304]) <=> Actual(404 Not Found)

[2015-04-09T11:33:50-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

A working example of a persistent container actually running a service?

So I've been trying to get something that could be used as a complete persistent service and seem to be missing some fundamental concepts. I can't seem to even get chef-metal-docker to create a container and run a command.

I set up chef-zero -H 0.0.0.0 server running on my ubuntu 14.04 workstation instance and uploaded a simple cookbook (https://github.com/rberger/chef-metal-min/cookbooks/min_app and also the apt cookbook)

I'm using this chef-zero server for both the workstation chef-client runs and the container chef-client runs so as to minimize ip address and routing issues.

If I create a provisioner_options in min_app/recipes/min.rb of:

with_provisioner_options 'base_image' => 'ubuntu:precise',  'create_container' => { 'command' =>  'ls -l /opt'}

and do a chef-client run on the workstation:

chef-client -o min_app::min -l info

The chef-client run fails but the container is created and if I start the container again it generates the output:

docker start -i -a 12ee3aafaa9a
total 0

Which shows that the container doesn't have chef installed.

If I then set the provisioner to:

with_provisioner_options 'base_image' => 'ubuntu:precise'

The chef-client run on my workstation will create the min_image docker image but it has the chef-client -l info as the command. (Not sure why it created those extra containers):

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                CREATED              STATUS              PORTS               NAMES
5f10d4a7230b        8859b13fbf47        chef-client -l info    About a minute ago   Exit 0                                  min
0796e0785921        4d4020697ca8        /bin/sh -c #(nop) AD   2 minutes ago        Exit 0                                  hopeful_engelbart
bab6f286bc43        061845e6cee3        /bin/sh -c #(nop) AD   2 minutes ago        Exit 0                                  hungry_darwin
35d4161453cf        2644d502c274        /bin/sh -c #(nop) AD   2 minutes ago        Exit 0                                  cocky_pike
dfb83a23e339        779457a7795b        /bin/sh -c #(nop) AD   2 minutes ago        Exit 0                                  desperate_pike

If I then change the provisioner to:

with_provisioner_options 'base_image' => 'min_image:latest',  'create_container' => { 'command' =>  'ls -l /opt'}

and then run the chef-client on the workstation it all succeeds (the workstation and the container chef-client runs) but it still executes the command chef-client -l info and not ls -l /opt:

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
bc331b9b81f2        231fbb21f23a        chef-client -l info    18 seconds ago      Exit 0                                  min

So what am I doing wrong? Does anyone have an example of creating a container and confirming that the command is actually executed?

Once I can do that, the next thing would be to know how to make it so the container stays up and runs one or more processes.

Thanks!

Will the re-write have the ability to do docker commands from the provisioning run?

Will the re-write keep the ability to do all the docker commands in the chef-metal recipes?

I.E. the feature where the provisioning recipe can do all the things that can be done in a docker file, but it doesn't require a chef-client in the docker container. It does it via the docker api from the provisioning chef-client run to the docker container via the docker api.

This is a super power and makes chef-metal-docker a much better docker provisioner than dockerfiles.

When should we start playing with this new version?

NoMethodError: undefined method 'id' for nil:nilClass when using machine_image resource

I'm attempting to use the following recipe to create a docker image on a CentOS 7 Virtualbox VM (for testing purposes):

require 'chef/provisioning/docker_driver'
machine_image 'zookeeper-test' do
    recipe 'zookeeper'
    driver 'docker'
    machine_options :docker_options => {
        :base_image => {
            :name => 'ubuntu',
            :repository => 'ubuntu',
            :tag => '14.04'
        }
    }
end

And here is the relevant part of the output from "chef-client -l debug" when I run this recipe:

[2015-04-14T12:43:41-07:00] INFO: Processing machine_image[zookeeper-test] action create (tests::machine_image_test line 3)
[2015-04-14T12:43:41-07:00] DEBUG: providers for generic machine_image resource enabled on node include: []
[2015-04-14T12:43:41-07:00] DEBUG: providers that refused resource machine_image[zookeeper-test] were: []
[2015-04-14T12:43:41-07:00] DEBUG: providers that support resource machine_image[zookeeper-test] include: []
[2015-04-14T12:43:41-07:00] DEBUG: no providers supported the resource, falling back to enabled handlers
[2015-04-14T12:43:41-07:00] DEBUG: providers that survived replacement include: []
[2015-04-14T12:43:41-07:00] DEBUG: dynamic provider resolver FAILED to resolve a provider
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_request
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
[2015-04-14T12:43:41-07:00] DEBUG: Signing the request as kube-master
[2015-04-14T12:43:41-07:00] DEBUG: String to sign: 'Method:GET
Hashed Path:7Z7zFOSXUinpODHzpJ+EIsUyzbA=
X-Ops-Content-Hash:2jmj7l5rSw0yVb/vlWAYkK/YBwk=
X-Ops-Timestamp:2015-04-14T19:43:41Z
X-Ops-UserId:kube-master'
Header hash: {"X-Ops-Sign"=>"algorithm=sha1;version=1.0;", "X-Ops-Userid"=>"kube-master", "X-Ops-Timestamp"=>"2015-04-14T19:43:41Z", "X-Ops-Content-Hash"=>"2jmj7l5rSw0yVb/vlWAYkK/YBwk=", "X-Ops-Authorization-1"=>"VMjVnN3HqhuKP7SjUGQxCcRWzdNNdZamISuIIbkWSJri8X9w4fB06pcZDcB1", "X-Ops-Authorization-2"=>"hoVhpSsVEpHhmPAAI4cyMmBA2XqIJ+Yqk7ORe6T+QfuZ3+M9fkZwdFrgVT2q", "X-Ops-Authorization-3"=>"jXY0OEABe3ZGwnrJTVtP3nR2gzi8oSbP3bSB4MfDdGIlhXH18h7zFE0xmCI8", "X-Ops-Authorization-4"=>"jhjfeCN3k+gMDINV3L6ngoOuVKfQ0x+ljL46V/3DIDd4Uy254j87jCxC6vzZ", "X-Ops-Authorization-5"=>"QnhrjUUg7zM0m4lOjv8yKipcISezYcqFkTTzFKITeaysNoRHqu7B5qzJf6WP", "X-Ops-Authorization-6"=>"ADkZ4/fvJdVHJg0j/dMY3YCs4gP1OBUufG+WtrxDPw=="}
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
[2015-04-14T12:43:41-07:00] DEBUG: Initiating GET to https://chef-server-centos.com/organizations/tcga/data/machine_image/zookeeper-test
[2015-04-14T12:43:41-07:00] DEBUG: ---- HTTP Request Header Data: ----
[2015-04-14T12:43:41-07:00] DEBUG: Accept: application/json
[2015-04-14T12:43:41-07:00] DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.0;
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-USERID: kube-master
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-TIMESTAMP: 2015-04-14T19:43:41Z
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-CONTENT-HASH: 2jmj7l5rSw0yVb/vlWAYkK/YBwk=
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-AUTHORIZATION-1: VMjVnN3HqhuKP7SjUGQxCcRWzdNNdZamISuIIbkWSJri8X9w4fB06pcZDcB1
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-AUTHORIZATION-2: hoVhpSsVEpHhmPAAI4cyMmBA2XqIJ+Yqk7ORe6T+QfuZ3+M9fkZwdFrgVT2q
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-AUTHORIZATION-3: jXY0OEABe3ZGwnrJTVtP3nR2gzi8oSbP3bSB4MfDdGIlhXH18h7zFE0xmCI8
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-AUTHORIZATION-4: jhjfeCN3k+gMDINV3L6ngoOuVKfQ0x+ljL46V/3DIDd4Uy254j87jCxC6vzZ
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-AUTHORIZATION-5: QnhrjUUg7zM0m4lOjv8yKipcISezYcqFkTTzFKITeaysNoRHqu7B5qzJf6WP
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-AUTHORIZATION-6: ADkZ4/fvJdVHJg0j/dMY3YCs4gP1OBUufG+WtrxDPw==
[2015-04-14T12:43:41-07:00] DEBUG: HOST: chef-server-centos.com:443
[2015-04-14T12:43:41-07:00] DEBUG: X-REMOTE-REQUEST-ID: dbe4a079-ac26-43f4-a244-90ca08b0c21e
[2015-04-14T12:43:41-07:00] DEBUG: ---- End HTTP Request Header Data ----
[2015-04-14T12:43:41-07:00] DEBUG: ---- HTTP Status and Header Data: ----
[2015-04-14T12:43:41-07:00] DEBUG: HTTP 1.1 404 Object Not Found
[2015-04-14T12:43:41-07:00] DEBUG: server: ngx_openresty/1.4.3.6
[2015-04-14T12:43:41-07:00] DEBUG: date: Tue, 14 Apr 2015 12:43:40 GMT
[2015-04-14T12:43:41-07:00] DEBUG: content-length: 81
[2015-04-14T12:43:41-07:00] DEBUG: connection: close
[2015-04-14T12:43:41-07:00] DEBUG: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=1.5.0
[2015-04-14T12:43:41-07:00] DEBUG: ---- End HTTP Status/Header Data ----
[2015-04-14T12:43:41-07:00] DEBUG: ---- HTTP Response Body ----
[2015-04-14T12:43:41-07:00] DEBUG: {"error":["Cannot load data bag item zookeeper-test for data bag machine_image"]}
[2015-04-14T12:43:41-07:00] DEBUG: ---- End HTTP Response Body -----
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_response
[2015-04-14T12:43:41-07:00] DEBUG: Expected JSON response, but got content-type ''
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
[2015-04-14T12:43:41-07:00] INFO: HTTP Request Returned 404 Object Not Found: error
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_request
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
[2015-04-14T12:43:41-07:00] DEBUG: Signing the request as kube-master
[2015-04-14T12:43:41-07:00] DEBUG: String to sign: 'Method:GET
Hashed Path:AMDCmRLYENS9SExi5vSX0/wD12w=
X-Ops-Content-Hash:2jmj7l5rSw0yVb/vlWAYkK/YBwk=
X-Ops-Timestamp:2015-04-14T19:43:41Z
X-Ops-UserId:kube-master'
Header hash: {"X-Ops-Sign"=>"algorithm=sha1;version=1.0;", "X-Ops-Userid"=>"kube-master", "X-Ops-Timestamp"=>"2015-04-14T19:43:41Z", "X-Ops-Content-Hash"=>"2jmj7l5rSw0yVb/vlWAYkK/YBwk=", "X-Ops-Authorization-1"=>"Gv7TrJGhytYk+yhWo9jzccfSsVWB0jUJ7M1t5R6adgZDfHKJdja+Ve+W+VkZ", "X-Ops-Authorization-2"=>"Uxk0sZHNSyY8XVXW+B8ZQdXVCPzmO/R5YFgHsnVQCDs67WweeqpncQw4ZFc9", "X-Ops-Authorization-3"=>"mRsyPMrPXLHsKtXvVERdEzKlXZC4KMHf74AZsptSLE63608kIPVy7CfLnY6a", "X-Ops-Authorization-4"=>"zWAc2iWNaC5tyhdGxOjK6Nm9RvXg+a2SUmMEgBIediT3IuLABSCh1YNUXkXd", "X-Ops-Authorization-5"=>"qj0sjXCfYdJbwsW1dEC1CnaPNpy946nmaRWqQ5HnpMZpLmUrti/BwwguIYMs", "X-Ops-Authorization-6"=>"J9WBf7gFPcna7ih0+D8s8zIZmSWxfOm5tK5ngu6nEA=="}
[2015-04-14T12:43:41-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
[2015-04-14T12:43:41-07:00] DEBUG: Initiating GET to https://chef-server-centos.com/organizations/tcga/data/images/zookeeper-test
[2015-04-14T12:43:41-07:00] DEBUG: ---- HTTP Request Header Data: ----
[2015-04-14T12:43:41-07:00] DEBUG: Accept: application/json
[2015-04-14T12:43:41-07:00] DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.0;
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-USERID: kube-master
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-TIMESTAMP: 2015-04-14T19:43:41Z
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-CONTENT-HASH: 2jmj7l5rSw0yVb/vlWAYkK/YBwk=
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-AUTHORIZATION-1: Gv7TrJGhytYk+yhWo9jzccfSsVWB0jUJ7M1t5R6adgZDfHKJdja+Ve+W+VkZ
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-AUTHORIZATION-2: Uxk0sZHNSyY8XVXW+B8ZQdXVCPzmO/R5YFgHsnVQCDs67WweeqpncQw4ZFc9
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-AUTHORIZATION-3: mRsyPMrPXLHsKtXvVERdEzKlXZC4KMHf74AZsptSLE63608kIPVy7CfLnY6a
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-AUTHORIZATION-4: zWAc2iWNaC5tyhdGxOjK6Nm9RvXg+a2SUmMEgBIediT3IuLABSCh1YNUXkXd
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-AUTHORIZATION-5: qj0sjXCfYdJbwsW1dEC1CnaPNpy946nmaRWqQ5HnpMZpLmUrti/BwwguIYMs
[2015-04-14T12:43:41-07:00] DEBUG: X-OPS-AUTHORIZATION-6: J9WBf7gFPcna7ih0+D8s8zIZmSWxfOm5tK5ngu6nEA==
[2015-04-14T12:43:41-07:00] DEBUG: HOST: chef-server-centos.com:443
[2015-04-14T12:43:41-07:00] DEBUG: X-REMOTE-REQUEST-ID: dbe4a079-ac26-43f4-a244-90ca08b0c21e
[2015-04-14T12:43:41-07:00] DEBUG: ---- End HTTP Request Header Data ----
[2015-04-14T12:43:42-07:00] DEBUG: ---- HTTP Status and Header Data: ----
[2015-04-14T12:43:42-07:00] DEBUG: HTTP 1.1 404 Object Not Found
[2015-04-14T12:43:42-07:00] DEBUG: server: ngx_openresty/1.4.3.6
[2015-04-14T12:43:42-07:00] DEBUG: date: Tue, 14 Apr 2015 12:43:40 GMT
[2015-04-14T12:43:42-07:00] DEBUG: content-length: 74
[2015-04-14T12:43:42-07:00] DEBUG: connection: close
[2015-04-14T12:43:42-07:00] DEBUG: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=1.5.0
[2015-04-14T12:43:42-07:00] DEBUG: ---- End HTTP Status/Header Data ----
[2015-04-14T12:43:42-07:00] DEBUG: ---- HTTP Response Body ----
[2015-04-14T12:43:42-07:00] DEBUG: {"error":["Cannot load data bag item zookeeper-test for data bag images"]}
[2015-04-14T12:43:42-07:00] DEBUG: ---- End HTTP Response Body -----
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Expected JSON response, but got content-type ''
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
[2015-04-14T12:43:42-07:00] INFO: HTTP Request Returned 404 Object Not Found: error
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Signing the request as kube-master
[2015-04-14T12:43:42-07:00] DEBUG: String to sign: 'Method:GET
Hashed Path:EXE2LPExbDohXR8mehvp+dZnBfw=
X-Ops-Content-Hash:2jmj7l5rSw0yVb/vlWAYkK/YBwk=
X-Ops-Timestamp:2015-04-14T19:43:42Z
X-Ops-UserId:kube-master'
Header hash: {"X-Ops-Sign"=>"algorithm=sha1;version=1.0;", "X-Ops-Userid"=>"kube-master", "X-Ops-Timestamp"=>"2015-04-14T19:43:42Z", "X-Ops-Content-Hash"=>"2jmj7l5rSw0yVb/vlWAYkK/YBwk=", "X-Ops-Authorization-1"=>"lesf0+354i3049yCUcSNLBBIQj3nBDxHtSgQRW8M3Gb4dVE9BK6OPHLomgEL", "X-Ops-Authorization-2"=>"Hx97QRuPQ/muClI1wXlP1BKVJGAn2bhAZSbf4ZDqIPlkWn1s3agC2ePUB0rg", "X-Ops-Authorization-3"=>"k1+GO4Dow3mrfog/AW24sX/l/vDOZy8C/ROAjYg8EaLIf847/caAyO6wt3R1", "X-Ops-Authorization-4"=>"Vln/PLWxQ/EkZq/H9JpskAp7TI5Qrioz4kku2iLa4OhvAB95meMCQYY1yBM3", "X-Ops-Authorization-5"=>"eNo6Y2l7KYmJJW0qJYJ47wpK1q3LD40mTHGXoO+xzIk76WF0pzEYnlNSSHCl", "X-Ops-Authorization-6"=>"yuTEYx7A4miGPN87j5+IDTaTVdpkIASi61ee5/7QTA=="}
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Initiating GET to https://chef-server-centos.com/organizations/tcga/nodes/zookeeper-test
[2015-04-14T12:43:42-07:00] DEBUG: ---- HTTP Request Header Data: ----
[2015-04-14T12:43:42-07:00] DEBUG: Accept: application/json
[2015-04-14T12:43:42-07:00] DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.0;
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-USERID: kube-master
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-TIMESTAMP: 2015-04-14T19:43:42Z
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-CONTENT-HASH: 2jmj7l5rSw0yVb/vlWAYkK/YBwk=
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-1: lesf0+354i3049yCUcSNLBBIQj3nBDxHtSgQRW8M3Gb4dVE9BK6OPHLomgEL
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-2: Hx97QRuPQ/muClI1wXlP1BKVJGAn2bhAZSbf4ZDqIPlkWn1s3agC2ePUB0rg
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-3: k1+GO4Dow3mrfog/AW24sX/l/vDOZy8C/ROAjYg8EaLIf847/caAyO6wt3R1
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-4: Vln/PLWxQ/EkZq/H9JpskAp7TI5Qrioz4kku2iLa4OhvAB95meMCQYY1yBM3
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-5: eNo6Y2l7KYmJJW0qJYJ47wpK1q3LD40mTHGXoO+xzIk76WF0pzEYnlNSSHCl
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-6: yuTEYx7A4miGPN87j5+IDTaTVdpkIASi61ee5/7QTA==
[2015-04-14T12:43:42-07:00] DEBUG: HOST: chef-server-centos.com:443
[2015-04-14T12:43:42-07:00] DEBUG: X-REMOTE-REQUEST-ID: dbe4a079-ac26-43f4-a244-90ca08b0c21e
[2015-04-14T12:43:42-07:00] DEBUG: ---- End HTTP Request Header Data ----
[2015-04-14T12:43:42-07:00] DEBUG: ---- HTTP Status and Header Data: ----
[2015-04-14T12:43:42-07:00] DEBUG: HTTP 1.1 200 OK
[2015-04-14T12:43:42-07:00] DEBUG: server: ngx_openresty/1.4.3.6
[2015-04-14T12:43:42-07:00] DEBUG: date: Tue, 14 Apr 2015 12:43:40 GMT
[2015-04-14T12:43:42-07:00] DEBUG: content-type: application/json
[2015-04-14T12:43:42-07:00] DEBUG: transfer-encoding: chunked
[2015-04-14T12:43:42-07:00] DEBUG: connection: close
[2015-04-14T12:43:42-07:00] DEBUG: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=1.5.0
[2015-04-14T12:43:42-07:00] DEBUG: content-encoding: gzip
[2015-04-14T12:43:42-07:00] DEBUG: ---- End HTTP Status/Header Data ----
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: decompressing gzip response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
[2015-04-14T12:43:42-07:00] INFO: Processing chef_node[zookeeper-test] action create (basic_chef_client::block line 57)
[2015-04-14T12:43:42-07:00] DEBUG: providers for generic chef_node resource enabled on node include: []
[2015-04-14T12:43:42-07:00] DEBUG: providers that refused resource chef_node[zookeeper-test] were: []
[2015-04-14T12:43:42-07:00] DEBUG: providers that support resource chef_node[zookeeper-test] include: []
[2015-04-14T12:43:42-07:00] DEBUG: no providers supported the resource, falling back to enabled handlers
[2015-04-14T12:43:42-07:00] DEBUG: providers that survived replacement include: []
[2015-04-14T12:43:42-07:00] DEBUG: dynamic provider resolver FAILED to resolve a provider
[2015-04-14T12:43:42-07:00] DEBUG: Platform basic_chef_client not found, using all defaults. (Unsupported platform?)
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Signing the request as kube-master
[2015-04-14T12:43:42-07:00] DEBUG: String to sign: 'Method:GET
Hashed Path:EXE2LPExbDohXR8mehvp+dZnBfw=
X-Ops-Content-Hash:2jmj7l5rSw0yVb/vlWAYkK/YBwk=
X-Ops-Timestamp:2015-04-14T19:43:42Z
X-Ops-UserId:kube-master'
Header hash: {"X-Ops-Sign"=>"algorithm=sha1;version=1.0;", "X-Ops-Userid"=>"kube-master", "X-Ops-Timestamp"=>"2015-04-14T19:43:42Z", "X-Ops-Content-Hash"=>"2jmj7l5rSw0yVb/vlWAYkK/YBwk=", "X-Ops-Authorization-1"=>"lesf0+354i3049yCUcSNLBBIQj3nBDxHtSgQRW8M3Gb4dVE9BK6OPHLomgEL", "X-Ops-Authorization-2"=>"Hx97QRuPQ/muClI1wXlP1BKVJGAn2bhAZSbf4ZDqIPlkWn1s3agC2ePUB0rg", "X-Ops-Authorization-3"=>"k1+GO4Dow3mrfog/AW24sX/l/vDOZy8C/ROAjYg8EaLIf847/caAyO6wt3R1", "X-Ops-Authorization-4"=>"Vln/PLWxQ/EkZq/H9JpskAp7TI5Qrioz4kku2iLa4OhvAB95meMCQYY1yBM3", "X-Ops-Authorization-5"=>"eNo6Y2l7KYmJJW0qJYJ47wpK1q3LD40mTHGXoO+xzIk76WF0pzEYnlNSSHCl", "X-Ops-Authorization-6"=>"yuTEYx7A4miGPN87j5+IDTaTVdpkIASi61ee5/7QTA=="}
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Initiating GET to https://chef-server-centos.com/organizations/tcga/nodes/zookeeper-test
[2015-04-14T12:43:42-07:00] DEBUG: ---- HTTP Request Header Data: ----
[2015-04-14T12:43:42-07:00] DEBUG: Accept: application/json
[2015-04-14T12:43:42-07:00] DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.0;
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-USERID: kube-master
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-TIMESTAMP: 2015-04-14T19:43:42Z
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-CONTENT-HASH: 2jmj7l5rSw0yVb/vlWAYkK/YBwk=
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-1: lesf0+354i3049yCUcSNLBBIQj3nBDxHtSgQRW8M3Gb4dVE9BK6OPHLomgEL
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-2: Hx97QRuPQ/muClI1wXlP1BKVJGAn2bhAZSbf4ZDqIPlkWn1s3agC2ePUB0rg
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-3: k1+GO4Dow3mrfog/AW24sX/l/vDOZy8C/ROAjYg8EaLIf847/caAyO6wt3R1
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-4: Vln/PLWxQ/EkZq/H9JpskAp7TI5Qrioz4kku2iLa4OhvAB95meMCQYY1yBM3
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-5: eNo6Y2l7KYmJJW0qJYJ47wpK1q3LD40mTHGXoO+xzIk76WF0pzEYnlNSSHCl
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-6: yuTEYx7A4miGPN87j5+IDTaTVdpkIASi61ee5/7QTA==
[2015-04-14T12:43:42-07:00] DEBUG: HOST: chef-server-centos.com:443
[2015-04-14T12:43:42-07:00] DEBUG: X-REMOTE-REQUEST-ID: dbe4a079-ac26-43f4-a244-90ca08b0c21e
[2015-04-14T12:43:42-07:00] DEBUG: ---- End HTTP Request Header Data ----
[2015-04-14T12:43:42-07:00] DEBUG: ---- HTTP Status and Header Data: ----
[2015-04-14T12:43:42-07:00] DEBUG: HTTP 1.1 200 OK
[2015-04-14T12:43:42-07:00] DEBUG: server: ngx_openresty/1.4.3.6
[2015-04-14T12:43:42-07:00] DEBUG: date: Tue, 14 Apr 2015 12:43:40 GMT
[2015-04-14T12:43:42-07:00] DEBUG: content-type: application/json
[2015-04-14T12:43:42-07:00] DEBUG: transfer-encoding: chunked
[2015-04-14T12:43:42-07:00] DEBUG: connection: close
[2015-04-14T12:43:42-07:00] DEBUG: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=1.5.0
[2015-04-14T12:43:42-07:00] DEBUG: content-encoding: gzip
[2015-04-14T12:43:42-07:00] DEBUG: ---- End HTTP Status/Header Data ----
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: decompressing gzip response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Signing the request as kube-master
[2015-04-14T12:43:42-07:00] DEBUG: String to sign: 'Method:PUT
Hashed Path:EXE2LPExbDohXR8mehvp+dZnBfw=
X-Ops-Content-Hash:73ker5e4SW7j/QWKhueUImjIA5M=
X-Ops-Timestamp:2015-04-14T19:43:42Z
X-Ops-UserId:kube-master'
Header hash: {"X-Ops-Sign"=>"algorithm=sha1;version=1.0;", "X-Ops-Userid"=>"kube-master", "X-Ops-Timestamp"=>"2015-04-14T19:43:42Z", "X-Ops-Content-Hash"=>"73ker5e4SW7j/QWKhueUImjIA5M=", "X-Ops-Authorization-1"=>"TQ30Gh05GFfQ5fCnoKcXnA3bYUanlhnLqfR1s87L5+yiOF+THTKYZ/HEVSz2", "X-Ops-Authorization-2"=>"HInCsGlAmuQ8NUSb6syJk4bB8VrnyQDewB2ZWqj4jUdTSFz+OM1f14IsokmF", "X-Ops-Authorization-3"=>"vvkptFSJb29xpaJTHEZDlmAmOZmKK+IReBFxfx+I5YvjKrrT5KUPtNfSpcuN", "X-Ops-Authorization-4"=>"FIzslulwoPCXmjHcjZID/1em90NkuLVpZXKk8a/pT3st5I3STHl/IF+uQoLn", "X-Ops-Authorization-5"=>"1FpL8wrkpaj0tqC45RHQY/InJ89Niix3Qw0tVg52BAZViEzfWKLph0a5xsdq", "X-Ops-Authorization-6"=>"7Gqz3RuXJR34dYV7KFmo4jHpglAPVPZ94MPksqqAow=="}
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
[2015-04-14T12:43:42-07:00] DEBUG: Initiating PUT to https://chef-server-centos.com/organizations/tcga/nodes/zookeeper-test
[2015-04-14T12:43:42-07:00] DEBUG: ---- HTTP Request Header Data: ----
[2015-04-14T12:43:42-07:00] DEBUG: Content-Type: application/json
[2015-04-14T12:43:42-07:00] DEBUG: Accept: application/json
[2015-04-14T12:43:42-07:00] DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.0;
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-USERID: kube-master
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-TIMESTAMP: 2015-04-14T19:43:42Z
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-CONTENT-HASH: 73ker5e4SW7j/QWKhueUImjIA5M=
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-1: TQ30Gh05GFfQ5fCnoKcXnA3bYUanlhnLqfR1s87L5+yiOF+THTKYZ/HEVSz2
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-2: HInCsGlAmuQ8NUSb6syJk4bB8VrnyQDewB2ZWqj4jUdTSFz+OM1f14IsokmF
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-3: vvkptFSJb29xpaJTHEZDlmAmOZmKK+IReBFxfx+I5YvjKrrT5KUPtNfSpcuN
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-4: FIzslulwoPCXmjHcjZID/1em90NkuLVpZXKk8a/pT3st5I3STHl/IF+uQoLn
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-5: 1FpL8wrkpaj0tqC45RHQY/InJ89Niix3Qw0tVg52BAZViEzfWKLph0a5xsdq
[2015-04-14T12:43:42-07:00] DEBUG: X-OPS-AUTHORIZATION-6: 7Gqz3RuXJR34dYV7KFmo4jHpglAPVPZ94MPksqqAow==
[2015-04-14T12:43:42-07:00] DEBUG: HOST: chef-server-centos.com:443
[2015-04-14T12:43:42-07:00] DEBUG: X-REMOTE-REQUEST-ID: dbe4a079-ac26-43f4-a244-90ca08b0c21e
[2015-04-14T12:43:42-07:00] DEBUG: Content-Length: 471
[2015-04-14T12:43:42-07:00] DEBUG: ---- End HTTP Request Header Data ----
[2015-04-14T12:43:42-07:00] DEBUG: ---- HTTP Status and Header Data: ----
[2015-04-14T12:43:42-07:00] DEBUG: HTTP 1.1 200 OK
[2015-04-14T12:43:42-07:00] DEBUG: server: ngx_openresty/1.4.3.6
[2015-04-14T12:43:42-07:00] DEBUG: date: Tue, 14 Apr 2015 12:43:40 GMT
[2015-04-14T12:43:42-07:00] DEBUG: content-type: application/json
[2015-04-14T12:43:42-07:00] DEBUG: transfer-encoding: chunked
[2015-04-14T12:43:42-07:00] DEBUG: connection: close
[2015-04-14T12:43:42-07:00] DEBUG: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=1.5.0
[2015-04-14T12:43:42-07:00] DEBUG: content-encoding: gzip
[2015-04-14T12:43:42-07:00] DEBUG: ---- End HTTP Status/Header Data ----
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: decompressing gzip response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
[2015-04-14T12:43:42-07:00] DEBUG: No matching images for chef:zookeeper-test, creating!
[2015-04-14T12:44:05-07:00] DEBUG: Allocated Docker::Image { :id => d0955f21bf24, :info => {"id"=>"d0955f21bf24", :headers=>{}}, :connection => Docker::Connection { :url => unix:///, :options => {:socket=>"/var/run/docker.sock"} } }
[2015-04-14T12:44:05-07:00] DEBUG: Tagged image Docker::Image { :id => d0955f21bf24, :info => {"id"=>"d0955f21bf24", :headers=>{}, "RepoTags"=>["chef:zookeeper-test"]}, :connection => Docker::Connection { :url => unix:///, :options => {:socket=>"/var/run/docker.sock"} } }
[2015-04-14T12:44:05-07:00] DEBUG: Start machine for container zookeeper-test using base image chef:zookeeper-test with options {:base_image=>{:name=>"ubuntu", :repository=>"ubuntu", :tag=>"14.04"}}
๏ฟฝ[0m
================================================================================๏ฟฝ[0m
๏ฟฝ[31mError executing action `create` on resource 'machine_image[zookeeper-test]'๏ฟฝ[0m
================================================================================๏ฟฝ[0m

๏ฟฝ[0mNoMethodError๏ฟฝ[0m
-------------๏ฟฝ[0m
undefined method `id' for nil:NilClass๏ฟฝ[0m

๏ฟฝ[0mResource Declaration:๏ฟฝ[0m
---------------------๏ฟฝ[0m
# In /var/chef/cache/cookbooks/tests/recipes/machine_image_test.rb
๏ฟฝ[0m
๏ฟฝ[0m  3: machine_image 'zookeeper-test' do
๏ฟฝ[0m  4:    recipe 'zookeeper'
๏ฟฝ[0m  5:    driver 'docker'
๏ฟฝ[0m  6:    machine_options :docker_options => {
๏ฟฝ[0m  7:        :base_image => {
๏ฟฝ[0m  8:            :name => 'ubuntu',
๏ฟฝ[0m  9:            :repository => 'ubuntu',
๏ฟฝ[0m 10:            :tag => '14.04'
๏ฟฝ[0m 11:        }
๏ฟฝ[0m 12:    }
๏ฟฝ[0m 13: end
๏ฟฝ[0m
๏ฟฝ[0mCompiled Resource:๏ฟฝ[0m
------------------๏ฟฝ[0m
# Declared in /var/chef/cache/cookbooks/tests/recipes/machine_image_test.rb:3:in `from_file'
๏ฟฝ[0m
๏ฟฝ[0mmachine_image("zookeeper-test") do
๏ฟฝ[0m  action :create
๏ฟฝ[0m  retries 0
๏ฟฝ[0m  retry_delay 2
๏ฟฝ[0m  default_guard_interpreter :default
๏ฟฝ[0m  chef_server {:chef_server_url=>"https://chef-server-centos.com/organizations/tcga", :options=>{:client_name=>"kube-master", :signing_key_filename=>"/etc/chef/client.pem"}}
๏ฟฝ[0m  driver "docker"
๏ฟฝ[0m  machine_options {:docker_options=>{:base_image=>{:name=>"ubuntu", :repository=>"ubuntu", :tag=>"14.04"}}}
๏ฟฝ[0m  declared_type :machine_image
๏ฟฝ[0m  cookbook_name "tests"
๏ฟฝ[0m  recipe_name "machine_image_test"
๏ฟฝ[0m  run_list_modifiers [#<Chef::RunList::RunListItem:0x00000003521ef0 @version=nil, @type=:recipe, @name="zookeeper">]
๏ฟฝ[0mend
๏ฟฝ[0m
๏ฟฝ[0m[2015-04-14T12:44:06-07:00] INFO: Running queued delayed notifications before re-raising exception
[2015-04-14T12:44:06-07:00] DEBUG: Re-raising exception: NoMethodError - machine_image[zookeeper-test] (tests::machine_image_test line 3) had an error: NoMethodError: undefined method `id' for nil:NilClass
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-docker-0.5.2/lib/chef/provisioning/docker_driver/driver.rb:200:in `rescue in start_machine'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-docker-0.5.2/lib/chef/provisioning/docker_driver/driver.rb:194:in `start_machine'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-docker-0.5.2/lib/chef/provisioning/docker_driver/driver.rb:88:in `ready_machine'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-0.20.1/lib/chef/provider/machine.rb:38:in `block in <class:Machine>'
  /opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:in `instance_eval'
  /opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:in `recipe_eval_with_update_check'
  /opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:45:in `block in action'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-0.20.1/lib/chef/provider/machine.rb:55:in `block in <class:Machine>'
  /opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:in `instance_eval'
  /opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:in `recipe_eval_with_update_check'
  /opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:45:in `block in action'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-0.20.1/lib/chef/provider/machine_image.rb:60:in `create_image'
  /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-0.20.1/lib/chef/provider/machine_image.rb:35:in `block in <class:MachineImage>'
  /opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:138:in `instance_eval'
  /opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:138:in `block in action'
  /opt/chef/embedded/apps/chef/lib/chef/provider.rb:149:in `run_action'
  /opt/chef/embedded/apps/chef/lib/chef/resource.rb:561:in `run_action'
  /opt/chef/embedded/apps/chef/lib/chef/runner.rb:49:in `run_action'
  /opt/chef/embedded/apps/chef/lib/chef/runner.rb:81:in `block (2 levels) in converge'
  /opt/chef/embedded/apps/chef/lib/chef/runner.rb:81:in `each'
  /opt/chef/embedded/apps/chef/lib/chef/runner.rb:81:in `block in converge'
  /opt/chef/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:83:in `block in execute_each_resource'
  /opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
  /opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
  /opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
  /opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
  /opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
  /opt/chef/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:81:in `execute_each_resource'
  /opt/chef/embedded/apps/chef/lib/chef/runner.rb:80:in `converge'
  /opt/chef/embedded/apps/chef/lib/chef/client.rb:331:in `block in converge'
  /opt/chef/embedded/apps/chef/lib/chef/client.rb:326:in `catch'
  /opt/chef/embedded/apps/chef/lib/chef/client.rb:326:in `converge'
  /opt/chef/embedded/apps/chef/lib/chef/client.rb:345:in `converge_and_save'
  /opt/chef/embedded/apps/chef/lib/chef/client.rb:449:in `run'
  /opt/chef/embedded/apps/chef/lib/chef/application.rb:271:in `block in fork_chef_client'
  /opt/chef/embedded/apps/chef/lib/chef/application.rb:259:in `fork'
  /opt/chef/embedded/apps/chef/lib/chef/application.rb:259:in `fork_chef_client'
  /opt/chef/embedded/apps/chef/lib/chef/application.rb:225:in `block in run_chef_client'
  /opt/chef/embedded/apps/chef/lib/chef/local_mode.rb:38:in `with_server_connectivity'
  /opt/chef/embedded/apps/chef/lib/chef/application.rb:213:in `run_chef_client'
  /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:392:in `block in interval_run_chef_client'
  /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:382:in `loop'
  /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:382:in `interval_run_chef_client'
  /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:372:in `run_application'
  /opt/chef/embedded/apps/chef/lib/chef/application.rb:60:in `run'
  /opt/chef/embedded/apps/chef/bin/chef-client:26:in `<top (required)>'
  /bin/chef-client:51:in `load'
  /bin/chef-client:51:in `<main>'
[2015-04-14T12:44:06-07:00] ERROR: Running exception handlers
[2015-04-14T12:44:06-07:00] ERROR: Exception handlers complete
[2015-04-14T12:44:06-07:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-04-14T12:44:06-07:00] DEBUG: NoMethodError: machine_image[zookeeper-test] (tests::machine_image_test line 3) had an error: NoMethodError: undefined method `id' for nil:NilClass
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-docker-0.5.2/lib/chef/provisioning/docker_driver/driver.rb:200:in `rescue in start_machine'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-docker-0.5.2/lib/chef/provisioning/docker_driver/driver.rb:194:in `start_machine'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-docker-0.5.2/lib/chef/provisioning/docker_driver/driver.rb:88:in `ready_machine'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-0.20.1/lib/chef/provider/machine.rb:38:in `block in <class:Machine>'
/opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:in `instance_eval'
/opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:in `recipe_eval_with_update_check'
/opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:45:in `block in action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-0.20.1/lib/chef/provider/machine.rb:55:in `block in <class:Machine>'
/opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:in `instance_eval'
/opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:in `recipe_eval_with_update_check'
/opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:45:in `block in action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-0.20.1/lib/chef/provider/machine_image.rb:60:in `create_image'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-0.20.1/lib/chef/provider/machine_image.rb:35:in `block in <class:MachineImage>'
/opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:138:in `instance_eval'
/opt/chef/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:138:in `block in action'
/opt/chef/embedded/apps/chef/lib/chef/provider.rb:149:in `run_action'
/opt/chef/embedded/apps/chef/lib/chef/resource.rb:561:in `run_action'
/opt/chef/embedded/apps/chef/lib/chef/runner.rb:49:in `run_action'
/opt/chef/embedded/apps/chef/lib/chef/runner.rb:81:in `block (2 levels) in converge'
/opt/chef/embedded/apps/chef/lib/chef/runner.rb:81:in `each'
/opt/chef/embedded/apps/chef/lib/chef/runner.rb:81:in `block in converge'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:83:in `block in execute_each_resource'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:81:in `execute_each_resource'
/opt/chef/embedded/apps/chef/lib/chef/runner.rb:80:in `converge'
/opt/chef/embedded/apps/chef/lib/chef/client.rb:331:in `block in converge'
/opt/chef/embedded/apps/chef/lib/chef/client.rb:326:in `catch'
/opt/chef/embedded/apps/chef/lib/chef/client.rb:326:in `converge'
/opt/chef/embedded/apps/chef/lib/chef/client.rb:345:in `converge_and_save'
/opt/chef/embedded/apps/chef/lib/chef/client.rb:449:in `run'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:271:in `block in fork_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:259:in `fork'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:259:in `fork_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:225:in `block in run_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/local_mode.rb:38:in `with_server_connectivity'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:213:in `run_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application/client.rb:392:in `block in interval_run_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application/client.rb:382:in `loop'
/opt/chef/embedded/apps/chef/lib/chef/application/client.rb:382:in `interval_run_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application/client.rb:372:in `run_application'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:60:in `run'
/opt/chef/embedded/apps/chef/bin/chef-client:26:in `<top (required)>'
/bin/chef-client:51:in `load'
/bin/chef-client:51:in `<main>'
[2015-04-14T12:44:06-07:00] DEBUG: Server doesn't support resource history, skipping resource report.
[2015-04-14T12:44:06-07:00] DEBUG: Audit Reports are disabled. Skipping sending reports.
[2015-04-14T12:44:06-07:00] ERROR: machine_image[zookeeper-test] (tests::machine_image_test line 3) had an error: NoMethodError: undefined method `id' for nil:NilClass
[2015-04-14T12:44:06-07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

After the recipe fails, I can see in the output of "docker images" that the image was created and tagged as chef:zookeeper-test, but when I run the container the chef-client executable is nowhere to be found.

I spent some time yesterday inserting debug statements into the code for the chef-provisioning and chef-provisioning-docker gems to see if I could figure out what might be causing this, and I noticed that the docker driver's allocate_image method (on line 65 of the machine_image provider in the chef-provisioning gem) doesn't appear to actually get called, which is what I would expect to happen based on what I've read of the code so far. If any of this is in error, I would be happy to learn if there's something I've missed here and any suggestions would be much appreciated.

Need volume support for machine_image

My current use case is when installing mysql while provisioning an image and having "/data/mysql:/var/lib/mysql" defined as a volume for persistence of the mysql db between container runs.

When the machine_image is being created, the volumes are not defined so mysql is installed in the local fs rather than to the persistent mount point.

When a machine is brought up from that image and the volumes are mounted, it mounts an empty /data/mysql directory, since the mysql db was installed on the local fs.

chef:mysql image while running machine_image create/chef-client

 "Volumes": {},
 "VolumesRW": {}

container running from chef:mysql image

  "Volumes": {
        "/dev/log": "/tmp/syslogdev/log",
        "/var/lib/mysql-default": "/data/mysql"
    },
    "VolumesRW": {
        "/dev/log": true,
        "/var/lib/mysql-default": true
    }

Please let me know if I need to clarify any of that.

Docker::Error::TimeoutError

Sometimes Im getting this error.

    Error executing action `converge` on resource 'machine[web27]'
    ================================================================================

    Docker::Error::TimeoutError
    ---------------------------
    read timeout reached

    Resource Declaration:
    ---------------------
    # In /home/vagrant/cookbooks/murally/recipes/create_container.rb

      4: machine "web27" do
      5:   recipe 'matiasdecarli::provision_container' 
      6: 
      7:   chef_server :chef_server_url=>'https://api.opscode.com/organizations/matiasdecarli',
      8:     :options =>{
      9:        :client_name=>"matiasdecarli",
     10:        :signing_key_filename=>"/etc/chef/client.pem"
     11:   }
     12: 
     13:   machine_options :docker_options => {
     14:       :base_image => {
     15:           :name => 'matiasdecarli/release-chef',
     16:           :repository => 'matiasdecarli',
     17:           :tag => 'latest'
     18:       },
     19:       :command => 'node',
     20:       :ports => 8080   
     21:   }
     22: end

Watching the log, I can see that this is happening after the Chef run

[2014-09-25T18:11:37+00:00] INFO: Chef Run complete in 347.802490812 seconds
[2014-09-25T18:11:37+00:00] INFO: Running report handlers
[2014-09-25T18:11:37+00:00] INFO: Report handlers complete
[2014-09-25T18:11:37+00:00] INFO: Sending resource update report (run-id: fb22fa40-e662-4193-b99b-71fe8db0cd1f)

Googleing this error, I can see that the solution is passing parameters (write_timeout, read_timeout) to docker-api. Is there any way to do this using the machine resource?

Enable to provisoning a container

Hi,

== I set up chef-server and docker.io in the same host (Ubuntu Precise). I installed 'chef-metal-docker' gem there to provisioning docker container.

== The chef-server is the client of itself. I can confirm buy this command.
ubuntu@vpc-proxy-01:~/provisioner$ sudo chef-client
[2014-09-20T09:51:27+00:00] INFO: Forking chef instance to converge...
[2014-09-20T09:51:27+00:00] WARN:


SSL validation of HTTPS requests is disabled. HTTPS connections are still
encrypted, but chef is not able to detect forged replies or man in the middle
attacks.

To fix this issue add an entry like this to your configuration file:

  # Verify all HTTPS connections (recommended)
  ssl_verify_mode :verify_peer

  # OR, Verify only connections to chef-server
  verify_api_cert true

To check your SSL configuration, or troubleshoot errors, you can use the
knife ssl check command like so:

  knife ssl check -c /etc/chef/client.rb

Starting Chef Client, version 11.14.6
[2014-09-20T09:51:27+00:00] INFO: *** Chef 11.14.6 ***
[2014-09-20T09:51:27+00:00] INFO: Chef-client pid: 4391
[2014-09-20T09:51:29+00:00] INFO: Run List is [recipe[build-essential]]
[2014-09-20T09:51:29+00:00] INFO: Run List expands to [build-essential]
[2014-09-20T09:51:29+00:00] INFO: Starting Chef Run for vpc-proxy-01.<>
[2014-09-20T09:51:29+00:00] INFO: Running start handlers
[2014-09-20T09:51:29+00:00] INFO: Start handlers complete.
[2014-09-20T09:51:29+00:00] INFO: HTTP Request Returned 404 Object Not Found:
resolving cookbooks for run list: ["build-essential"]
[2014-09-20T09:51:29+00:00] INFO: Loading cookbooks [[email protected]]
Synchronizing Cookbooks:

  • build-essential
    Compiling Cookbooks...
    Converging 7 resources
    Recipe: build-essential::_debian
  • package[autoconf] action install[2014-09-20T09:51:29+00:00] INFO: Processing package[autoconf] action install (build-essential::_debian line 21)
    (up to date)
  • package[binutils-doc] action install[2014-09-20T09:51:29+00:00] INFO: Processing package[binutils-doc] action install (build-essential::_debian line 22)
    (up to date)
  • package[bison] action install[2014-09-20T09:51:29+00:00] INFO: Processing package[bison] action install (build-essential::_debian line 23)
    (up to date)

== My provisioned node snippet:
ubuntu@vpc-proxy-01:~$ cat provisioner/wario.rb
require 'chef_metal_docker'

machine 'wario' do
recipe 'apache'

machine_options :docker_options => {
  :base_image => {
      :name => 'ubuntu',
      :repository => 'ubuntu',
      :tag => '14.04'
  },
  :command => '/usr/sbin/httpd'
}

end

== However, I cannot create an docker container. The log is
ubuntu@vpc-proxy-01:~/provisioner$ sudo CHEF_DRIVER=docker chef-client wario.rb
[2014-09-20T09:49:48+00:00] INFO: Forking chef instance to converge...
[2014-09-20T09:49:48+00:00] WARN:


SSL validation of HTTPS requests is disabled. HTTPS connections are still
encrypted, but chef is not able to detect forged replies or man in the middle
attacks.

To fix this issue add an entry like this to your configuration file:

  # Verify all HTTPS connections (recommended)
  ssl_verify_mode :verify_peer

  # OR, Verify only connections to chef-server
  verify_api_cert true

To check your SSL configuration, or troubleshoot errors, you can use the
knife ssl check command like so:

  knife ssl check -c /etc/chef/client.rb

Starting Chef Client, version 11.14.6
[2014-09-20T09:49:48+00:00] INFO: *** Chef 11.14.6 ***
[2014-09-20T09:49:48+00:00] INFO: Chef-client pid: 4151
[2014-09-20T09:49:50+00:00] INFO: Run List is [recipe[build-essential]]
[2014-09-20T09:49:50+00:00] INFO: Run List expands to [build-essential]
[2014-09-20T09:49:50+00:00] INFO: Starting Chef Run for vpc-proxy-01.<>
[2014-09-20T09:49:50+00:00] INFO: Running start handlers
[2014-09-20T09:49:50+00:00] INFO: Start handlers complete.
[2014-09-20T09:49:50+00:00] INFO: HTTP Request Returned 404 Object Not Found:
resolving cookbooks for run list: ["build-essential"]
[2014-09-20T09:49:50+00:00] INFO: Loading cookbooks [[email protected]]
Synchronizing Cookbooks:

  • build-essential
    Compiling Cookbooks...
    Converging 8 resources
    Recipe: build-essential::_debian

  • package[autoconf] action install[2014-09-20T09:49:52+00:00] INFO: Processing package[autoconf] action install (build-essential::_debian line 21)
    (up to date)

  • package[binutils-doc] action install[2014-09-20T09:49:52+00:00] INFO: Processing package[binutils-doc] action install (build-essential::_debian line 22)
    (up to date)

  • package[bison] action install[2014-09-20T09:49:52+00:00] INFO: Processing package[bison] action install (build-essential::_debian line 23)
    (up to date)

    • package[build-essential] action install[2014-09-20T09:49:52+00:00] INFO: Processing package[build-essential] action install (build-essential::_debian line 24)
      (up to date)
  • package[flex] action install[2014-09-20T09:49:52+00:00] INFO: Processing package[flex] action install (build-essential::_debian line 25)
    (up to date)

  • package[gettext] action install[2014-09-20T09:49:52+00:00] INFO: Processing package[gettext] action install (build-essential::_debian line 26)
    (up to date)

  • package[ncurses-dev] action install[2014-09-20T09:49:52+00:00] INFO: Processing package[ncurses-dev] action install (build-essential::_debian line 27)
    [2014-09-20T09:49:52+00:00] INFO: package[ncurses-dev] is a virtual package, actually acting on package[libncurses5-dev](up to date)
    Recipe: @recipe_files::/home/ubuntu/provisioner/wario.rb

  • machine[wario] action converge[2014-09-20T09:49:52+00:00] INFO: Processing machine[wario] action converge (@recipe_files::/home/ubuntu/provisioner/wario.rb line 3)
    [2014-09-20T09:49:52+00:00] INFO: Processing chef_node[wario] action create (basic_chef_client::block line 61)
    [2014-09-20T09:49:52+00:00] INFO: HTTP Request Returned 403 Forbidden: error
    [2014-09-20T09:49:52+00:00] INFO: Running queued delayed notifications before re-raising exception

    Error executing action converge on resource 'machine[wario]'

    Net::HTTPServerException

    chef_node[wario](basic_chef_client::block line 61) had an error: Net::HTTPServerException: 403 "Forbidden"

    Resource Declaration:

    In /home/ubuntu/provisioner/wario.rb

    3: machine 'wario' do
    4: recipe 'apache'
    5:
    6: machine_options :docker_options => {
    7: :base_image => {
    8: :name => 'ubuntu',
    9: :repository => 'ubuntu',
    10: :tag => '14.04'
    11: },
    12: :command => '/usr/sbin/httpd'
    13: }
    14: end

    Compiled Resource:

    Declared in /home/ubuntu/provisioner/wario.rb:3:in `from_file'

    machine("wario") do
    action :converge
    retries 0
    retry_delay 2
    guard_interpreter :default
    chef_server {:chef_server_url=>"https://vpc-proxy-01.<>", :options=>{:client_name=>"vpc-proxy-01.<>", :signing_key_filename=>"/etc/chef/client.pem"}}
    driver "docker"
    machine_options {:docker_options=>{:base_image=>{:name=>"ubuntu", :repository=>"ubuntu", :tag=>"14.04"}, :command=>"/usr/sbin/httpd"}}
    cookbook_name "@recipe_files"
    recipe_name "/home/ubuntu/provisioner/wario.rb"
    run_list_modifiers [recipe[apache]]
    end

[2014-09-20T09:49:52+00:00] INFO: Running queued delayed notifications before re-raising exception

Running handlers:
[2014-09-20T09:49:52+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-09-20T09:49:52+00:00] ERROR: Exception handlers complete
[2014-09-20T09:49:52+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 4.21188368 seconds
[2014-09-20T09:49:52+00:00] ERROR: machine[wario](@recipe_files::/home/ubuntu/provisioner/wario.rb line 3) had an error: Net::HTTPServerException: chef_node[wario](basic_chef_client::block line 61) had an error: Net::HTTPServerException: 403 "Forbidden"
[2014-09-20T09:49:52+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
ubuntu@vpc-proxy-01:~/provisioner$ ^C

Please enlighten me. Thanks

Connection to Docker image fails

Trying to run the command
CHEF_DRIVER=docker chef-client -z <chefprov_env>.rb
with the sample recipe at https://github.com/chef/chef-provisioning-docker

The image is created and I can see it listed but the the attempt to create the container fails with the following exception:

Error executing action converge on resource 'machine[machine1]'

Docker::Error::NotFoundError
----------------------------
No such container: machine1

If I manually run the command sudo docker run -t -i <image_created>a container instance is created. I tried running the chef-client in sudo mode but it is not able to access the chef-provisioning-docker gem in sudo mode

Docker::Error::ArgumentError: Must have id, got: {"id"=>nil, :headers=>{}}

Steps to reproduce:

  1. Create image with machine_image resource;
  2. Remove image created on previous step using docker rmi command;
  3. Converge machine using image from step 1 as from_image attribute;

This happens due to chef-server has information regarding to specified image in data bag, but image is not available on target machine.

Error message doesn't clarify what has happened. We need to process errors like this and display more informative text.

Another option here, we can try to recreate images, since data bag item container information regarding to image specification. Though, it is currently blocked by #53 , image spec doesn't contain valid information about base image:

{
  "id": "my_app",
  "reference": {
    "driver_url": "docker:unix:///var/run/docker.sock",
    "driver_version": "0.7-dev",
    "allocated_at": 1436044732,
    "docker_options": {
      "base_image": {
        "name": "chef_my_app",
        "repository": "chef",
        "tag": "my_app"
      },
      "from_image": true
    }
  },
  "run_list": [
    "recipe[test::recipe1]",
    "recipe[test::recipe2]",
    "recipe[test::recipe1]",
    "recipe[test::recipe2]"
  ]
}

Cannot Run Samples w/ boot2docker

I installed boot2docker (1.3.1) and installed docker (1.3.1) my my OS X 10.10 system. I set up boot2docker by:

$ boot2docker init
$ boot2docker up
$ export DOCKER_HOST=tcp://192.168.59.103:2376
$ export DOCKER_CERT_PATH=/Users/jherriott/.boot2docker/certs/boot2docker-vm
$ export DOCKER_TLS_VERIFY=1
$ export CHEF_DRIVER=docker

From the OS X command prompt, I am unable to run:

$ bundle exec chef-client -z docker_ubuntu_image.rb
/Users/jherriott/.rvm/gems/ruby-2.1.2/gems/bundler-1.6.5/lib/bundler/rubygems_integration.rb:256:in `block in replace_gem': chef is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
    from /Users/jherriott/.rvm/gems/ruby-2.1.2/bin/chef-client:22:in `<main>'
    from /Users/jherriott/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
    from /Users/jherriott/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'

however, I can get it partially going doing:

$ chef-client -z docker_ubuntu_image.rb
[2014-11-07T17:02:21-08:00] WARN: No config file found or specified on command line, using command line options.
[2014-11-07T17:02:21-08:00] WARN: No cookbooks directory found at or above current directory.  Assuming /Users/jherriott/workspace/chef-provisioning/docs/examples.
Starting Chef Client, version 11.16.4
resolving cookbooks for run list: []
Synchronizing Cookbooks:
Compiling Cookbooks...
WARN: Unresolved specs during Gem::Specification.reset:
      mini_portile (~> 0.6.0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
[2014-11-07T17:02:35-08:00] WARN: Node Bitcasas-MacBook-Pro.local has an empty run list.
Converging 2 resources
Recipe: @recipe_files::/Users/jherriott/workspace/chef-provisioning/docs/examples/docker_ubuntu_image.rb
  * machine_image[web_server] action create
    - update node web_server at http://localhost:8889
    -   update normal.chef_provisioning.location.allocated_at from "2014-11-08 00:53:12 UTC" to "2014-11-08 01:02:35 UTC"
    ================================================================================
    Error executing action `create` on resource 'machine_image[web_server]'
    ================================================================================

    Excon::Errors::SocketError
    --------------------------
    No such file or directory - connect(2) for /var/run/docker.sock (Errno::ENOENT)

    Resource Declaration:
    ---------------------
    # In /Users/jherriott/workspace/chef-provisioning/docs/examples/docker_ubuntu_image.rb

      3: machine_image 'web_server' do
      4:   recipe 'apache'
      5: 
      6:   machine_options :docker_options => {
      7:       :base_image => {
      8:           :name => 'ubuntu',
      9:           :repository => 'ubuntu',
     10:           :tag => '14.04'
     11:       }
     12:   }
     13: end
     14: 

    Compiled Resource:
    ------------------
    # Declared in /Users/jherriott/workspace/chef-provisioning/docs/examples/docker_ubuntu_image.rb:3:in `from_file'

    machine_image("web_server") do
      action :create
      retries 0
      retry_delay 2
      guard_interpreter :default
      chef_server {:chef_server_url=>"http://localhost:8889", :options=>{:client_name=>"Bitcasas-MacBook-Pro.local", :signing_key_filename=>nil}}
      driver "docker"
      machine_options {:docker_options=>{:base_image=>{:name=>"ubuntu", :repository=>"ubuntu", :tag=>"14.04"}}}
      cookbook_name "@recipe_files"
      recipe_name "/Users/jherriott/workspace/chef-provisioning/docs/examples/docker_ubuntu_image.rb"
      run_list_modifiers [#<Chef::RunList::RunListItem:0x007fce63cd44f0 @version=nil, @type=:recipe, @name="apache">]
    end


Running handlers:
[2014-11-07T17:02:35-08:00] ERROR: Running exception handlers
Running handlers complete
[2014-11-07T17:02:35-08:00] ERROR: Exception handlers complete
[2014-11-07T17:02:35-08:00] FATAL: Stacktrace dumped to /Users/jherriott/.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 9.849394 seconds
[2014-11-07T17:02:35-08:00] ERROR: machine_image[web_server] (@recipe_files::/Users/jherriott/workspace/chef-provisioning/docs/examples/docker_ubuntu_image.rb line 3) had an error: Excon::Errors::SocketError: No such file or directory - connect(2) for /var/run/docker.sock (Errno::ENOENT)
[2014-11-07T17:02:35-08:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

So, my question is, what am I doing wrong? Is there something I need to fix?

Could not find the file /etc/chef/client.pem in container

I'm trying to use the example recipe:

require 'chef_metal_docker'

machine_image 'web_server' do
  recipe 'apache'

  machine_options :docker_options => {
      :base_image => {
          :name => 'ubuntu',
          :repository => 'ubuntu',
          :tag => '14.04'
      }
  }
end

machine 'web00' do
  from_image 'web_server'

  machine_options :docker_options => {
      :command => '/usr/sbin/httpd'
  }
end

I ran it like this but it failed with "Could not find the file /etc/chef/client.pem in container f765b676":

# docker -v
Docker version 1.0.1, build 990021a
# chef-client -v
Chef: 11.16.2
# CHEF_DRIVER=docker bundle exec chef-client -z docker_ubuntu_image.rb
[2014-10-02T04:04:57-04:00] WARN: No config file found or specified on command line, using command line options.
[2014-10-02T04:04:57-04:00] WARN: No cookbooks directory found at or above current directory.  Assuming /home/dan/Code/cheftests.
Starting Chef Client, version 11.16.2
resolving cookbooks for run list: []
Synchronizing Cookbooks:
Compiling Cookbooks...
[2014-10-02T04:05:00-04:00] WARN: Node dan-ThinkPad-X1-Carbon-2nd has an empty run list.
Converging 2 resources
Recipe: @recipe_files::/home/dan/Code/cheftests/docker_ubuntu_image.rb
  * machine_image[web_server] action create
    - update node web_server at http://localhost:8889
    -   update normal.metal.location.allocated_at from "2014-10-02 07:59:46 UTC" to "2014-10-02 08:05:00 UTC"
    ================================================================================
    Error executing action `create` on resource 'machine_image[web_server]'
    ================================================================================

    Docker::Error::ServerError
    --------------------------
    Could not find the file /etc/chef/client.pem in container f765b676d0dc3bc972c90c4d21549af7775bdfd67a31472df1ef8cf858d9e5bf

    Resource Declaration:
    ---------------------
    # In /home/dan/Code/cheftests/docker_ubuntu_image.rb

      3: machine_image 'web_server' do
      4:   recipe 'apache'
      5: 
      6:   machine_options :docker_options => {
      7:       :base_image => {
      8:           :name => 'ubuntu',
      9:           :repository => 'ubuntu',
     10:           :tag => '14.04'
     11:       }
     12:   }
     13: end
     14: 

    Compiled Resource:
    ------------------
    # Declared in /home/dan/Code/cheftests/docker_ubuntu_image.rb:3:in `from_file'

    machine_image("web_server") do
      action :create
      retries 0
      retry_delay 2
      guard_interpreter :default
      chef_server {:chef_server_url=>"http://localhost:8889", :options=>{:client_name=>"dan-ThinkPad-X1-Carbon-2nd", :signing_key_filename=>nil}}
      driver "docker"
      machine_options {:docker_options=>{:base_image=>{:name=>"ubuntu", :repository=>"ubuntu", :tag=>"14.04"}}}
      cookbook_name "@recipe_files"
      recipe_name "/home/dan/Code/cheftests/docker_ubuntu_image.rb"
      run_list_modifiers [recipe[apache]]
    end

Running handlers:
[2014-10-02T04:05:00-04:00] ERROR: Running exception handlers
Running handlers complete
[2014-10-02T04:05:00-04:00] ERROR: Exception handlers complete
[2014-10-02T04:05:00-04:00] FATAL: Stacktrace dumped to /root/.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 2.551468423 seconds
[2014-10-02T04:05:00-04:00] ERROR: machine_image[web_server] (@recipe_files::/home/dan/Code/cheftests/docker_ubuntu_image.rb line 3) had an error: Docker::Error::ServerError: Could not find the file /etc/chef/client.pem in container f765b676d0dc3bc972c90c4d21549af7775bdfd67a31472df1ef8cf858d9e5bf

[2014-10-02T04:05:00-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Btw, my client.rb is:

# cat /etc/chef/client.rb 
log_location     STDOUT
chef_server_url  "https://api.opscode.com/organizations/testord"
validation_client_name "testord-validator"
validation_key '/etc/chef/validation.pem'
# Using default node name (fqdn)

I can't figure out how to fix this. Any ideas?

Container.create missing cmd parameter?

I tried to run a simple test, but it fails because Container.create is missing the cmd parameter.

This did not work:
container = Docker::Container.create('Image' => image.id, 'name' => container_name)

This works:
container = Docker::Container.create('Cmd' => :command, 'Image' => image.id, 'name' => container_name)

docker_options/base_image with docker-api v1.20.0 result in a 404 error

Hi,

Quick issue here, with the docker-api gem v1.20 (which I believe is shipped with ChefDK 0.4.0) I'm somehow getting a 404 error with chef-provisioning-docker (0.5.2):

    ================================================================================
    Error executing action `create` on resource 'machine_image[web_server]'
    ================================================================================

    Docker::Error::NotFoundError
    ----------------------------
    Expected([200, 201, 202, 203, 204, 304]) <=> Actual(404 Not Found)

    Resource Declaration:
    ---------------------
    # In /home/sjourdan/dev/chef-repo/provisioning/webserver-docker.rb

      3: machine_image 'web_server' do
      4:   recipe 'apache'
      5: 
      6:   machine_options :docker_options => {
      7:       :base_image => {
      8:           :name => 'ubuntu',
      9:           :repository => 'ubuntu',
     10:           :tag => '14.04'
     11:       }
     12:   }
     13: end
     14: 

My current workaround is to simply rollback to the 1.18 version of docker-api, so the problem disappear.

IP Address of Docker Container?

Is it possible to get the IP address of the docker container for use in a recipe with code similar to this ec2 code?

ruby_block "print out public IP" do
block do
appservernode = search(:node, "name:#{appserver_instance_name}").first
Chef::Log.info("Application can be accessed at http://#{appservernode['ec2']['public_ipv4']}:3001")
end
end

Publishing ports

Hi guys!

Maybe this is a silly question, but... is there is any option to publish a port?
The idea is to obtain something similar to this

docker run -t -i -p 8080 matiasdecarli/release-chef /bin/bash
CONTAINER ID        IMAGE                               COMMAND                CREATED              STATUS                      PORTS                     NAMES
56ac6548abae        matiasdecarli/release-chef:latest   "/bin/bash"            19 minutes ago       Up 19 minutes               0.0.0.0:49154->8080/tcp   web02

Docker::Error::ServerError: Invalid registry endpoint on CentOS 7

Getting following error when trying to use docker image from private reporistory.

ERROR: machine_image[test] (test-app::default line 18) had an error: 
Docker::Error::ServerError: Invalid registry endpoint https://<server_address>/v1/: 
Get https://<server_address>/v1/_ping: dial tcp: i/o timeout. If this private 
registry supports only HTTP or HTTPS with an unknown CA certificate, 
please add `--insecure-registry <server_address>` to the daemon's 
arguments. In the case of HTTPS, if you have access to the registry's 
CA certificate, no need for the flag; simply place the CA certificate 
at /etc/docker/certs.d/<server_address>/ca.crt

My private repostiry uses ssl with self-signed certificate. I have certificate installed at /etc/docker/certs.d/<server_address>/ca.crt on host system. When I do docker pull <server_address>/<image_name>:<tag> on the same VM it works just fine. Though, machine_image resource fails with error above.

Here is my recipe:

require 'chef/provisioning/docker_driver'

with_driver 'docker'

if platform_family?'rhel'
# Workaround for https://github.com/swipely/docker-api/issues/155 .
# CentOS 7 has docker 1.3.2 version by default wich supports 1.15 Docker API. 
# Default version defined in docker-api is 1.16.
    Docker::API_VERSION='1.15'
end

# create test image
machine_image 'test' do
  recipe 'test-app'
  recipe 'test-app::cleanup'

  machine_options :docker_options => {
      :base_image => {
          :name => 'my-private-docker-registry.org/centos',
          :repository => 'my-private-docker-registry.org/centos',
          :tag => '7'
      }
  }
end

Modify way of how use local image as base image

I was trying to run sequentially creation of two images following way:

require "chef/provisioning/docker_driver"
with_driver "docker"
machine_image "machine1" do
  recipe "my_recipe::1"
  machine_options :docker_options => {
      :base_image => {
          :name => "ubuntu",
          :repository => "ubuntu",
          :tag => "14.04"
      }
  }
end

machine_image "machine2" do
  recipe "my_recipe::2"

  machine_options :docker_options => {
      :base_image => {
          :name => "chef",
          :repository => "chef",
          :tag => "machine1"
       }
  }
end

But it doesn't work for some reason. Still looking on it.

NoMethodError `<<' for #<Chef::EventDispatch::EventsOutputStream:0x000000056423a0>

I constantly get this error. The command option seems not to be working in my node definition.

[2014-09-20T22:35:55+00:00] INFO: Processing chef_node[wario] action create (basic_chef_client::block line 144)
[2014-09-20T22:35:57+00:00] INFO: Processing chef_node[wario] action create (basic_chef_client::block line 61)

================================================================================
Error executing action `converge` on resource 'machine[wario]'
================================================================================

NoMethodError
-------------
undefined method `<<' for #<Chef::EventDispatch::EventsOutputStream:0x000000056423a0>

Resource Declaration:
---------------------
# In /home/ubuntu/provisioner/wario.rb

  3: machine 'wario' do
  4:     machine_options :docker_options => {
  5:       :base_image => {
  6:           :name => 'ubuntu',
  7:           :repository => 'ubuntu',
  8:           :tag => '14.04'
  9:       },
 10:       :chef_server_url => 'https://vpc-proxy-01.lzd.co',
 11:       :node_name       => 'wario_link',
 12:       :command        => '/bin/bash'
 13:     }
 14: end

Compiled Resource:
------------------

Running handlers:
[2014-09-20T22:36:01+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-09-20T22:36:01+00:00] ERROR: Exception handlers complete
[2014-09-20T22:36:01+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 10.870250922 seconds
[2014-09-20T22:36:01+00:00] ERROR: machine[wario](@recipe_files::/home/ubuntu/provisioner/wario.rb line 3) had an error: NoMethodError: undefined method `<<' for #Chef::EventDispatch::EventsOutputStream:0x000000056423a0
[2014-09-20T22:36:01+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

++When I tried to re-attach the container, it always end at 'chef-client run' instead of the command '/bin/bash' as I specified. Please help.

Reduce image size produced by `machine_image` resource

I found that docker image created by machine_image resource has too many redundant layers in it.

REPOSITORY        TAG                 IMAGE ID            VIRTUAL SIZE
chef              test                85d60acf156b        386.7 MB
ubuntu            14.04               2d24f826cb16        188.3 MB
IMAGE         CREATED BY                                                         SIZE
85d60acf156b  chef-client -l auto                                                2 B
d18b21b38ae7  dpkg -i /tmp/chef_12.1.0-1_amd64.deb                               154.4 MB
911920e7729f  /bin/sh -c #(nop) ADD file:<hash> in /tmp/chef_12.1.0-1_amd64.deb  43.96 MB
3f9ff1bb17bb  /bin/sh -c #(nop) ADD file:<hash> in /tmp/detect.sh                3.559 kB
374b13cdedd5  /bin/sh -c #(nop) ADD file:<hash> in /etc/chef/client.rb           132 B
8a3981e5fa44  /bin/sh -c #(nop) ADD file:<hash> in /etc/chef/client.pem          1.679 kB
a6e2feedecb1  mkdir -p /etc/chef+                                                0 B
2d24f826cb16  /bin/sh -c #(nop) CMD [/bin/bash]                                  0 B

Please note 911920e7729f and d18b21b38ae7. Ideally, I believe, it has to be merged into single layer (85d60acf156b). It is also important to allow completely remove chef-client from image to save ~200Mb.

So far the only workaround here is to reimport image with docker export <conainer_id> | sudo docker import - <my_compact_image_name>. Thoug, I personaly don't like this approach because it also wipes out underlying layers of base image (for instance, ubuntu image).

Docker Swarm support

Currently chef-provisioning-docker does not support Docker Swarm -- docker native clustering tool. chef-provisioning-docker workflow implies committing containers and reusing resulting images. This new image exists only on single node in the cluster, and Swarm is unable to track it and run container on node with that image.
This could be addressed on Swarm side by implementing images replication. But I didn't see any work in that direction so far.
Another way is to support Swarm filters in chef-provisioning-docker to be able to process all steps of convergence on the same node. It is also requires additional work if chef-zero used, so remote container could connect to chef-zero on provisioning node.

ERROR: Connection refused

Getting following error on machine_create while run chef-client in local mode:

$ sudo CHEF_DRIVER=docker bundle exec chef-client -z recipes/robot.rb
  <....>
    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

    [2015-02-19T10:31:15+00:00] INFO: *** Chef 12.0.3 ***
    [2015-02-19T10:31:15+00:00] INFO: Chef-client pid: 10
    [2015-02-19T10:31:16+00:00] ERROR: Connection refused connecting to http://localhost:8889/nodes/robot, retry 1/5
    [2015-02-19T10:31:21+00:00] ERROR: Connection refused connecting to http://localhost:8889/nodes/robot, retry 2/5
    [2015-02-19T10:31:26+00:00] ERROR: Connection refused connecting to http://localhost:8889/nodes/robot, retry 3/5
    [2015-02-19T10:31:31+00:00] ERROR: Connection refused connecting to http://localhost:8889/nodes/robot, retry 4/5
    [2015-02-19T10:31:36+00:00] ERROR: Connection refused connecting to http://localhost:8889/nodes/robot, retry 5/5

    ================================================================================
    Chef encountered an error attempting to load the node data for "robot"
    ================================================================================

    Networking Error:
    -----------------
    Connection refused - Connection refused connecting to http://localhost:8889/nodes/robot, giving up

    Your chef_server_url may be misconfigured, or the network could be down.

    Relevant Config Settings:
    -------------------------
    chef_server_url  "http://localhost:8889"
<...>

Here is how recipes/robot.rb looks:

require 'chef/provisioning/docker_driver'
with_driver 'docker'
machine_image 'robot' do
  recipe 'robot'
  machine_options :docker_options => {
      :base_image => {
          :name => 'ubuntu',
          :repository => 'ubuntu',
          :tag => '14.04'
      }
  }
end

Obviously this happens due to chef-zero is running on host and container has no access to it. This could be solved by adding --net=host option to container when running chef-client in local mode. Another way is probably to play with iptables.

This issue also occures when testing recipes with test-kitchen.

Connection refused - Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, giving up

I'm having problems provisioning an image using docker on OSX (boot2docker) with chef in local mode.
My container tries to find the chef-server on the docker host instead on my OSX machine.

Is there a way I can give the container a hint so it uses the local chef or is my setup using boot2docker that makes the whole szenario impossible?

Actually I'm using the successor of boot2docker on OSX called Docker Machine. But I guess it's behaviour is the same as boot2docker and should't make a difference.

I use the following setup:

Recipe I am using

docker_ubuntu_image.rb

require 'chef/provisioning/docker_driver'

machine 'daniel' do
    recipe 'openssh::default'
    machine_options :docker_options => {
      :base_image => {
          :name => 'ubuntu',
          :repository => 'ubuntu',
          :tag => '14.04'
      },
      :command => '/usr/sbin/sshd -p 8022 -D',
    }
end

Gemfile for the setup

( still using librarian instead of berkshelf ...)

source 'https://rubygems.org'

gem 'chef-zero'
gem 'chef-provisioning-docker'
gem 'librarian-chef'

Command I executed

CHEF_DRIVER=docker chef-client -z docker_ubuntu_image.rb

Full Exception

Here the part of the exception which seems relevant to me.
172.17.42.1 is the IP the docker host is bound to.

Running handlers:
[2015-10-27T08:49:20+01:00] ERROR: Running exception handlers
Running handlers complete
[2015-10-27T08:49:20+01:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 35 seconds
[2015-10-27T08:49:20+01:00] FATAL: Stacktrace dumped to /Users/daniel/.chef/local-mode-cache/cache/chef-stacktrace.out
[2015-10-27T08:49:20+01:00] ERROR: machine[daniel] (@recipe_files::/Users/daniel/development/chef/versuch2/docker_ubuntu_image.rb line 3) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of docker run --name daniel b11c4326c0cfd6b330d290056ce4d926cc95de1c2654a9f1eb884c151f7edb0b chef-client -l auto ----
STDOUT: [2015-10-27T07:48:54+00:00] INFO: Forking chef instance to converge...
[2015-10-27T07:48:54+00:00] INFO: *** Chef 12.5.1 ***
[2015-10-27T07:48:54+00:00] INFO: Chef-client pid: 10
[2015-10-27T07:48:55+00:00] ERROR: Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, retry 1/5
[2015-10-27T07:49:00+00:00] ERROR: Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, retry 2/5
[2015-10-27T07:49:05+00:00] ERROR: Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, retry 3/5
[2015-10-27T07:49:10+00:00] ERROR: Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, retry 4/5
[2015-10-27T07:49:15+00:00] ERROR: Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, retry 5/5

================================================================================
Chef encountered an error attempting to load the node data for "daniel"
================================================================================

Networking Error:
-----------------
Connection refused - Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, giving up

Your chef_server_url may be misconfigured, or the network could be down.

Relevant Config Settings:
-------------------------
chef_server_url  "http://172.17.42.1:8889"

[2015-10-27T07:49:20+00:00] ERROR: Running exception handlers
[2015-10-27T07:49:20+00:00] ERROR: Exception handlers complete
[2015-10-27T07:49:20+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-10-27T07:49:20+00:00] ERROR: Connection refused - Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, giving up
[2015-10-27T07:49:20+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
STDERR:
---- End output of docker run --name daniel b11c4326c0cfd6b330d290056ce4d926cc95de1c2654a9f1eb884c151f7edb0b chef-client -l auto ----
Ran docker run --name daniel b11c4326c0cfd6b330d290056ce4d926cc95de1c2654a9f1eb884c151f7edb0b chef-client -l auto returned 1
[2015-10-27T08:49:21+01:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Machine image gets immediately deleted after creation

Running recipe from example:

machine_image 'web_server' do
  recipe 'apache'
  machine_options :docker_options => {
      :base_image => {
          :name => 'ubuntu',
          :repository => 'ubuntu',
          :tag => '14.04'
      }
  }
end

After chef-client exited, no docker images are accessible.
This happens due to following change in latest version if chef-provisioning (v1.0.1) .

gemspec relies on very old chef-provisioning version

see https://github.com/chef/chef-provisioning-docker/blob/master/chef-provisioning-docker.gemspec#L16

Updating git://github.com/chef/chef-provisioning-google.git
Updating git://github.com/chef/chef-provisioning-docker.git
Updating git://github.com/chef/chef-provisioning-ssh.git
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "chef-provisioning":
  In Gemfile:
    chef-provisioning-docker (>= 0) ruby depends on
      chef-provisioning (~> 0.9) ruby

    chef-provisioning (>= 0) ruby

search(:node) does not contain the ipaddress

Here are two scripts.
One creates a machine:

require 'chef/provisioning/docker_driver'
machine "dummy" do
    tag "dummy"
    converge true
    machine_options({ docker_options: {
        base_image: { name: 'baseimage', repository: 'phusion/baseimage', tag: '0.9.17' },
        command: '/sbin/my_init'} })
end

The other searches for it:

require 'chef/provisioning/docker_driver'
search(:node, "tags:*dummy*").map do |node|
    p node.ipaddress
end

When I run these scripts with bundle and this Gemfile:

gem 'chef-provisioning-docker'

The second script works fine.

When I try and run against the master git HEAD version :

gem 'chef-provisioning-docker', :path => '../chef-provisioning-docker' 

I get the following error:

ERROR: Undefined method or attribute `ipaddress' on `node'

Add volumes support

It would be realy nice to be able to specify docker volumes when provisioning machines. It also could help solve #26 .

NoMethodError: undefined method `[]' while creating machine from image

After latest (v0.20) chef-privisioning changes following code stops working:

require 'chef/provisioning/docker_driver'
machine_image 'web_server' do
  recipe 'apache'
  machine_options :docker_options => {
      :base_image => {
          :name => 'ubuntu',
          :repository => 'ubuntu',
          :tag => '14.04'
      }
  }
end
machine 'web00' do
  from_image 'web_server'
  machine_options :docker_options => {
      :command => '/usr/sbin/httpd'
  }
end

chef-provisining changed the way how machine_images_spec is stored. Following commit supposed to fix compatibility issue, but it doesn't actually saves machine_options into data:
Before v0.20 (cat data_bags/images/web_server.json)

{
  "id": "web_server",
  "machine_options": {
    "docker_options": {
      "base_image": {
        "name": "chef_web_server",
        "repository": "chef",
        "tag": "web_server"
      },
      "from_image": true
    }
  }
}

After (cat data_bags/machine_image/web_server.json)

{
  "id": "web_server",
  "driver_url": "docker:unix:///var/run/docker.sock",
  "run_list": [
    "recipe[apache]",
  ]
}

From logs:

[2015-03-30T07:53:29+00:00] WARN: Machine options are no longer stored in machine_image_spec.  Drivers that store machine_options will stop working with Provisioning 1.0.

stacktrace

NoMethodError: machine[web00] (test::default line 66) had an error: NoMethodError: undefined method `[]' for nil:NilClass
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-provisioning-docker-0.5.2/lib/chef/provisioning/docker_driver/driver.rb:100:in `build_container'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-provisioning-docker-0.5.2/lib/chef/provisioning/docker_driver/driver.rb:87:in `ready_machine'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-provisioning-0.20/lib/chef/provider/machine.rb:38:in `block in <class:Machine>'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:60:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:60:in `recipe_eval_with_update_check'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:45:in `block in action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-provisioning-0.20/lib/chef/provider/machine.rb:55:in `block in <class:Machine>'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:60:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:60:in `recipe_eval_with_update_check'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:45:in `block in action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider.rb:121:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource.rb:648:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:49:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:81:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:81:in `each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:81:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection.rb:98:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection.rb:96:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:80:in `converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:345:in `converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:431:in `do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:213:in `block in run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:207:in `fork'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:207:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application.rb:236:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application/client.rb:338:in `block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application/client.rb:327:in `loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application/client.rb:327:in `run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application.rb:55:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/bin/chef-client:26:in `<top (required)>'
/opt/chef/bin/chef-client:23:in `load'
/opt/chef/bin/chef-client:23:in `<main>'

NameError: undefined local variable or method `chef_version'

Current chef-provisioning-docker version is not compatible with chef-provisioning v0.20 .

machine_image[test] (test-cookbook line 38) had an error: NameError: undefined local variable or method `chef_version' for #<Chef::Provisioning::ConvergenceStrategy::InstallCached:0x00000001447978>

Stacktrace:

NameError: machine_image[test] (test-cookbook line 38) had an error: NameError: undefined local variable or method `chef_version' for #<Chef::Provisioning::ConvergenceStrategy::InstallCached:0x00000001447978>
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-provisioning-0.20/lib/chef/provisioning/convergence_strategy/install_cached.rb:53:in `setup_convergence'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-provisioning-0.20/lib/chef/provisioning/machine/basic_machine.rb:17:in `setup_convergence'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-provisioning-0.20/lib/chef/provider/machine.rb:57:in `block in <class:Machine>'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:60:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:60:in `recipe_eval_with_update_check'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:45:in `block in action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-provisioning-0.20/lib/chef/provider/machine_image.rb:60:in `create_image'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-provisioning-0.20/lib/chef/provider/machine_image.rb:35:in `block in <class:MachineImage>'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:138:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:138:in `block in action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider.rb:125:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource.rb:648:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:49:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:81:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:81:in `each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:81:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection.rb:98:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection.rb:96:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:80:in `converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:345:in `converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:431:in `do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:213:in `block in run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:207:in `fork'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:207:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application.rb:236:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application/client.rb:338:in `block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application/client.rb:327:in `loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application/client.rb:327:in `run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application.rb:55:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/bin/chef-client:26:in `<top (required)>'
/opt/chef/bin/chef-client:23:in `load'
/opt/chef/bin/chef-client:23:in `<main>'

OpenSSL::SSL::SSLError:

While running the default recipe in my dev environment I run into the chef error listed below. This error is because I am using a untrusted cert with the chef server. I am attempting to pass the ":ssl_verify_mode => 'verify_none'" to the knife.rb file of the docker container. I believe I am doing this correctly, so this could be a bug. However, It could be something I miss configuration.

Recipe I am using

require "chef/provisioning/docker_driver"
with_driver "docker"

machine 'Workstation' do
    recipe 'chef-dk::default'

    machine_options :docker_options => {
      :base_image => {
          :name => 'ubuntu',
          :repository => 'ubuntu',
          :tag => '14.04'
      }
    },
    :convergenc_options => {
      :ssl_verify_mode => 'verify_none'
    }
end

Error I am getting

================================================================================
    Error executing action `converge` on resource 'machine[Workstation]'
    ================================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of docker run --name Workstation 702a3a1b8f2a92896f5a84381c3958c7fcee10840650ad67dec8e14fdc8b0bf2 chef-client -l info ----
    STDOUT: [2015-04-30T01:23:54+00:00] INFO: Forking chef instance to converge...
    [2015-04-30T01:23:54+00:00] INFO: *** Chef 12.3.0 ***
    [2015-04-30T01:23:54+00:00] INFO: Chef-client pid: 10
    [2015-04-30T01:23:55+00:00] ERROR: SSL Validation failure connecting to host: docker-01 - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

    ================================================================================
    Chef encountered an error attempting to load the node data for "Workstation"
    ================================================================================

    Unexpected Error:
    -----------------
    OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

    [2015-04-30T01:23:55+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
    [2015-04-30T01:23:55+00:00] ERROR: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
    [2015-04-30T01:23:55+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
    STDERR:
    ---- End output of docker run --name Workstation 702a3a1b8f2a92896f5a84381c3958c7fcee10840650ad67dec8e14fdc8b0bf2 chef-client -l info ----
    Ran docker run --name Workstation 702a3a1b8f2a92896f5a84381c3958c7fcee10840650ad67dec8e14fdc8b0bf2 chef-client -l info returned 1

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/Chef-Provisioner-Docker-Cookbook/recipes/workstation.rb

     11: machine 'Workstation' do
     12:     recipe 'chef-dk::default'
     13:
     14:     machine_options :docker_options => {
     15:       :base_image => {
     16:           :name => 'ubuntu',
     17:           :repository => 'ubuntu',
     18:           :tag => '14.04'
     19:       }
     20:     },
     21:     :convergenc_options => {
     22:       :ssl_verify_mode => 'verify_none'
     23:     }
     24: end

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/Chef-Provisioner-Docker-Cookbook/recipes/workstation.rb:11:in `from_file'

    machine("Workstation") do
      action :converge
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      chef_server {:chef_server_url=>"https://docker-01/organizations/marcusbeach", :options=>{:client_name=>"docker-01", :signing_key_filename=>"/etc/chef/client.pem"}}
      driver "docker"
      machine_options {:docker_options=>{:base_image=>{:name=>"ubuntu", :repository=>"ubuntu", :tag=>"14.04"}}, :convergenc_options=>{:ssl_verify_mode=>"verify_none"}}
      declared_type :machine
      cookbook_name "Chef-Provisioner-Docker-Cookbook"
      recipe_name "workstation"
      run_list_modifiers [#<Chef::RunList::RunListItem:0x00000004c71c90 @version=nil, @type=:recipe, @name="chef-dk::default">]
    end

[2015-04-29T21:23:55-04:00] INFO: Running queued delayed notifications before re-raising exception

Running handlers:
[2015-04-29T21:23:55-04:00] ERROR: Running exception handlers
Running handlers complete
[2015-04-29T21:23:55-04:00] ERROR: Exception handlers complete
[2015-04-29T21:23:55-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 1 resources updated in 13.763251552 seconds
[2015-04-29T21:23:56-04:00] ERROR: machine[Workstation] (Chef-Provisioner-Docker-Cookbook::workstation line 11) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of docker run --name Workstation 702a3a1b8f2a92896f5a84381c3958c7fcee10840650ad67dec8e14fdc8b0bf2 chef-client -l info ----
STDOUT: [2015-04-30T01:23:54+00:00] INFO: Forking chef instance to converge...
[2015-04-30T01:23:54+00:00] INFO: *** Chef 12.3.0 ***
[2015-04-30T01:23:54+00:00] INFO: Chef-client pid: 10
[2015-04-30T01:23:55+00:00] ERROR: SSL Validation failure connecting to host: docker-01 - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

================================================================================
Chef encountered an error attempting to load the node data for "Workstation"
================================================================================

Unexpected Error:
-----------------
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

[2015-04-30T01:23:55+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-04-30T01:23:55+00:00] ERROR: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
[2015-04-30T01:23:55+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
STDERR:
---- End output of docker run --name Workstation 702a3a1b8f2a92896f5a84381c3958c7fcee10840650ad67dec8e14fdc8b0bf2 chef-client -l info ----
Ran docker run --name Workstation 702a3a1b8f2a92896f5a84381c3958c7fcee10840650ad67dec8e14fdc8b0bf2 chef-client -l info returned 1
[2015-04-29T21:23:56-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

provisioning docker with chef-provisioning fails with "no such id"

0
down vote
favorite
I am trying to provision my docker image using chef. I run the following.

knife cookbook site install apt -z
knife cookbook site install haproxy -z
knife cookbook site install tomcat -z
knife cookbook site install postgresql -z
export CHEF_DRIVER=docker
chef-client -z ~/deploy-environment.rb

My deploy-environment.rb file looks as follows

# Deploy a database server, two app servers, and a load balancer
require 'chef/provisioning/docker_driver'

# global variables
chef_env = '_default'
domain = 'myapp.local'
subdomain = "#{chef_env}.#{domain}"

# Dev/Non-Prod instance count
num_appservers = 2
num_dbservers = 1

# Conditional deployment
if chef_env.eql?("production")
  num_appservers = 3
  num_dbservers = 2
end

# DB server(s)
# Standby DB could be configured as such after finding online Active node
# One method would be to add to a recipe search(:node, 'recipes:"postgresql::server"')
1.upto(num_dbservers) do |i|
  machine "db#{i}.#{domain}" do
    recipe 'apt::default' # Update local apt database
    recipe 'postgresql::server'
    chef_environment chef_env
      machine_options :docker_options => {
        :base_image => {
          :name => 'ubuntu',
          :repository => 'ubuntu',
          :tag => '14.04'
        },
        :command => 'service postgresql start'
      }
  end
end

# Launch Application servers in parallel
machine_batch do
  1.upto(num_appservers) do |i|
    machine "app#{i}.#{domain}" do
      recipe 'apt::default' # Update local apt database
      recipe 'tomcat'
      chef_environment chef_env
      attribute 'tomcat', { 'base_version' => 7 } # sets node['tomcat']['base_version']
      attribute 'java', { 'java_home' => '/usr/lib/jvm/java-1.7.0-openjdk-amd64' } # sets node['java']['java_home']
      machine_options :docker_options => {
        :base_image => {
        :name => 'ubuntu',
        :repository => 'ubuntu',
        :tag => '14.04'
        },
        :command => 'service tomcat7 start'
      }
    end
  end
end

# Load balancer
machine "lb1.#{domain}" do
  recipe 'haproxy'
  chef_environment chef_env
  machine_options :docker_options => {
      :base_image => {
      :name => 'ubuntu',
      :repository => 'ubuntu',
      :tag => '14.04'
    },
    :command => 'service haproxy start'
  }
end

However I get this when I run chef-client

ERROR: machine[wario] (@recipe_files::/Users/asattar/Dev/projects/chef-repo/deploy-environment-4.rb line 3) had an error: Docker::Error::NotFoundError: no such id: a3ed95caeb02

Containers get created in a stopped state.

Containers get created in a stopped state. Starting them just returns them to a stopped state.

require 'chef/provisioning/docker_driver'

with_chef_server "http://some.address.com:8889"

machine 'mario' do
  recipe 'nginx'

  machine_options :docker_options => {
    :base_image => {
      :name => 'ubuntu',
      :repository => 'ubuntu',
      :tag => '14.04'
    },
    :detached => true
  }
end

I have tried adding a :command like tail -f /etc/lsb-release, but to no avail.

container will not stay running

Using provisioning to build a container with docker machine using the following recipe.

#
# Cookbook Name:: tomcat_cluster
# Recipe:: default
#
# Copyright (c) 2015 The Authors, All Rights Reserved.
require 'chef/provisioning/docker_driver'
chef_env = '_default'
domain = 'myapp.local'
subdomain = "#{chef_env}.#{domain}"
num_appservers = 2
version = 7

machine "app.#{domain}" do
    driver 'docker'
    recipe 'apt::default' # Update local apt database
    recipe 'tomcat'
    chef_environment chef_env
    attribute 'tomcat', { 'base_version' => version } # sets node['tomcat']['base_version']
    attribute 'java', {
        'install_flavor' => 'openjdk',
        'jdk_version' => "#{version}",
        'java_home' => '/usr/lib/java/'
    }
    machine_options :docker_options => {
            :base_image => {
            :name => 'ubuntu',
            :repository => 'ubuntu',
            :tag => '14.04'
        },
        #:command => 'service tomcat7 start', 
        :env => {
            "HTTP_PROXY" => 'http://proxy:80', 
            "HTTPS_PROXY" =>  'http://proxy:80',
            "NO_PROXY" => 'localhost, 127.0.0.1', 
        },
        :command => "tail -f /var/log/tomcat#{version}/catalina.out",
        :ports => 8080
    },
    :convergence_options => {
        :ssl_verify_mode => 'verify_none'
    }
end

The container will not stay up. It does not appear that the command from the machine build is ever run. It appears that the chef-client runs and as soon as that happens the container stops.

Environment Vars

Im having this issue, where the ENV vars declared before running the resource, are not taking into account when the command is excecuted.

Here is the recipe

ENV['URL']="https://www.testurl.com"

machine actual do
  machine_options :docker_options => {
      :base_image => {
          :name => 'matiasdecarli/release',
          :repository => 'matiasdecarli',
          :tag => 'latest'
      },
      :command => '/usr/bin/node /matiasdecarli/app.js',
      :ports => port.to_s + ':8080',
      :keep_stdin_open => true
  }
end

The error that I get is the app crashing when trying to start because URL being undefined. I can see a posible solution (https://docs.docker.com/reference/run/#env-environment-variables), having the option to pass an array with env vars

Chef::Exceptions::ContentLengthMismatch: Response body length 8006 does not match HTTP Content-Length header 12829

The below error appears when using the chef-provisioning-docker driver for providing a machine that need to sync cookbook with chef-zero (chef-client -z ...)

Chef::Exceptions::ContentLengthMismatch: Response body length 8006 does not match HTTP Content-Length header 12829

There already is an issue opened in chef-zero, (chef/chef-zero#126) but it might be related to chef-provisioning-docker, as with the same cookbooks and recipes, it works for other drivers (ie. vagrant)

ERROR: machine_batch[default] (@recipe_files::/root/workdir/kafka-cluster.rb line 64) had an error: Errno::ENOENT: No such file or directory @ rb_sysopen - proc/10110/root/etc/chef/client.pem

Hi, I'm having this error when trying to run chef-provisioning-docker from within docker (which is actually quite useful to get a reproducible self-contained chef environment and allows to run multiple chef-provisioning on different drivers in parallel ).
I don't know the cause of this behaviour, all that I know is that write_file method in
/lib/chef/provisioning/docker_driver/docker_transport.rb
determins the pem path from container_path() method, which in turn, does:

    def container_path(path)
      File.join('proc', container.info['State']['Pid'].to_s, 'root', path)
    end

My quick and dirty bypass is to force the containing directory creation:

    def write_file(path, content)
      require "file_utils"
      mkdir_p File.dirname(container_path(path))
      File.open(container_path(path), 'w') { |file| file.write(content) }
    end

I'm guessing that the fact that I'm in a container changes the way the driver behaves, what do you think ?
If you think this bypass is acceptable, I can submit a PR.

docker log-driver

Wondering how to set the log-driver for the container.

want this (docker inspect):

"LogConfig": {
            "Type": "syslog",
            "Config": {
                "syslog-address": "udp://10.0.10.19:35514",
                "syslog-facility": "local0"
            }
        },

always get this after a chef provision

"LogConfig": {
            "Type": "json-file",
            "Config": {
            }
        },

recipe:

require 'chef/provisioning'
require 'chef/provisioning/docker_driver'

with_driver 'docker'

with_machine_options({
  convergence_options: {
     ssl_verify_mode: :verify_none
  },
  docker_options: {
    base_image: {
     :name => 'centos',
     :repository => 'centos',
     :tag => 'latest'
    },
    logconfig: {
      :type => "syslog",
      config: {
        :syslog_address => 'udp://10.0.10.19:32512',
        :syslog_facility => 'local0'
      }
    },
    :ports => ["5060:5060","5060:5060/udp","10000-10009:10000-10009/udp","5038:5038","8088:8088","8089:8089"],
    :command => 'asterisk -v'
  }
})

Monkey patch EventOutputStream

As much as I dont think this is a great idea. Unless its planned to merge chef/chef#2100 soon, seems like this would be a reasonable temporary workaround. Otherwise one is left flying blind during convergence. For example the couchbase cookbook waits for its port to respond and can hang quite a while and one is left wondering, "is it still downloading the couch package or is it hanging on the port"?

when using from_image at machine, converge without specified attritbue

Here is simple chef-provisioning-docker recipe.

require 'chef/provisioning'

nginx_config = {
  'nginx' => {
    'port' => 8080,
    'user' => 'www-data',
    'group' => 'www-data',
  }
}

machine_image 'nginx_base' do
  recipe 'nginx::package'
  attributes nginx_config

  machine_options :docker_options => {
    :base_image => {
      :name       => 'ubuntu',
      :repository => 'ubuntu',
      :tag        => '14.04'
    }
  }
end

machine 'nginx_server' do
  from_image 'nginx_base'

  attribute %w[ nginx port ], 8888
  attribute %w[ nginx user ], 'root'
  attribute %w[ nginx group ], nil

  machine_options :docker_options => {
    :command => '/usr/sbin/nginx -g "daemon off;"'
  }
end

nginx_base image has below attributes:

  • node['nginx']['port'] = 8080
  • node['nginx']['user'] = 'www-data'
  • node['nging']['group'] = 'www-data'

nginx_server container replaces them with below attributes (I assume):

  • node['nginx']['port'] = 8888
  • node['nginx']['user'] = 'root'
  • node['nging']['group'] = nil

After converging above recipe, nginx_server container has replaced attributes:

vagrant@vagrant:~/docker$ head nodes/nginx_server.json 
{
  "name": "nginx_server",
  "normal": {
    "tags": null,
    "nginx": {
      "port": 8888,
      "user": "root",
      "group": null
    },
    "chef_provisioning": {
vagrant@vagrant:~/docker$ 

But template has original attributes:

vagrant@vagrant:~/docker$ docker exec a216e6f0301f cat /etc/nginx/sites-enabled/default
server {
  listen   8080;
  server_name  4bbb91bca063;

  access_log  /var/log/nginx/localhost.access.log;

  location / {
    root   /var/www/nginx-default;
    index  index.html index.htm;
  }
}
vagrant@vagrant:~/docker$

Is it bug or my misunderstanding how to use attribute?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.