This is with both Chef 12.0.0 and 12.1.1
When talking to a real chef server (in that case hosted chef) - and running the following queries. I get the following results (there are about 60 other nodes in this hosted chef account).
chef > search(:node, "role:api_server AND chef_environment:#{node.chef_environment} NOT tags:hidden", :filter_result => { 'ip' => ['ipaddress'] })
=> [{"ip"=>"1.1.1.1"}]
chef > search(:node, "role:api_server AND chef_environment:#{node.chef_environment} AND NOT tags:hidden", :filter_result => { 'ip' => ['ipaddress'] })
=> [{"ip"=>"1.1.1.1"}]
Works as I would expect
Also here i'm using filter results - but have confirmed the issue with both normal search and "partial" search.
On a test server - (using test-kichen with chef zero provisioner), and pre-populating node data, I see the following:
Node Data
cat /tmp/kitchen/nodes/api_server.json
{
"id": "api_server",
"chef_environment": "test",
"run_list": [
"role[api_server]"
],
"automatic": {
"ipaddress": "172.33.33.34",
"hostname": "api-server",
"roles": [
"api_server"
]
}
}
{
"id": "sensu_master",
"chef_environment": "test",
"run_list": [
"role[sensu_master]"
],
"automatic": {
"ipaddress": "172.33.33.50",
"hostname": "sensu-master",
"roles": [
"sensu_master"
]
}
}
Then running queries against:
pry(#<Chef::Recipe>)> search(:node, "role:api_server AND chef_environment:#{node.chef_environment} NOT tags:hidden", :filter_result => { 'ip' => ['ipaddress'] })
=> [{"ip"=>"172.33.33.34"},{"ip"=>"172.33.33.50"}]
pry(#<Chef::Recipe>)> search(:node, "role:api_server AND chef_environment:#{node.chef_environment} AND NOT tags:hidden", :filter_result => { 'ip' => ['ipaddress'] })
=> [{"ip"=>"172.33.33.34"}]
pry(#<Chef::Recipe>)> search(:node, "role:api_server AND chef_environment:#{node.chef_environment}", :filter_result => { 'ip' => ['ipaddress'] })
=> [{"ip"=>"172.33.33.34"}]
So in this case it seems to be the AND or AND NOT at the end. This is easy for us to work around by using AND NOT in our cookbooks since that seems to work for both, but there might be a chef-zero or localmode bug.
This is with both Chef
12.0.0and12.1.1When talking to a real chef server (in that case hosted chef) - and running the following queries. I get the following results (there are about 60 other nodes in this hosted chef account).
Works as I would expect
Also here i'm using filter results - but have confirmed the issue with both normal search and "partial" search.
On a test server - (using test-kichen with chef zero provisioner), and pre-populating node data, I see the following:
Node Data
Then running queries against:
So in this case it seems to be the
ANDorAND NOTat the end. This is easy for us to work around by usingAND NOTin our cookbooks since that seems to work for both, but there might be a chef-zero or localmode bug.