Created
December 9, 2012 12:17
-
-
Save priestjim/4244627 to your computer and use it in GitHub Desktop.
Managing a number of chef installations/knife configs via a central one
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
# Enter this code alone in your ~/.chef/knife.rb | |
# The directory structure is expected to be like | |
# $HOME/Code | |
# $HOME/Code/ChefSetup1 | |
# $HOME/Code/ChefSetup2 | |
# Each of the project directories should contain their respective knife config like | |
# | |
# $HOME/Code/ChefSetup1/.chef/knife.local.rb | |
# $HOME/Code/ChefSetup2/.chef/knife.local.rb | |
# | |
# In your terminal just do then | |
# | |
# cd ~/Code/EpicStartup/cookbooks | |
# knife cookbook upload base | |
# | |
# and knife will automatically use the correct server settings | |
# | |
# ln -s ~/.chef/knife.rb ~/.chef/shef.rb | |
# to use the same concept for your shef shell | |
# | |
# Declare here you project home | |
project_home = File.join(ENV['HOME'], 'Code') | |
current_project = Dir.pwd.sub("#{project_home}/", '').split('/').first | |
real_project = File.join(project_home, current_project) | |
if File.exists?(File.join(real_project, '.chef', 'knife.local.rb')) | |
Chef::Config.from_file(File.join(real_project,'.chef','knife.local.rb')) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment