Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search return just the node name and nothing else #63

Open
jamengual opened this issue Sep 4, 2014 · 6 comments
Open

Search return just the node name and nothing else #63

jamengual opened this issue Sep 4, 2014 · 6 comments

Comments

@jamengual
Copy link

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
Copy link

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

@jamengual
Copy link
Author

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
Copy link
Author

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
Copy link

lonniev commented Dec 4, 2014

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
Copy link

@lonniev you have the chops to PR that?

@lonniev
Copy link

lonniev commented Dec 4, 2014

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! ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants