Module: GreenAndSecure
Defined Under Namespace
Classes: Block, BlockList, BlockNew, BlockUse
Constant Summary collapse
Instance Method Summary collapse
-
#berkshelf_path ⇒ Object
Returns path to berkshelf.
- #check_block_setup ⇒ Object
- #chef_config_base ⇒ Object
- #current_chef_version ⇒ Object
-
#locate_config_file(config) ⇒ Object
Copied from chef/knife.rb.
- #printable_server(server_config) ⇒ Object
Instance Method Details
#berkshelf_path ⇒ Object
Returns path to berkshelf
89 90 91 |
# File 'lib/chef/knife/block.rb', line 89 def berkshelf_path @berkshelf_path ||= ENV['BERKSHELF_PATH'] || File.('~/.berkshelf') end |
#check_block_setup ⇒ Object
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/chef/knife/block.rb', line 73 def check_block_setup base = GreenAndSecure::chef_config_base if File.exists?(base+"/knife.rb") then unless File.symlink?(base+"/knife.rb") puts "#{base}/knife.rb is NOT a symlink." puts "Please copy the file to #{base}/knife-<servername>.rb and re-run this command." exit 3 end end end |
#chef_config_base ⇒ Object
36 37 38 |
# File 'lib/chef/knife/block.rb', line 36 def chef_config_base @@knife.get_config_file end |
#current_chef_version ⇒ Object
32 33 34 |
# File 'lib/chef/knife/block.rb', line 32 def current_chef_version @@current_chef_version end |
#locate_config_file(config) ⇒ Object
Copied from chef/knife.rb
Chef 11 defines ‘locate_config_file` in its chef/knife.rb but Chef 10 has this snippet of code inlined in chef/knife.rb:configure_chef.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/chef/knife/block.rb', line 44 def locate_config_file(config) candidate_configs = [] # Look for $KNIFE_HOME/knife.rb (allow multiple knives config on same machine) if ENV['KNIFE_HOME'] candidate_configs << File.join(ENV['KNIFE_HOME'], 'knife.rb') end # Look for $PWD/knife.rb if Dir.pwd candidate_configs << File.join(Dir.pwd, 'knife.rb') end # Look for $UPWARD/.chef/knife.rb if ::Chef::Knife.chef_config_dir candidate_configs << File.join(::Chef::Knife.chef_config_dir, 'knife.rb') end # Look for $HOME/.chef/knife.rb if ENV['HOME'] candidate_configs << File.join(ENV['HOME'], '.chef', 'knife.rb') end candidate_configs.each do |candidate_config| candidate_config = File.(candidate_config) if File.exist?(candidate_config) config[:config_file] = candidate_config break end end end |
#printable_server(server_config) ⇒ Object
84 85 86 |
# File 'lib/chef/knife/block.rb', line 84 def printable_server(server_config) File.basename(server_config, ".rb").split('-')[1 .. -1].join('-') end |