Skip to content

Commit c2c75c0

Browse files
committed
Add optional query to cacher to limit nodes included in search
Signed-off-by: Ryan Steinmetz <[email protected]>
1 parent e78a1f4 commit c2c75c0

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ The following attributes are set on a per-platform basis, see the `attributes/de
124124
- `node['ssh_known_hosts']['key_type']` - Determines which key type ssh-keyscan will use to determine the host key, different systems will have different available key types, check your manpage for available key types for ssh-keyscan. Defaults to 'rsa,dsa'
125125
- `node['ssh_known_hosts']['use_data_bag_cache']` - Use the data bag maintained by the cacher server to build `/etc/ssh/ssh_known_hosts` instead of a direct search (requires that a node be set up to run the cacher recipe regularly).
126126
- `node['ssh_known_hosts']['cacher']['data_bag']`/`node['ssh_known_hosts']['cacher']['data_bag_item']` - Data bag where cacher recipe should store its keys.
127+
- `node['ssh_known_hosts']['cacher']['node_search_query']` - Additional query string to apply to the cacher search (useful in large environments)
127128
- `node['ssh_known_hosts']['node_search_query']` - Additional query string to apply to the search
128129

129130
## License & Authors

attributes/default.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@
2323

2424
default['ssh_known_hosts']['cacher']['data_bag'] = 'server_data'
2525
default['ssh_known_hosts']['cacher']['data_bag_item'] = 'known_hosts'
26+
default['ssh_known_hosts']['cacher']['node_search_query'] = ''
2627
default['ssh_known_hosts']['node_search_query'] = ''

recipes/cacher.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
all_host_keys = ssh_known_hosts_partial_query('keys:*')
1+
2+
node_query = 'keys:*'
3+
node_query << " #{node['ssh_known_hosts']['cacher']['node_search_query']}" unless node['ssh_known_hosts']['cacher']['node_search_query'].empty?
4+
5+
all_host_keys = ssh_known_hosts_partial_query(node_query)
26
Chef::Log.debug("Partial search got: #{all_host_keys.inspect}")
37

48
new_data_bag_content = {

0 commit comments

Comments
 (0)