knife-zero icon indicating copy to clipboard operation
knife-zero copied to clipboard

Assume a default query key when none provided in `knife zero chef_client QUERY`

Open patcon opened this issue 10 years ago • 7 comments

It seems that even when there's a node/example.com.json, knife zero chef_client example.com doesn't work, and instead, we must use knife zero chef_client name:example.com

Would be great if knife-zero assumed a default key, either name or fqdn (I prefer "name", as it should intuitiveless always match the json filename in nodes/. Yes, in the current knife-zero this is also the fqdn, but this need not necessarily be the case in the future)

patcon avatar Jun 10 '15 17:06 patcon

hmm... QUERY syntax based on knife search, ssh. It's usage of chef-server/client environment.

https://docs.chef.io/knife_ssh.html https://docs.chef.io/knife_search.html

If I implement specific usage to knife-zero, then it's getting harder to follow chef-core updates ( and the edge of chef often cases regression ...).

But, I seem to better way to use name or fqdn by default. In that case, there is a need to be careful not to use as a regular expression.

sawanoboly avatar Jun 12 '15 08:06 sawanoboly

You're right about it diverging from chef-core. Perhaps it would be welcome there. Created a ticket here for discussion: https://github.com/chef/chef/issues/3526

patcon avatar Jun 12 '15 15:06 patcon

Thank you for create issue to core :smiley:

sawanoboly avatar Jun 13 '15 06:06 sawanoboly

bwaha. the label.

patcon avatar Jun 13 '15 06:06 patcon

fyi this would work for knife zero commands. Feel free to offer feedback: https://github.com/chef/chef/pull/3536

patcon avatar Jun 15 '15 19:06 patcon

@patcon great!

I've add below to Gemfile and tested it.

gem 'chef', github: 'patcon/chef', ref: '3526-fuzz-ssh-query'

There are node which is named knife-zero02. It have IP 133.242.xxx.xxx.

$ bundle exec knife node show knife-zero02
Node Name:   knife-zero02
Environment: _default
FQDN:        
IP:          133.242.xxx.xxx
Run List:    
Roles:       
Recipes:     
Platform:    ubuntu 14.04
Tags:        

In this case, I should pass an ipaddress to fuzzy_query.

$ bundle exec knife zero converge 133.242.xxx.xxx -a ipaddress
133.242.xxx.xxx sudo: unable to resolve host knife-zero02
133.242.xxx.xxx Starting Chef Client, version 12.3.0
133.242.xxx.xxx resolving cookbooks for run list: []
133.242.xxx.xxx Synchronizing Cookbooks:
133.242.xxx.xxx Compiling Cookbooks...
133.242.xxx.xxx [2015-06-16T15:01:09+09:00] WARN: Node knife-zero02 has an empty run list.
133.242.xxx.xxx Converging 0 resources
133.242.xxx.xxx [2015-06-16T15:01:09+09:00] WARN: Could not find whitelist attribute fqdn/.
133.242.xxx.xxx [2015-06-16T15:01:09+09:00] WARN: Could not find whitelist attribute cloud.
133.242.xxx.xxx 
133.242.xxx.xxx Running handlers:
133.242.xxx.xxx Running handlers complete
133.242.xxx.xxx Chef Client finished, 0/0 resources updated in 1.760414153 seconds

How about include name to fuzzy target?

$ bundle exec knife zero converge knife-zero02 -a ipaddress
FATAL: No nodes returned from search!

sawanoboly avatar Jun 16 '15 06:06 sawanoboly

I'm down, but it sounds like Lamont thinks this logic should match the search logic, so maybe mention the idea in the chef issue?

Also, I'll make sure to leave it around this time, but I'd recommend against using my feature branches on your master, as my habit is to delete them after merge, and sometimes they break :)

patcon avatar Jun 16 '15 13:06 patcon