带有使用通配符的字段的 Knife 搜索环境和角色

Knife search environments and roles with a field using a wildcard

我正在更改以下属性:

default['splunk']['auth'] = "admin:changeme"

至:

default['splunk']['auth']['username'] = "admin"
default['splunk']['auth']['password'] = "changeme"

并且我想确保我不会错过/忘记某些事情...

很容易确保我没有遗漏食谱中的任何内容:

nickh@BONHENRY:~/Repositories/chef$ ack-grep "\[.splunk.?\]\[.auth.?\]"
cookbooks/splunk_cookbook/attributes/default.rb
36:default['splunk']['auth']['username']          = "admin"
37:default['splunk']['auth']['password']          = "changeme"

cookbooks/splunk_cookbook/attributes/README.md
72:* `node['splunk']['auth']['username']` - The default admin username to use instead of splunks "admin"
73:* `node['splunk']['auth']['password']` - The default admin password to use instead of splunks "changeme"

cookbooks/splunk_cookbook/recipes/server.rb
219:  command "#{splunk_cmd} edit user admin -password #{node['splunk']['auth']['password']} -roles admin -auth admin:changeme && echo true > /opt/splunk_setup_passwd"
228:    command "#{splunk_cmd} enable listen #{node['splunk']['receiver_port']} -auth #{node['splunk']['auth']['username']}:#{node['splunk']['auth']['password']}"
326:      command "#{splunk_cmd} edit licenser-localslave -master_uri 'https://#{node['splunk']['dedicated_search_master']}:8089' -auth #{node['splunk']['auth']['username']}:#{node['splunk']['auth']['passwor
391:    command "/opt/splunk/bin/splunk login -auth #{node['splunk']['auth']['username']}:#{node['splunk']['auth']['password']}"

cookbooks/splunk_cookbook/recipes/forwarder.rb
78:execute "#{splunk_cmd} edit user admin -password #{node['splunk']['auth']['password']} -roles admin -auth admin:changeme && echo true > /opt/splunk_setup_passwd" do

但是,我不确定 grep/search JSON roles/environments 的好方法...

这个有效:

 nickh@BONHENRY:~/Repositories/chef$ knife search environment "override_attributes_splunk_auth:*" -i
 1 items found

 prod-acme

但是,您知道为什么会这样吗:

 nickh@BONHENRY:~/Repositories/chef$ knife search environment "*:*" -i
 108 items found

但这不是吗? :

 nickh@BONHENRY:~/Repositories/chef$ knife search environment "*splunk_auth:*" -i
 ERROR: knife search failed: invalid index name or query

有没有一种我没有想到/没有意识到的简单/更好的方法?我可以使用我的 Solr 查询更改某些内容以使其正常工作吗?

提前致谢:-)

因为*:*是完全绕过Solr的搜索系统的特例。 Chef 的搜索索引使用查询的转换版本,因此我认为在这样的方面名称中使用 glob 是不安全的。我会推荐 运行 knife download environments/(和类似的角色),然后在本地 JSON 文件上执行 grep。