Coder Social home page Coder Social logo

chef-zero's Introduction

Chef Zero

Build status Gem Version

Description

Chef Zero is a simple, easy-install, in-memory Chef server that can be useful for Chef Client testing and chef-solo-like tasks that require a full Chef Server. It IS intended to be simple, Chef 11+ compliant, easy to run and fast to start. It is NOT intended to be secure, scalable, performant or persistent. It does NO input validation, authentication or authorization (it will not throw a 400, 401 or 403). It does not save data, and will start up empty each time you start it.

Because Chef Zero runs in memory, it's super fast and lightweight. This makes it perfect for testing against a "real" Chef Server without mocking the entire Internet.

Installation

This server can be installed as a Ruby Gem.

$ gem install chef-zero

If you're using bundler, add chef-zero as a development dependency:

group :development do
  gem 'chef-zero'
end

Or in a .gemspec

s.add_development_dependency 'chef-zero'

You can also clone the source repository and install it using rake install.

Usage

One of chef-zero's primary uses is as a small test server for people writing and testing clients. Here's a simple example of starting it up:

require 'chef_zero/server'
server = ChefZero::Server.new(port: 4000)
server.start

This will create a server instance in the foreground. To stop the server:

server.stop

This is great for debugging and logging requests, but you'll probably want to run this in the background so you have full control of your thread.

To run Chef Zero in the background, simply issue the start_background command:

require 'chef_zero/server'
server = ChefZero::Server.new(port: 4000)
server.start_background

You can stop the server the same way:

server.stop

Valid Options

You may currently pass the following options to the initializer:

  • host - the host to run on (Default: '127.0.0.1')
  • port - the port to run on (Default: 8889)
  • debug - run in debug mode to see all requests and responses (Default: false)

CLI (Command Line)

If you don't want to use Chef Zero as a library, you can simply start an instance with the included chef-zero executable:

$ chef-zero

Note, this will run in the foreground.

You now have a fully functional (empty) Chef Server running.

To try it out, go into the chef-zero/playground directory and run knife. It will behave the same as a normal Chef Server, and all normal knife commands will work (show, list, delete, from file, upload, download, diff ...). For example, with +knife-essentials+ (or Chef 11) you can upload everything in the repo:

chef-zero/playground> knife upload .
Created nodes/desktop.json
Created data_bags/dns
Created environments/production.json
Created nodes/lb.json
Created nodes/dns.json
Created nodes/ldap.json
Created nodes/www.json
Created data_bags/dns/services.json
Created environments/staging.json
Created data_bags/passwords
Created data_bags/users
Created data_bags/users/jkeiser.json
Created data_bags/passwords/github.json
Created data_bags/passwords/twitter.json
Created data_bags/users/schisamo.json
Created data_bags/users/sethvargo.json
Created cookbooks/apache2
Created cookbooks/php

chef-zero/playground> knife environment list
_default
production
staging

To use it in your own repository, create a knife.rb like so:

chef_server_url   'http://127.0.0.1:8889'
node_name         'stickywicket'
client_key        'path_to_any_pem_file.pem'

And use knife like you normally would.

Since Chef Zero does no authentication, any .pem file will do. The client just needs something to sign requests with (which will be ignored on the server). Even though it's ignored, the .pem must still be a valid format.

Now, stop the Chef Zero server and all the data is gone!

Run chef-zero --help to see a list of the supported flags and options:

Usage: chef-zero [ARGS]
    -H, --host HOST                  Host to bind to (default: 127.0.0.1)
    -p, --port PORT                  Port to listen on (e.g. 8889, or 8500-8600 or 8885,8888)
        --[no-]generate-keys         Whether to generate actual keys or fake it (faster).  Default: false.
    -d, --daemon                     Run as a daemon process
    -l, --log-level LEVEL            Set the output log level
        --log-file FILE              Log to a file
        --enterprise                 Whether to run in enterprise mode
        --multi-org                  Whether to run in multi-org mode
        --file-store PATH            Persist data to files at the given path
        --[no-]ssl                   Use SSL with self-signed certificate(Auto generate before every run).  Default: false.
    -h, --help                       Show this message
        --version                    Show version

Contributing

For information on contributing to this project see https://github.com/chef/chef/blob/master/CONTRIBUTING.md

License

Copyright:: Chef Software, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

chef-zero's People

Contributors

chef-ci avatar dafyddcrosby avatar danielsdeleo avatar jashaik avatar jayashrig158 avatar jaymzh avatar jkeiser avatar jrunning avatar juliandunn avatar lamont-granquist avatar marcparadise avatar mattgleeson avatar prajaktapurohit avatar randomcamel avatar reset avatar sawanoboly avatar scottopherson avatar sethvargo avatar skeshari12 avatar srenatus avatar stevendanna avatar tas50 avatar tduffield avatar terceiro avatar thommay avatar tpowell-progress avatar tyler-ball avatar tylercloke avatar vinay-satish avatar waffle-iron 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chef-zero's Issues

Errno::ENAMETOOLONG

Running test-kitchen for ossec cookbook and come across this error. It's issued during the chef-client run, which leads my to believe it's something with chef-zero. Could me wrong tho.

Stacktrace:

[2014-01-22T17:17:27+00:00] DEBUG: HTTP 1.1 500 Internal Server Error
       [2014-01-22T17:17:27+00:00] DEBUG: content-type: text/plain
       [2014-01-22T17:17:27+00:00] DEBUG: server: chef-zero

       [2014-01-22T17:17:27+00:00] DEBUG: connection: close
       [2014-01-22T17:17:27+00:00] DEBUG: content-length: 13481
       [2014-01-22T17:17:27+00:00] DEBUG: ---- End HTTP Status/Header Data ----

       [2014-01-22T17:17:27+00:00] DEBUG: Expected JSON response, but got content-type 'text/plain'
       [2014-01-22T17:17:27+00:00] INFO: HTTP Request Returned 500 Internal Server Error:


       ================================================================================
       Error Resolving Cookbooks for Run List:
       ================================================================================


       Unknown Server Error:
       ---------------------
       The server had a fatal error attempting to load the node data.



       Server Response:
       ----------------
       Exception raised!  #<Errno::ENAMETOOLONG: File name too long - {"name":"ossec","description":"Installs/Configures ossec","long_description":"Description\n====\n\nInstalls OSSEC from source in a server-agent installation. See:\n\nhttp://www.ossec.net/main/manual/manual-installation/\n\nRequirements\n====\n\nTested on Ubunt
.....
.....
.....

Template filenames with metacharacters throw URI::InvalidURIError

We have a cookbook around our ldap installation, and some of those files have some URI metacharacters. This throws an exception when they're used against chef-zero (run in test-kitchen, but looking at the source, test-kitchen is not formulating the URIs):

      URI::InvalidURIError
           --------------------
           bad URI(is not URI?): http://localhost:8889/file_store/repo/cookbooks/local-ldap/templates/default/slapd.d/cn=config/olcDatabase={0}config.ldif


       Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/local-ldap/recipes/default.rb


            93:   template "/etc/ldap/slapd.d/cn=config/#{f}.ldif" do
            94:     source "slapd.d/cn=config/#{f}.ldif"
            95:     owner node['ldap']['user']
            96:     group node['ldap']['user']

        97:     mode 00640
            98:     variables :olc_root_pw => vault_info[:olc_root_pw]
            99:   end
           100: end

