Created
April 24, 2012 02:51
-
-
Save hh/2475733 to your computer and use it in GitHub Desktop.
getting rid of node.kernel.modules and pnp_drivers makes huge difference is node size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| require 'bundler/setup' | |
| require 'pp' | |
| require 'yaml' | |
| require 'chef' | |
| def create_chef_cache | |
| Chef::Config.from_file(".chef/knife.rb") | |
| out = Mash.new | |
| @cq = Chef::Search::Query.new | |
| puts @cq.list_indexes.keys.inspect | |
| @cq.list_indexes.keys.each do |index| | |
| puts index | |
| out[index]=[] | |
| @cq.search(index,"*:*") do |entry| | |
| if index == 'node' | |
| entry['kernel'].delete 'modules' | |
| entry['kernel'].delete 'pnp_drivers' | |
| end | |
| out[index] << entry #.to_hash might make it less dependent on chef | |
| end | |
| end | |
| File.open('chef_cache.yml', 'w') {|f| f.write(out.to_yaml)} | |
| @chef_cache = out | |
| end | |
| def load_chef_cache | |
| @chef_cache = YAML.load(File.open('chef_cache.yml').read) | |
| end | |
| # chef_cache.yml size in bytes: | |
| # 3153354 # before deleting modules/pnp_drivers | |
| # 432344 # afterwards | |
| # Just the 2.5meg in xfer alone will make /status and friends run much faster |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This stuff can take up 10 times the amount of data | |
| # as the entire rest of the node... we don't need it | |
| ['pnp_drivers', 'modules'].each do |extraneous_info| | |
| node.automatic['kernel'].delete extraneous_info | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment