Class: Hazetug::Tug::Solo
Constant Summary
Constants inherited
from Hazetug::Tug
LOGDIR
NetSSH::Mixin::NET_SSH_OPTIONS
Instance Attribute Summary
Attributes inherited from Hazetug::Tug
#config, #options
Instance Method Summary
collapse
Methods inherited from KnifeBase
#bootstrap_run, #bootstrap_server, #check_bootstrap_files!, #hazetug_identity, #knife
[], #bootstrap, #tug_name
Methods included from UI::Mixin
included
Constructor Details
#initialize(config = {}) ⇒ Solo
Returns a new instance of Solo.
12
13
14
15
|
# File 'lib/hazetug/tug/solo.rb', line 12
def initialize(config={})
super
@upload_dest = '/tmp/hazetug-cookbooks.tar.gz'
end
|
Instance Method Details
#berks_package(&block) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/hazetug/tug/solo.rb', line 34
def berks_package(&block)
berks = Berkshelf::Berksfile.from_file(bootstrap_options[:berksfile])
Dir::Tmpname.create('hazetug-cookbooks') do |path|
begin
berks.package(path)
block.call(path)
ensure
File.unlink(path) if File.exist?(path)
end
end
end
|
#bootstrap_cleanup ⇒ Object
29
30
31
32
|
# File 'lib/hazetug/tug/solo.rb', line 29
def bootstrap_cleanup
ssh = Fog::SSH.new(config[:public_ip_address], ssh_username, net_ssh_options)
ssh.run("test -f #{@upload_dest} && rm #{@upload_dest}")
end
|
#bootstrap_config ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/hazetug/tug/solo.rb', line 17
def bootstrap_config
super
config[:attributes_json] = json_attributes
config[:cookbooks_file] = @upload_dest
check_bootstrap_files! :template_file, :berksfile
end
|
#bootstrap_init ⇒ Object
25
26
27
|
# File 'lib/hazetug/tug/solo.rb', line 25
def bootstrap_init
upload_berks_package
end
|
#bootstrap_options ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/hazetug/tug/solo.rb', line 54
def bootstrap_options
@bootstrap_options ||= begin
opts = super
opts[:berksfile] = config[:berksfile] || 'Berksfile'
opts
end
end
|
#json_attributes ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/hazetug/tug/solo.rb', line 62
def json_attributes
@json_attributes ||= begin
hash = config[:attributes] || {}
hash[:run_list] = config[:run_list] || []
JSON.pretty_generate(hash)
end
end
|
#ssh_username ⇒ Object
70
71
72
|
# File 'lib/hazetug/tug/solo.rb', line 70
def ssh_username
config[:ssh_user] || 'root'
end
|
#upload_berks_package ⇒ Object
47
48
49
50
51
52
|
# File 'lib/hazetug/tug/solo.rb', line 47
def upload_berks_package
berks_package do |path|
scp = Fog::SCP.new(config[:public_ip_address], ssh_username, net_ssh_options)
scp.upload(path, @upload_dest)
end
end
|