The file in question definitely exists in the template directory and is getting loaded into /tmp/kitchen/cache/. It also works fine on against a chef-server.

Data bag search of the form "x:y AND NOT z:w" fails

The Opscode users cookbook does a data bag search against the users data bag for "groups:sysadmin AND NOT action:remove". This search fails to find any users on chef-zero.

Reproduce by starting a chef-zero on 127.0.0.1:8889 and doing a knife search:

$ cat knife.rb
node_name                "markcornick"
client_key               "/Users/mcornick/.chef/markcornick.pem"
chef_server_url          "http://127.0.0.1:8889"
$ cat mark.json
{
  "groups": [ "sysadmin" ],
  "comment": "Mark Cornick",
  "id": "mark",
  "shell": "/bin/bash"
}
$ knife data bag create users -c knife.rb
Created data_bag[users]
$ knife data bag from file users mark.json -c knife.rb
Updated data_bag_item[users::mark]
$ knife search users 'groups:sysadmin' -c knife.rb
1 items found

chef_type: data_bag_item
comment:   Mark Cornick
data_bag:  users
groups:    sysadmin
id:        mark
shell:     /bin/bash

$ knife search users 'groups:sysadmin AND NOT action:remove' -c knife.rb
0 items found

The issue does not seem to be that the "action" key doesn't exist, because the same issue also manifests if we use a key that does exist:

$ knife search users 'groups:sysadmin AND NOT comment:shazbot' -c knife.rb
0 items found

DataBagItemEndpoint is missing a delete method

When calling destroy on a data_bag_item against Chef-Zero you get a 404. That's because DataBagItemEndpoint doesn't implement a delete method the way that DataBagEndpoint does.

example:

item = data_bag_item('ebs_volumes_db', 'ip-standalone.centos.aws') # works
item.destroy # fails with error:
# HTTP Request Returned 404 Not Found : Object not found: http://localhost:8889/data/ebs_volumes_db/data_bag_item_ebs_volumes_db_ip-standalone.centos.aws

How to handle changing url of ChefZero during chef-client run

I'm running into an issue where my Chef run changes the chef-client config during the chef run (see chef-boneyard/chef-client#117). After this change, my cookbooks can no longer connect to ChefZero:

ERROR: Connection refused connecting to https://chef.local.mydomain.com/nodes/server-debian-74, retry 1/5       
ERROR: Connection refused connecting to https://chef.local.mydomain.com/nodes/server-debian-74, retry 2/5       
ERROR: Connection refused connecting to https://chef.local.mydomain.com/nodes/server-debian-74, retry 3/5       
ERROR: Connection refused connecting to https://chef.local.mydomain.com/nodes/server-debian-74, retry 4/5       
ERROR: Connection refused connecting to https://chef.local.mydomain.com/nodes/server-debian-74, retry 5/5       

To handle test environments, I add a conditional resource to my chef run that adds the new chef-server domain to the /etc/hosts file like this:

$ cat /etc/hosts
127.0.0.1 localhost chef.local.mydomain.com

However, this only works on any subsequent runs, not during the initial run where the chef-config is updated mid-run, because ChefZero already started using the original client.rb configs.

I suspect this is due to the fact that ChefZero only listens to a specific url+port, instead of globally listening on any url + port (ie 0.0.0.0:8889). Listening on every ip is probably not the best idea (and seems to be unsupported in test-kitchen anyway), but is there any other option you can think of to solve this issue?

chef-zero not copying data_bags into cache

This looks pretty similar to #56 , except my files are named correctly.

I have the following folder structure

$ cd var/chef/cookbooks/zero && find .

./metadata.rb
./README.md
./attributes
./CHANGELOG.md
./data_bags
./data_bags/zero
./data_bags/zero/fluff.json
./recipes
./recipes/default.rb

And my default recipe looks like:

$ cat recipes/default.rb

a = search(:node, "*:*")
b = data_bag_item("zero", "fluff")

file "/tmp/zerofiles" do
  content a[0].to_s
end

file "/tmp/fluff" do
  content b.to_s
end

But when I run chef-client -z -o zero I get the following error:

[2014-08-01T22:11:35-04:00] WARN: No config file found or specified on command line, using command line options.
Starting Chef Client, version 11.14.0.rc.2
[2014-08-01T22:11:36-04:00] WARN: Run List override has been provided.
[2014-08-01T22:11:36-04:00] WARN: Original Run List: []
[2014-08-01T22:11:36-04:00] WARN: Overridden Run List: [recipe[zero]]
resolving cookbooks for run list: ["zero"]
Synchronizing Cookbooks:
  - zero
Compiling Cookbooks...
[2014-08-01T22:11:36-04:00] ERROR: Failed to load data bag item: "zero" "fluff"

================================================================================
Recipe Compile Error in /home/user/.chef/local-mode-cache/cache/cookbooks/zero/recipes/default.rb
================================================================================

Net::HTTPServerException
------------------------
404 "Not Found "

Cookbook Trace:
---------------
  /home/user/.chef/local-mode-cache/cache/cookbooks/zero/recipes/default.rb:2:in `from_file'

Relevant File Content:
----------------------
/home/user/.chef/local-mode-cache/cache/cookbooks/zero/recipes/default.rb:

  1:  a = search(:node, "*:*")
  2>> b = data_bag_item("zero", "fluff")
  3:  
  4:  file "/tmp/zerofiles" do
  5:    content a[0].to_s
  6:  end
  7:  
  8:  file "/tmp/fluff" do
  9:    content b.to_s
 10:  end
 11:  


Running handlers:
[2014-08-01T22:11:36-04:00] ERROR: Running exception handlers
Running handlers complete
[2014-08-01T22:11:36-04:00] ERROR: Exception handlers complete
[2014-08-01T22:11:36-04:00] FATAL: Stacktrace dumped to /home/user/.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 1.607884477 seconds
[2014-08-01T22:11:36-04:00] ERROR: 404 "Not Found "
[2014-08-01T22:11:36-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

I took a look at my chef-zero cache, and as a matter of fact, the data_bags folder was not copied over.

$ cd /home/user/.chef/local-mode-cache/cache/cookbooks/zero && find . 

./metadata.rb
./README.md
./CHANGELOG.md
./recipes
./recipes/default.rb

Am I missing something? Is there additional configuration required to tell chef-zero to copy over the data-bags?

$ chef-client --version 
Chef: 11.14.0.rc.2

Vagrant on windows fails to load Chef-Zero due to Chef dependencies

General info:
C:>vagrant -v
Vagrant 1.4.3

C:>vagrant plugin list
vagrant-berkshelf (1.3.7)
vagrant-chef-zero (0.6.0)
vagrant-omnibus (1.2.1)
vagrant-windows (1.5.1)

Error text:
INFO environment: Loading plugin from JSON: vagrant-chef-zero
ERROR root: Failed to load plugin: vagrant-chef-zero
ERROR root: -- Error: #<Gem::LoadError: Unable to activate chef-11.8.2-x86-mingw32, because ffi-1.9.3-x86-mingw32 conflicts with ffi (= 1.3.1)>
ERROR root: -- Backtrace:
ERROR root: C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/rubygems/specification.rb:2007:in `raise_if_conflicts'

