class Inception::InceptionServerCookbook
Perform converge chef cookbooks upon inception server
Attributes
project_dir[R]
server[R]
settings[R]
Public Class Methods
new(inception_server, settings, project_dir)
click to toggle source
# File lib/inception/inception_server_cookbook.rb, line 10 def initialize(inception_server, settings, project_dir) @server = inception_server @settings = settings @project_dir = project_dir end
Public Instance Methods
converge()
click to toggle source
To be invoked within the settings_dir
# File lib/inception/inception_server_cookbook.rb, line 24 def converge FileUtils.chdir(project_dir) do knife_solo :cook end end
ignore_chef_preparations?()
click to toggle source
# File lib/inception/inception_server_cookbook.rb, line 30 def ignore_chef_preparations? @settings.exists?("cookbook.prepared") end
key_path()
click to toggle source
# File lib/inception/inception_server_cookbook.rb, line 35 def key_path; server.private_key_path; end
knife_solo(command)
click to toggle source
# File lib/inception/inception_server_cookbook.rb, line 37 def knife_solo(command) attributes = cookbook_attributes_for_inception.to_json sh %Q{knife solo #{command} #{user_host} -i #{key_path} -j '#{attributes}' -r 'bosh_inception'} end
prepare()
click to toggle source
# File lib/inception/inception_server_cookbook.rb, line 16 def prepare FileUtils.chdir(project_dir) do prepare_project_dir knife_solo :prepare unless ignore_chef_preparations? end end
user_host()
click to toggle source
# File lib/inception/inception_server_cookbook.rb, line 34 def user_host; server.user_host; end
Protected Instance Methods
cookbook_attributes_for_inception()
click to toggle source
# File lib/inception/inception_server_cookbook.rb, line 65 def cookbook_attributes_for_inception { "disk" => { "mounted" => true, "device" => settings.inception.provisioned.disk_device.internal }, "git" => { "name" => settings.git.name, "email" => settings.git.email }, "user" => { "username" => settings.inception.provisioned.username }, "fog" => settings.provider.credentials } end
gem_root_path()
click to toggle source
# File lib/inception/inception_server_cookbook.rb, line 82 def gem_root_path File.expand_path("../../..", __FILE__) end
inception_cookbook_path()
click to toggle source
# File lib/inception/inception_server_cookbook.rb, line 86 def inception_cookbook_path File.join(gem_root_path, "cookbooks/bosh_inception") end
prepare_berksfile()
click to toggle source
# File lib/inception/inception_server_cookbook.rb, line 59 def prepare_berksfile unless File.exists?("Berksfile") cp_r(File.join(gem_root_path, "Berksfile"), "Berksfile") end end
prepare_cookbook()
click to toggle source
# File lib/inception/inception_server_cookbook.rb, line 49 def prepare_cookbook mkdir_p("cookbooks") rm_rf("cookbooks/bosh_inception") cp_r(inception_cookbook_path, "cookbooks/") end
prepare_knife_config()
click to toggle source
# File lib/inception/inception_server_cookbook.rb, line 55 def prepare_knife_config mkdir_p("nodes") # needed for knife solo end
prepare_project_dir()
click to toggle source
# File lib/inception/inception_server_cookbook.rb, line 43 def prepare_project_dir prepare_cookbook prepare_knife_config prepare_berksfile end