Class: Inception::InceptionServerCookbook

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/inception/inception_server_cookbook.rb

Overview

Perform converge chef cookbooks upon inception server

Defined Under Namespace

Classes: InvalidTarget

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inception_server, settings, project_dir) ⇒ InceptionServerCookbook

Returns a new instance of InceptionServerCookbook.



10
11
12
13
14
# 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

Instance Attribute Details

#project_dirObject (readonly)

Returns the value of attribute project_dir.



6
7
8
# File 'lib/inception/inception_server_cookbook.rb', line 6

def project_dir
  @project_dir
end

#serverObject (readonly)

Returns the value of attribute server.



6
7
8
# File 'lib/inception/inception_server_cookbook.rb', line 6

def server
  @server
end

#settingsObject (readonly)

Returns the value of attribute settings.



6
7
8
# File 'lib/inception/inception_server_cookbook.rb', line 6

def settings
  @settings
end

Instance Method Details

#convergeObject

To be invoked within the settings_dir



24
25
26
27
28
# File 'lib/inception/inception_server_cookbook.rb', line 24

def converge
  FileUtils.chdir(project_dir) do
    knife_solo :cook
  end
end

#ignore_chef_preparations?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/inception/inception_server_cookbook.rb', line 30

def ignore_chef_preparations?
  @settings.exists?("cookbook.prepared")
end

#key_pathObject



35
# File 'lib/inception/inception_server_cookbook.rb', line 35

def key_path; server.private_key_path; end

#knife_solo(command) ⇒ Object



37
38
39
40
# 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

#prepareObject



16
17
18
19
20
21
# 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_hostObject



34
# File 'lib/inception/inception_server_cookbook.rb', line 34

def user_host; server.user_host; end