Linked issue to vagrant plugin: schubergphilis/vagrant-chef-zero#37
Linked issue: https://tickets.opscode.com/browse/CHEF-4987

Searching for a node with an exact name fails

$ bundle exec knife search node 'name:yipit_prod_logstash_72f36501'
0 items found
$ bundle exec knife search node 'name:*yipit_prod_logstash_72f36501'
1 items found

Node Name:   yipit_prod_logstash_72f36501
Environment: production
FQDN:        yipit-prod-logstash-72f36501.ec2.internal
IP:          11.11.11.11
Run List:    role[logstash]
Roles:       logstash
Recipes:     yipit_foo::bar
Platform:    ubuntu 12.04
Tags:

Parsing metadata blows up on evaluating metadata.json.

In chef_zero/cookbook_data.rb when processing the metadata there is the following call:

metadata.from_json(read_file(directory, 'metadata.json'))

However, the from_json method expects a filepath but is being given json in this case.

def from_json(filepath)
  self.merge!(JSON.parse(File.read(filepath)))
end

This results in the from_json method throwing up because it is trying to read a path which is actually json data.

SSL support

I'm aware that chef-zero isn't meant to be secure, but we do use it for testing and would rather not send our cookbooks in clear. SSL support would be grand.

At the moment we do it all over SSH reverse tunnels (see taste-tester in github.com/facebook/chef-utils)

Not found returned for all roles

Currently running the 1.5.5 gem, and my roles are uploaded, but when in my run_list, a 404 Not Found is always returned. I've also tried using roles without a - in the name, but this had no effect:

