Skip to content

jrwesolo/chef_search_woes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Search Woes

This cookbook is here to demonstrate a weird situation with searches in Chef.

Example

Normally, if you wanted to find nodes that were in a chef environment called production you would do something like this:

nodes = search(:node, 'chef_environment:production')

Chef uses SOLR underneath to perform searches. SOLR will look for the field (chef_environment in this case) no matter how nested it may be in a node's attributes.

Let's say we have two nodes. alice is in the production environment and bob is in the development environment. Bob also has a node attribute set to:

node['break']['search']['with']['chef_environment'] = 'production'

Performing the search above would return both alice and bob.

Testing

This cookbook has unit and integration tests that fail due to this search behavior. The unit tests contain contexts with and without the conflicting nested attribute.

Tests were performed with ChefDK 0.5.1 using the following commands:

chef exec rspec        # for unit tests
chef exec kitchen test # for integration tests

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published