edelight / chef-solo-search

Data bag search for Chef Solo
Apache License 2.0
177 stars 2 forks source link

Search return just the node name and nothing else #63

Open jamengual opened 10 years ago

jamengual commented 10 years ago

Hi.

I'm having a estrange issue with the search cookbook.

I created a data bag node :

{ "id": "splunk-server", "name": "splunk_server", "chef_environment": "_default", "json_class": "Chef::Node", "splunk_is_server": "true", "ipaddress ": "123.123.123.123", "automatic": { "hostname": "splunk.server.com", "os": "centos" }, "normal": { }, "chef_type": "node", "default": { }, "override": { }, "run_list": [ "role[monitoring]" ] }

but the result of the search was keep coming blank so I start printing variables on my recepies and I realize that this search :

splunk_servers = search(# ~FC003 :node, "splunk_is_server:true")

it returns empty but if I search for :node I can see : search(:node) result : node[splunk_server]

But the search above is trying to find on the chef server ( in this case the json file) all the nodes with the attribute "splunk_is_server": "true", but it doesn't seem to find it.

I'm doing something wrong on the json file ?

should I add those attributes to another section ?

Thanks.

PS : the template replacement code from the cookbook that I'm using https://github.com/opscode-cookbooks/chef-splunk/blob/master/templates/default/outputs.conf.erb

the original search code :

https://github.com/opscode-cookbooks/chef-splunk/blob/master/recipes/client.rb

heathsnow commented 10 years ago

Has chef been successfully run on the "splunk_server" node yet?

jamengual commented 10 years ago

yes it did run successfully but the server ip is empty and that is what the search is for, to find the node: that has that attribute "splunk_is_server": "true" and then fill up the template

thanks.

jamengual commented 10 years ago

do you meen in the splunk server itself ? in that case no because I don't need it since I need the client to be installed not the server and the cookbook that I'm using search on the chef server for a splunk server node and if found one then uses the ipaddress attribute to fill up the template.

lonniev commented 9 years ago

Related to this, it would help if the README.md not only showed how to state a query but also showed a sample input json databag and a sample output query result for each query. As it is, a newbie user has no idea what to run the query against and what to expect as the type/format of the output.

michaelglass commented 9 years ago

@lonniev you have the chops to PR that?

lonniev commented 9 years ago

Now that I have read over the code in the providers directory for the users recipe, yes I probably could add the few lines of markdown that would illustrate how that search method returns an iterable array of json objects as the resultset.

However, I have my own code to debug and document and I'd prefer to stay focused there! ;-)