Uploaded /var/folders/nf/zwnznxhj35n_143061ppg9rr0000gn/T/default-centos-64-sandbox-20130912-15374-1qapxn7/roles/spc-starter-controller.rb (389 bytes)
Uploaded /var/folders/nf/zwnznxhj35n_143061ppg9rr0000gn/T/default-centos-64-sandbox-20130912-15374-1qapxn7/roles/spc-starter-proxy.rb (255 bytes)
Uploaded /var/folders/nf/zwnznxhj35n_143061ppg9rr0000gn/T/default-centos-64-sandbox-20130912-15374-1qapxn7/roles/spc-starter-saio.rb (316 bytes)
Uploaded /var/folders/nf/zwnznxhj35n_143061ppg9rr0000gn/T/default-centos-64-sandbox-20130912-15374-1qapxn7/roles/spc-starter-storage.rb (261 bytes)
[2013-09-12T20:07:11+00:00] INFO: Starting Chef Zero server in background
[2013-09-12T20:07:11+00:00] INFO: Forking chef instance to converge...
Starting Chef Client, version 11.6.0
[2013-09-12T20:07:11+00:00] INFO: *** Chef 11.6.0 ***
Creating a new client identity for default-centos-64 using the validator key.
[2013-09-12T20:07:11+00:00] INFO: Client key /tmp/d20130912-3111-c3rjp7/client.pem is not present - registering
[2013-09-12T20:07:11+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: http://127.0.0.1:8889/nodes/default-centos-64
[2013-09-12T20:07:11+00:00] INFO: Setting the run_list to ["role[spc-starter-controller]"] from JSON
[2013-09-12T20:07:11+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: http://127.0.0.1:8889/roles/spc-starter-controller
[2013-09-12T20:07:11+00:00] ERROR: Role spc-starter-controller (included by 'top level') is in the runlist but does not exist. Skipping expand.

================================================================================
Error expanding the run_list:
================================================================================


Missing Role(s) in Run List:
----------------------------
* spc-starter-controller included by 'top level'


Original Run List
-----------------
* role[spc-starter-controller]


[2013-09-12T20:07:11+00:00] FATAL: Stacktrace dumped to /tmp/kitchen-chef-zero/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated
[2013-09-12T20:07:11+00:00] INFO: Shutting down Chef Zero server
[2013-09-12T20:07:11+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
[2013-09-12T20:07:11+00:00] INFO: Shutting down Chef Zero server

Searches for node `role:SOMESTRING` are returning nested attributes

I have an HAProxy cookbook that allows us to set up backends in an automated fashion. To do this, we specify a hash of roles that should be searched for, and automatically added to the load balancer on some port:

default[:haproxy][:backends] = [
  { :role => 'SOMEROLE', :port => '3250' },
  { :role => 'settings', :port => '80' }
]

However, SOMEROLE doesn't exist yet. At all. It's not mapped to any node, it doesn't exist on chef-zero, we haven't created it. We expect search to return no results for a search for it.

Searching the expanded runlist behaves as expected:

$ knife search node "roles:SOMEROLE"
0 items found

But searching for the non-expanded runlist (which happens to have a key collision with 'role' that's deep in a nested attribute) returns bad results:

$ knife search node "role:SOMEROLE"
1 items found

Node Name:  vagrant-ubuntu-precise
Environment: local
FQDN:        vagrant-ubuntu-precise
IP:          10.0.2.15
Run List:    role[base], role[haproxy-mid-tier]
Roles:      base, haproxy-mid-tier
Recipes:    [..snip..]
Platform:    ubuntu 12.04
Tags:

Clearly, this is bad. http://docs.opscode.com/essentials_search.html#nested-fields says that nested attributes are expanded to the top level (which is kind of a crazy idea, but I digress) but http://docs.opscode.com/essentials_search.html#roles-in-run-lists specifically says that role: and roles: have special behavior.

Searching is Broken

Ran in to some issues with trying to search for nodes. Heres a quick overview of my workflow:

  1. Get some node data, do this by using knife to download a production systems node data as JSON via knife.
  2. Start Chef-Zero on my local machine
  3. Dump the node data in to Chef-Zero using Ridley with r.node.create(JSON.parse(IO.read(node)).to_hash)
  4. Run Vagrant pointing at Chef Zero
  5. Run a simple search query against the node data.

Here is the debug output

[2013-06-04T18:28:14-04:00] DEBUG: GET search/node?q=name:yipit_prod_search2&sort=X_CHEF_id_CHEF_X asc&start=0&rows=1000
[2013-06-04T18:28:14-04:00] ERROR: #<TypeError: can't define singleton>
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/hashie-2.0.5/lib/hashie/extensions/deep_merge.rb:14:in `block in deep_merge!'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/hashie-2.0.5/lib/hashie/extensions/deep_merge.rb:13:in `each'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/hashie-2.0.5/lib/hashie/extensions/deep_merge.rb:13:in `deep_merge!'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/hashie-2.0.5/lib/hashie/extensions/deep_merge.rb:7:in `deep_merge'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/hashie-2.0.5/lib/hashie/extensions/deep_merge.rb:15:in `block in deep_merge!'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/hashie-2.0.5/lib/hashie/extensions/deep_merge.rb:13:in `each'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/hashie-2.0.5/lib/hashie/extensions/deep_merge.rb:13:in `deep_merge!'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/hashie-2.0.5/lib/hashie/extensions/deep_merge.rb:7:in `deep_merge'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/hashie-2.0.5/lib/hashie/extensions/deep_merge.rb:15:in `block in deep_merge!'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/hashie-2.0.5/lib/hashie/extensions/deep_merge.rb:13:in `each'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/hashie-2.0.5/lib/hashie/extensions/deep_merge.rb:13:in `deep_merge!'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/chef-zero-1.1.3/lib/chef_zero/endpoints/search_endpoint.rb:67:in `expand_for_indexing'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/chef-zero-1.1.3/lib/chef_zero/endpoints/search_endpoint.rb:110:in `block in search'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/chef-zero-1.1.3/lib/chef_zero/endpoints/search_endpoint.rb:107:in `each'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/chef-zero-1.1.3/lib/chef_zero/endpoints/search_endpoint.rb:107:in `search'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/chef-zero-1.1.3/lib/chef_zero/endpoints/search_endpoint.rb:13:in `get'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/chef-zero-1.1.3/lib/chef_zero/rest_base.rb:29:in `call'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/chef-zero-1.1.3/lib/chef_zero/rest_router.rb:23:in `call'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/chef-zero-1.1.3/lib/chef_zero/server.rb:274:in `block in make_app'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/puma-2.0.1/lib/puma/server.rb:364:in `call'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/puma-2.0.1/lib/puma/server.rb:364:in `handle_request'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/puma-2.0.1/lib/puma/server.rb:243:in `process_client'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/puma-2.0.1/lib/puma/server.rb:142:in `block in run'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/puma-2.0.1/lib/puma/thread_pool.rb:92:in `call'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/puma-2.0.1/lib/puma/thread_pool.rb:92:in `block in spawn_thread'

If it helps, I get this same problem if I do a search that would have no results. Chef-Zero will return a 500 instead of an empty set of results.

So far I watched it fail for node: and role: search on the /node endpoint

Wrong generated client keys with Ruby 1.9.2

Using ruby 1.9.2, the generated client keys are not valid. But seems to work OK with newer ruby versions.

The following #gen_key_pair code seems doesn't work properly with ruby 1.9.2. The generated public key is not valid.

An example of a wrong public key generated with ruby 1.9.2:

-----BEGIN PUBLIC KEY-----
MIIBCgKCAQEA60/Ia/Ts6YukWICm6K/nyKLZ8Y5phsm7Z31WGS9P5F34lZts92e6
gzpJfNtdxPYy83lqkCdoftpDjy7+f5dyKy9yOCxS65pcwQ0u1GarlgN2St7PClU+
T3aqzZmW4N69JB3/rNJCgTGPGAHgIctqFge0BV0+QRgQX+T6G/IHg2wG5Ivg+F05
F0QjELck+bZND0QF4Hb2jsCpjET470Sja9tQ3hHiq1eMo/cFNYgPy/6iQMSPVZfm
E76/0sYM2SqHLmli3ZdkG8HQoEJpWB3GlebrJv5cQ8xC/HG1a22JOGdOA8iJ/UA9
yGEAIVEPVUegshebkugtZxzYAZ6ZLViDXQIDAQAB
-----END PUBLIC KEY-----

Summarizing, the following code snippet doesn't work for ruby 1.9.2:

require 'openssl'
# This code from ChefZero::Server#gen_key_pair seems broken for Ruby 1.9.2
private_key = OpenSSL::PKey::RSA.new(2048)
public_key = private_key.public_key.to_s
public_key.sub!(/^-----BEGIN RSA PUBLIC KEY-----/, '-----BEGIN PUBLIC KEY-----')
public_key.sub!(/-----END RSA PUBLIC KEY-----(\s+)$/, '-----END PUBLIC KEY-----\1')
OpenSSL::PKey::RSA.new(public_key)

The generated public key is wrong. You can try to use the 1.9.2 generated key with newer ruby versions and the error is the same:

chef_zero_rsa_broken.rb:7:in `initialize': Neither PUB key nor PRIV key:: nested asn1 error (OpenSSL::PKey::RSAError)
        from chef_zero_rsa_broken.rb:7:in `new'
        from chef_zero_rsa_broken.rb:7:in `<main>'

Knife Search throwing error

When I run a knife search, ANY knife search it seems, I get back a stacktrace indicating TypeError: can't convert Fixnum into String throwing from `TypeError: can't convert Fixnum into String'

Adding a cast to `term[index].to_s' on line 32 fixes the error, but results in no results being returned from the search, even when there are valid results available.

You can reproduce the TypeError with the vagrantfile and knife.rb located here:
https://github.com/tejaycar/chef-zero/tree/master/chef-zero-test

Not loading roles

Not 100% sure which part of the stack to blame, but I think it's chef-zero. Running this via kitchen (which correctly copies everything to /tmp/kitchen in the Vagrant VM):

# sudo -E chef-client -z --config /tmp/kitchen/client.rb --json-attributes /tmp/kitchen/dna.json

/tmp/kitchen/client.rb has:

node_name "default-precise"
checksum_path "/tmp/kitchen/checksums"
file_cache_path "/tmp/kitchen/cache"
file_backup_path "/tmp/kitchen/backup"
cookbook_path ["/tmp/kitchen/cookbooks", "/tmp/kitchen/site-cookbooks"]
data_bag_path "/tmp/kitchen/data_bags"
environment_path "/tmp/kitchen/environments"
node_path "/tmp/kitchen/nodes"
role_path "/tmp/kitchen/roles"
client_path "/tmp/kitchen/clients"
user_path "/tmp/kitchen/users"
validation_key "/tmp/kitchen/validation.pem"
client_key "/tmp/kitchen/client.pem"
chef_server_url "http://127.0.0.1:8889"
encrypted_data_bag_secret "/tmp/kitchen/encrypted_data_bag_secret"
environment "development"

/tmp/kitchen/roles/db_master.json has:

{
"name": "db_master",
"description": "Mock DB endpoint",
"override_attributes": {
"internal_ip": "127.0.0.1"
},
"run_list": [
]
}

Running any role search (search(:role, '*:*')) or node search by role (search(:node, 'role:db_master') fails to find anything. I'm able to find other objects like data_bags and nodes.

Trying to trace the problem, where does load_data actually get called?

Cannot give a specific recipe from chef-client

Hello,
I've setup a chef-zero and it works well when I try to install a whole cookbook from my chef-client. But not if I try a specific recipe.

With a cookbook =>

precise64:~# chef-client -S http://192.168.1.67:8889 -o "recipe[apt]" -K /etc/chef/validation.pem -N lxc-vagr
[2013-04-28T12:31:31+00:00] WARN: *****************************************
[2013-04-28T12:31:31+00:00] WARN: Did not find config file: /etc/chef/client.rb, using command line options.
[2013-04-28T12:31:31+00:00] WARN: *****************************************
[2013-04-28T12:31:31+00:00] INFO: *** Chef 10.14.2 ***
[2013-04-28T12:31:31+00:00] WARN: Run List override has been provided.
[2013-04-28T12:31:31+00:00] WARN: Original Run List: []
[2013-04-28T12:31:31+00:00] WARN: Overridden Run List: [recipe[apt]]
[2013-04-28T12:31:31+00:00] INFO: Run List is [recipe[apt]]
[2013-04-28T12:31:31+00:00] INFO: Run List expands to [apt]
[2013-04-28T12:31:31+00:00] INFO: Starting Chef Run for lxc-vagr
[2013-04-28T12:31:31+00:00] INFO: Running start handlers
[2013-04-28T12:31:31+00:00] INFO: Start handlers complete.
[2013-04-28T12:31:31+00:00] INFO: Loading cookbooks [apt]
[2013-04-28T12:31:31+00:00] INFO: Processing execute[apt-get-update] action run (apt::default line 22)
[2013-04-28T12:31:31+00:00] INFO: Processing execute[apt-get update] action nothing (apt::default line 29)
[2013-04-28T12:31:31+00:00] INFO: Processing package[update-notifier-common] action install (apt::default line 36)
[2013-04-28T12:31:31+00:00] INFO: Processing execute[apt-get-update-periodic] action run (apt::default line 40)
[2013-04-28T12:31:31+00:00] INFO: Processing directory[/var/cache/local] action create (apt::default line 50)
[2013-04-28T12:31:31+00:00] INFO: Processing directory[/var/cache/local/preseeding] action create (apt::default line 50)
[2013-04-28T12:31:31+00:00] INFO: Chef Run complete in 0.063847 seconds
[2013-04-28T12:31:31+00:00] INFO: Running report handlers
[2013-04-28T12:31:31+00:00] INFO: Report handlers complete

With a recipe (the same than before because recipe[apt] == recipe[apt::default])

root@precise64:~# chef-client -S http://192.168.1.67:8889 -o "recipe[apt::default]" -K /etc/chef/validation.pem -N lxc-vagr
[2013-04-28T12:29:08+00:00] WARN: *****************************************
[2013-04-28T12:29:08+00:00] WARN: Did not find config file: /etc/chef/client.rb, using command line options.
[2013-04-28T12:29:08+00:00] WARN: *****************************************
[2013-04-28T12:29:08+00:00] INFO: *** Chef 10.14.2 ***
[2013-04-28T12:29:09+00:00] WARN: Run List override has been provided.
[2013-04-28T12:29:09+00:00] WARN: Original Run List: []
[2013-04-28T12:29:09+00:00] WARN: Overridden Run List: [recipe[apt::default]]
[2013-04-28T12:29:09+00:00] INFO: Run List is [recipe[apt::default]]
[2013-04-28T12:29:09+00:00] INFO: Run List expands to [apt::default]
[2013-04-28T12:29:09+00:00] INFO: Starting Chef Run for lxc-vagr
[2013-04-28T12:29:09+00:00] INFO: Running start handlers
[2013-04-28T12:29:09+00:00] INFO: Start handlers complete.
[2013-04-28T12:29:09+00:00] INFO: HTTP Request Returned 412 Precondition Failed: No such cookbook: apt::default

================================================================================
Error Resolving Cookbooks for Run List:
================================================================================

Missing Cookbooks:
------------------
No such cookbook: apt::default

Thanks again for chef-zero, it can help a lot to improve our tests.

chef-zero 404'ing on data bag items

I'm having a problem where chef-zero is 404'ing on an encrypted data bag in my recipe. I decided to try jtimberman's simple chef-zero example with a data bag (http://jtimberman.housepub.org/blog/2013/10/10/preview-chef-client-local-mode/), and even that is 404'ing when I try it. Is there something I'm doing wrong here?

# knife.rb
node_name                "kallen"
client_key               "/home/kallen/.chef/kallen.pem"
chef_server_url          "http://127.0.0.1:8889"
knife[:secret_file] = "/home/kallen/.chef/encrypted_data_bag_secret"
// data_bags/zero/fluff
{
  "id": "fluff",
  "clouds": "Are fluffy"
}
$ chef-client -v
Chef: 11.8.2
$ gem list chef-zero

*** LOCAL GEMS ***

chef-zero (2.0.2)
$ chef-client -z -o zero
Starting Chef Client, version 11.8.2
[2014-01-30T01:41:52+00:00] WARN: Run List override has been provided.
[2014-01-30T01:41:52+00:00] WARN: Original Run List: []
[2014-01-30T01:41:52+00:00] WARN: Overridden Run List: [recipe[zero]]
resolving cookbooks for run list: ["zero"]
Synchronizing Cookbooks:
  - zero
Compiling Cookbooks...
[2014-01-30T01:41:52+00:00] ERROR: Failed to load data bag item: "zero" "fluff"

================================================================================
Recipe Compile Error in /home/kallen/.chef/local-mode-cache/cache/cookbooks/zero/recipes/default.rb
================================================================================


Net::HTTPServerException
------------------------
404 "Not Found"


Cookbook Trace:
---------------
  /home/kallen/.chef/local-mode-cache/cache/cookbooks/zero/recipes/default.rb:2:in `from_file'


Relevant File Content:
----------------------
/home/kallen/.chef/local-mode-cache/cache/cookbooks/zero/recipes/default.rb:

  1:  a = search(:node, "*:*")
  2>> b = data_bag_item("zero", "fluff")
  3:
  4:  file "/tmp/zerofiles" do
  5:    content a[0].to_s
  6:  end
  7:
  8:  file "/tmp/fluff" do
  9:    content b.to_s
 10:  end
 11:

[2014-01-30T01:41:52+00:00] ERROR: Running exception handlers
[2014-01-30T01:41:52+00:00] ERROR: Exception handlers complete
[2014-01-30T01:41:52+00:00] FATAL: Stacktrace dumped to /home/kallen/.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated
[2014-01-30T01:41:52+00:00] ERROR: 404 "Not Found"
[2014-01-30T01:41:52+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

License missing from gemspec

Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec
via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

There is even a License Finder to help companies ensure all gems they use
meet their licensing needs. This tool depends on license information being available in the gemspec.
Including a license in your gemspec is a good practice, in any case.

How did I find you?

I'm using a script to collect stats on gems, originally looking for download data, but decided to collect licenses too,
and make issues for missing ones as a public service :)
https://gist.github.com/bf4/5952053#file-license_issue-rb-L13 So far it's going pretty well

Search strange behavior

Hello.
I have the following attributes in node:

"mongodb": {
          "package": "mongodb-10gen",
          "version": "2.4.8",
          "cluster_name": "default",
          "defaults": {
            "service": {
              "install_prefix": "/usr/local",
              "conf_dir": "etc",
              "log_dir": "log",
              "db_dir": "db",
              "config_filename": "config.conf",
              "ready_to_install": false
            },
            "opts": {
              "logpath": null,
              "dbpath": null,
              "pidfilepath": null,
              "logappend": true
            },
            "config": {
              "port": 27019,
              "configsvr": true
            },
            "router": {
              "port": 27018,
              "configdb": ""
            },
            "shard": {
              "arbiter": false,
              "shardsvr": true
            }
          },
          "configs": {
            "mongodb-cfg-1": {
              "install_prefix": "/usr/local",
              "conf_dir": "etc",
              "log_dir": "log",
              "db_dir": "db",
              "config_filename": "config.conf",
              "ready_to_install": true,
              "opts": {
                "logpath": "/usr/local/mongodb-cfg-1/log/mongodb-cfg-1.log",
                "dbpath": "/usr/local/mongodb-cfg-1/db",
                "pidfilepath": "/var/run/mongodb-cfg-1.pid",
                "logappend": true,
                "port": 29017,
                "configsvr": true,
                "smallfiles": true,
                "oplogSize": 512
              },
              "install_path": "/usr/local/mongodb-cfg-1"
            },
            "mongodb-cfg-2": {
              "install_prefix": "/usr/local",
              "conf_dir": "etc",
              "log_dir": "log",
              "db_dir": "db",
              "config_filename": "config.conf",
              "ready_to_install": true,
              "opts": {
                "logpath": "/usr/local/mongodb-cfg-2/log/mongodb-cfg-2.log",
                "dbpath": "/usr/local/mongodb-cfg-2/db",
                "pidfilepath": "/var/run/mongodb-cfg-2.pid",
                "logappend": true,
                "port": 31017,
                "configsvr": true,
                "smallfiles": true,
                "oplogSize": 512
              },
              "install_path": "/usr/local/mongodb-cfg-2"
            },
            "mongodb-cfg-3": {
              "install_prefix": "/usr/local",
              "conf_dir": "etc",
              "log_dir": "log",
              "db_dir": "db",
              "config_filename": "config.conf",
              "ready_to_install": true,
              "opts": {
                "logpath": "/usr/local/mongodb-cfg-3/log/mongodb-cfg-3.log",
                "dbpath": "/usr/local/mongodb-cfg-3/db",
                "pidfilepath": "/var/run/mongodb-cfg-3.pid",
                "logappend": true,
                "port": 33017,
                "configsvr": true,
                "smallfiles": true,
                "oplogSize": 512
              },
              "install_path": "/usr/local/mongodb-cfg-3"
            }
          },
          "search": {
            "shards": "chef_environment:_default AND mongodb_cluster_name:default AND mongodb_shards:*",
            "configs": "chef_environment:_default AND mongodb_cluster_name:default AND mongodb_configs:*",
            "routers": "chef_environment:_default AND mongodb_cluster_name:default AND mongodb_routers:*",
            "all": "chef_environment:_default AND mongodb_cluster_name:default AND NOT fqdn:mongodb-config"
          },
          "routers": {
            "mongos": {
              "install_prefix": "/usr/local",
              "conf_dir": "etc",
              "log_dir": "log",
              "db_dir": "db",
              "config_filename": "config.conf",
              "ready_to_install": true,
              "opts": {
                "logpath": "/usr/local/mongos/log/mongos.log",
                "dbpath": "/usr/local/mongos/db",
                "pidfilepath": "/var/run/mongos.pid",
                "logappend": true,
                "port": 27017,
                "configdb": "",
                "smallfiles": true,
                "oplogSize": 512
              },
              "install_path": "/usr/local/mongos"
            }
          }
        }

The search code:

hef > nodes = search :node, "mongodb_configs:*"
 => [] 
chef > nodes = search :node, "mongodb_configs*:*"
 => [node[mongodb-config]] 
chef > nodes = search :node, "mongodb_routers:*"
 => [] 
chef > nodes = search :node, "mongodb_routers*:*"
 => [node[mongodb-config]] 

Can't figure out why this doesn't work without asterisk. On real chef-server works
Chef Version: 11.4.4

Think it is bug. Also how to get more debug info from chef-zero. All what I have using -l debug is:

[2013-11-29T13:04:34+03:00] DEBUG: GET search/node?q=mongodb_routers:*&sort=X_CHEF_id_CHEF_X asc&start=0&rows=1000
[2013-11-29T13:04:34+03:00] DEBUG: 
--- RESPONSE (200) ---
{
  "rows": [

  ],
  "start": 0,
  "total": 0
}
--- END RESPONSE ---

Attribute and Template Overrides

I'm not sure if this is a chef-zero issue or in general how chef-server behaves.

I'm currently using chef-solo 11.10. There I can override templates that are used in recipes from the cookbooks directory by supplying them in site-cookbooks in the same path, e.g.

cookbooks/apache2/templates/default/apache.conf.erb
site-cookbooks/apache2/templates/default/apache.conf.erb

When I run chef-client in local mode against chef-zero, my template override is ignored and only the original in 'cookbooks' is loaded. The same applies to attribute files.

As it works in chef-solo I'm not sure if this is how it is supposed to work or a bug in my client.rb or even chef-zero?

Thanks!

knife plugin?

Would you be interested in patches that add a knife plugin to this?

Thinking of using this for chef-workflow. Thanks for making it!

search query fails when using parenthesis

Hey guys,

I have a search query that uses parenthesis and it fails in the same way as the range query. I'll An example:

knife search node 'role:base AND datacenter_domain:local AND NOT role:MONITORING_DISABLED'
ERROR: Server returned error for http://192.168.33.1:4000/search/node?q=role%253Abase%2520AND%2520datacenter_domain%253Alocal%2520AND%2520NOT%2520role%253AMONITORING_DISABLED&sort=&start=0&rows=1000, retrying 1/5 in 4s

HTTP 500 Returned when Accept Header isn't set.

If an incoming HTTP request doesn't have the Accept header set, the server returns an HTTP 500 error:

> curl -H "Accept:" "http://localhost:8889/nodes"
Exception raised!  #<NoMethodError: undefined method `split' for nil:NilClass>
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/chef-zero-0.9.7/lib/chef_zero/rest_base.rb:24:in `call'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/chef-zero-0.9.7/lib/chef_zero/rest_router.rb:21:in `block in call'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/chef-zero-0.9.7/lib/chef_zero/rest_router.rb:19:in `each'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/chef-zero-0.9.7/lib/chef_zero/rest_router.rb:19:in `call'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/chef-zero-0.9.7/lib/chef_zero/server.rb:257:in `block in make_app'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:81:in `call'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:81:in `block in pre_process'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:79:in `catch'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:79:in `pre_process'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:54:in `process'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:39:in `receive_data'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:199:in `run_machine'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:199:in `run'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/backends/base.rb:63:in `start'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/server.rb:159:in `start'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/chef-zero-0.9.7/lib/chef_zero/server.rb:81:in `start'
/Users/sdanna/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/chef-zero-0.9.7/bin/chef-zero:40:in `<top (required)>'
/Users/sdanna/.rbenv/versions/1.9.3-p392/bin/chef-zero:23:in `load'

According to RFC2616 the server should assume it can send content in this case:

If no Accept header field is present, then it is assumed that the client accepts all media types. If an Accept header field is present, and if the server cannot send a response which is acceptable according to the combined Accept field value, then the server SHOULD send a 406 (not acceptable) response.

However, ultimately chef-zero should do whatever Chef Server does in this situation. I'll follow up with whatever the Chef Server behavior is.

Allow seeding of Data

It would be nice to have a way to seed data into Chef Zero on startup. As it stands now I have to run through a bunch of hoops to upload everything to the server before running Vagrant.

Perhaps a config file or command line option to pass directories for

databags/
environments/
cookbooks/
roles/

Issue with

When I use a role to define a run_list specific for an environment and pin the cookbook version, I get the following error when I execute chef-client

DEBUG: Sending HTTP Request via POST to 10.10.10.2:4000/environments/environment01/cookbook_versions
INFO: HTTP Request Returned 412 Precondition Failed: No such cookbook: cookbookName::recipeName

This seems to happen if we have a role specifying the version of the cookbook for an environment. For example:

** RECIPE COMMANDS **
{
  "name": "roleName",
  "json_class": "Chef::Role",
  "env_run_lists": {
    "environment01": [
      "recipe[cookbookName::[email protected]]"
    ],
    "environment02": [
       "recipe[cookbookName::[email protected]]"
  ],
  },
  "run_list": [ ],
  "description": "role applied to nodes",
  "chef_type": "role",
  "override_attributes": {
  }
}

This issue went away when we would change

"recipe[cookbookName::[email protected]]"

to

"recipe[cookbookName::recipeName]"

Please let me know if you need more information.

bug in chef zero search query involving multiple attributes and attribute presence check

Hi,

there seem to be some inconsistency between chef server and chef zero on queries involving multiple nested attributes and attribute presence check...

on enterprise chef server:

  • knife search node "languages_ruby:*" -i -> return all nodes that have "ruby" attribute under "languages"

on chef zero (included in chef client 11.12.8, as test-kitchen provisioner):

  • knife search node "languages_ruby:*" -i -z -> return 0 node
  • however, this following query works on chef-zero: knife search node "languages_ruby_version:*" -i -z -> return 1 node

It seems does this bug apply only in node attributes (opposite to "leaf" attributes) in chef zero ? or maybe I miss something on query semantic ...

nicolas farges
GE Capital

data_bag_item fails in definition block executions

I have a simple ruby_app definition in my cookbook that uses a template that a recipe calls.

I noticed that if in a ruby_app 'appname' do block I make a data_bag_item('bag', 'item') call, it returns a two element array containing bag and item. If I have the data_bag_item call outside my ruby_app block, data_bag_item works fine.

This behavior is easily fixed but I found it quite peculiar. I'm using this with Vagrant but I don't think it's a vagrant issue.

chef-zero does not validate the format of cookbook directory names when using versioned cookbooks mode

I had previously uploaded some cookbooks to my chef-zero repo with zero in single cookbook version mode and then I switched to versioned cookbooks mode (I was using knife serve to run zero and a custom script to upload cookbooks, but my debugging doesn't indicate this was an issue with my script). When trying to list cookbooks, chef-zero returned a 500 with the following error:

ERROR: internal server error
Response: Exception raised!  #<ArgumentError: Malformed version number string omnibus>
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/rubygems/version.rb:191:in `initialize'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-zero-2.2/lib/chef_zero/endpoints/cookbooks_base.rb:44:in `new'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-zero-2.2/lib/chef_zero/endpoints/cookbooks_base.rb:44:in `block (2 levels) in filter_cookbooks'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-zero-2.2/lib/chef_zero/endpoints/cookbooks_base.rb:44:in `each'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-zero-2.2/lib/chef_zero/endpoints/cookbooks_base.rb:44:in `sort_by'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-zero-2.2/lib/chef_zero/endpoints/cookbooks_base.rb:44:in `block in filter_cookbooks'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-zero-2.2/lib/chef_zero/endpoints/cookbooks_base.rb:38:in `each'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-zero-2.2/lib/chef_zero/endpoints/cookbooks_base.rb:38:in `filter_cookbooks'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-zero-2.2/lib/chef_zero/endpoints/cookbooks_base.rb:13:in `format_cookbooks_list'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-zero-2.2/lib/chef_zero/endpoints/cookbooks_endpoint.rb:15:in `get'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-zero-2.2/lib/chef_zero/rest_base.rb:29:in `call'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-zero-2.2/lib/chef_zero/rest_router.rb:23:in `call'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-zero-2.2/lib/chef_zero/server.rb:443:in `block in app'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `call'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'

Adding some debugging output to chef-zero (by editing the gem directly) it appears that chef-zero had parsed the directory name as a cookbook name of "" (empty string) and a version of "omnibus" (the directory's name).

{:cookbook_list=>
  {""=>["omnibus"],
  # other stuff that doesn't matter

It would be cool if chef-zero validated the directory names and returned a nice error message when invalid ones are present.

no port found in cookbook url - can't download cookbooks unless listening on port 80

After uploading a cookbook to the ChefZero server the URL of each cookbook file does not contain the port of the running ChefZero server.

This means that when you attempt to download the cookbook, unless you started ChefZero on port 80, you'll receive a connection error.

Here's the "resources" collection of a cookbook in the ChefZero server:

{:resources=>[#<Hashie::Mash checksum="b70ba735f3af47e5d6fc71b91775b34c" name="defresource.rb" path="resources/defresource.rb" specificity="default" url="http://localhost/file_store/b70ba735f3af47e5d6fc71b91775b34c">]

You'll notice that the url is http://localhost/file_store/b70ba735f3af47e5d6fc71b91775b34c but the ChefZero server is actually running on 8889

Typo error in README

Chef Zero is a simple, easy-install, in-memory Chef server that can be useful for > Chef Client testing and chef-solo-like tasks that require a full Chef Cerver.

"Chef Cerver" should read "Chef Server"

InvalidByteSequenceError on converge

I get the following error when I try to use chef-zero with packer on CentOS 5.3. It's really odd because it works perfectly when building Ubuntu 12.04/14.04 hosts.

virtualbox-iso:
virtualbox-iso: Starting Chef Client, version 11.12.8
virtualbox-iso: [2014-07-15T11:18:41-07:00] WARN: Run List override has been provided.
virtualbox-iso: [2014-07-15T11:18:41-07:00] WARN: Original Run List: []
virtualbox-iso: [2014-07-15T11:18:41-07:00] WARN: Overridden Run List: [role[centos_53]]
virtualbox-iso: resolving cookbooks for run list: ["users", "timezone", "openssh", "sssd_ldap", "cacert::cacert.org", "chef", "ntp"]
virtualbox-iso: [2014-07-15T11:18:41-07:00] ERROR: #<Encoding::InvalidByteSequenceError: "\xC3" on US-ASCII>
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/cookbook/metadata.rb:444:in `encode'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/cookbook/metadata.rb:444:in `to_json'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/cookbook/metadata.rb:444:in `to_json'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/json-1.8.1/lib/json/common.rb:285:in `generate'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/json-1.8.1/lib/json/common.rb:285:in `pretty_generate'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/chef_fs/chef_fs_data_store.rb:102:in `block in get'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/chef_fs/chef_fs_data_store.rb:339:in `with_entry'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/chef_fs/chef_fs_data_store.rb:82:in `get'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/rest_base.rb:42:in `get_data'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:77:in `block in depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `each'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:101:in `block in depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `each'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:101:in `block in depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `each'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:101:in `block in depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `each'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:101:in `block in depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `each'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:37:in `post'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/rest_base.rb:29:in `call'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/rest_router.rb:23:in `call'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/server.rb:369:in `block in app'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `call'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
virtualbox-iso: /opt/chef/embedded/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
virtualbox-iso: /opt/chef/embedded/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
virtualbox-iso: /opt/chef/embedded/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
virtualbox-iso:
virtualbox-iso: ================================================================================
virtualbox-iso: Error Resolving Cookbooks for Run List:
virtualbox-iso: ================================================================================
virtualbox-iso:
virtualbox-iso:
virtualbox-iso: Unknown Server Error:
virtualbox-iso: ---------------------
virtualbox-iso: The server had a fatal error attempting to load the node data.
virtualbox-iso:
virtualbox-iso:
virtualbox-iso:
virtualbox-iso: Server Response:
virtualbox-iso: ----------------
virtualbox-iso: Exception raised!  #<Encoding::InvalidByteSequenceError: "\xC3" on US-ASCII>
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/cookbook/metadata.rb:444:in `encode'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/cookbook/metadata.rb:444:in `to_json'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/cookbook/metadata.rb:444:in `to_json'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/json-1.8.1/lib/json/common.rb:285:in `generate'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/json-1.8.1/lib/json/common.rb:285:in `pretty_generate'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/chef_fs/chef_fs_data_store.rb:102:in `block in get'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/chef_fs/chef_fs_data_store.rb:339:in `with_entry'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/chef_fs/chef_fs_data_store.rb:82:in `get'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/rest_base.rb:42:in `get_data'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:77:in `block in depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `each'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:101:in `block in depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `each'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:101:in `block in depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `each'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:101:in `block in depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `each'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:101:in `block in depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `each'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:71:in `depsolve'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb:37:in `post'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/rest_base.rb:29:in `call'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/rest_router.rb:23:in `call'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-zero-2.0.2/lib/chef_zero/server.rb:369:in `block in app'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `call'
virtualbox-iso: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
virtualbox-iso: /opt/chef/embedded/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
virtualbox-iso: /opt/chef/embedded/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
virtualbox-iso: /opt/chef/embedded/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
virtualbox-iso:
virtualbox-iso:
virtualbox-iso:
virtualbox-iso: Running handlers:
virtualbox-iso: [2014-07-15T11:18:41-07:00] ERROR: Running exception handlers
virtualbox-iso: Running handlers complete
virtualbox-iso:
virtualbox-iso: [2014-07-15T11:18:41-07:00] ERROR: Exception handlers complete
virtualbox-iso: [2014-07-15T11:18:41-07:00] FATAL: Stacktrace dumped to /root/.chef/local-mode-cache/cache/chef-stacktrace.out
virtualbox-iso: Chef Client failed. 0 resources updated in 2.193515 seconds
virtualbox-iso: [2014-07-15T11:18:41-07:00] ERROR: 500 "Internal Server Error "
virtualbox-iso: [2014-07-15T11:18:41-07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Incorrect search behavior when a query parameter contains a '-' character

We're using vagrant + chef-zero for dev & noticed an odd search behavior. There are 2 nodes running concurrently with different sets of recipes:

Node Name:   control
Environment: dev
FQDN:        control
IP:          10.0.2.15
Run List:    recipe[ktc-base], role[os-compute-single-controller]
Roles:       os-compute-single-controller, os-base, os-ops-database, os-identity, os-image, os-image-registry, os-image-api, os-compute-scheduler, os-compute-api, os-compute-api-ec2, os-compute-api-os-compute, os-compute-api-metadata, os-block-storage, os-compute-cert, os-compute-vncproxy, os-dashboard, infra-caching
Recipes:     ktc-base, openstack-common, openstack-common::logging, openstack-ops-database::server, ktc-messaging, openstack-ops-database::openstack-db, openstack-identity::server, openstack-identity::registration, openstack-image::registry, openstack-image::api, ktc-network, openstack-compute::scheduler, openstack-compute::api-ec2, openstack-compute::api-os-compute, openstack-compute::api-metadata, openstack-block-storage, openstack-compute::nova-cert, openstack-compute::vncproxy, openstack-dashboard::server, openstack-object-storage::memcached
Platform:    ubuntu 12.04
Tags:

Node Name:   worker1
Environment: dev
FQDN:        worker1
IP:          10.0.2.15
Run List:    recipe[ktc-base], recipe[ktc-compute]
Roles:
Recipes:     ktc-base, ktc-compute
Platform:    ubuntu 12.04
Tags:

The worker1 node contains ktc-compute the control node does not. Our code does a search for this recipe.

The following is shef output on the worker1 node ( both nodes produce the same output )

chef > resp = search("node", "recipes:ktc-compute")
 => [node[control], node[worker1]]
chef > resp = search(:node, "recipes:ktc-computeaaa")
 => [node[control], node[worker1]]
chef > resp = search("node", "run_list:ktc-aaa")
 => [node[control], node[worker1]]
chef > resp = search("node", "run_list:k")
 => []
chef > resp = search("node", "run_list:kt")
 => []
chef > resp = search("node", "run_list:ktc")
 => [node[control], node[worker1]]
chef > resp = search("node", "recipes:ktc-")
[2013-08-02T15:25:24+09:00] ERROR: Server returned error for http://192.168.31.86:4000/search/node?q=recipes:ktc-&sort=X_CHEF_id_CHEF_X%20asc&start=0&rows=1000, retrying 1/5 in 3s
^[[A^[[A[2013-08-02T15:25:27+09:00] ERROR: Server returned error for http://192.168.31.86:4000/search/node?q=recipes:ktc-&sort=X_CHEF_id_CHEF_X%20asc&start=0&rows=1000, retrying 2/5 in 5s
^CIRB::Abort: abort then interrupt!
(stack trace removed)
chef > resp = search("node", "run_list:ktc\-compute")
 => [node[control], node[worker1]]
chef > resp = search("node", "recipes:ktc\\-compute")
 => [node[worker1]]

It appears the - is being interpreted as a wildcard of sorts and the search does not work correctly unless it is escaped.

This was tested on a real chef server & works as expected: search("node", "recipes:ktc-compute") returns the worker1 node, the others return nothing or an error.

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.