Class: Colonize::Machine
Instance Method Summary
collapse
Methods included from Tools
#cp, #ln, #mv, #rm, #template
Methods included from Log
#debug, #error, #fatal, #info
Constructor Details
#initialize(name, host: 'localhost', port: 2222) ⇒ Machine
Returns a new instance of Machine.
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/colonize/machine.rb', line 36
def initialize(name, host: 'localhost', port: 2222)
@name = name.to_s
@conn = Colonize::Connection.new host, port: port
@update = false
@upgrade = false
ObjectSpace.define_finalizer(self, proc { finalize })
info "Colonizeing '#{@name}'..."
end
|
Instance Method Details
#exec(cmd, *opts) ⇒ Object
68
69
70
|
# File 'lib/colonize/machine.rb', line 68
def exec(cmd, *opts)
@conn.exec cmd, *opts
end
|
#mount_temp ⇒ Object
93
94
95
96
97
98
|
# File 'lib/colonize/machine.rb', line 93
def mount_temp
replace_or_append '/etc/fstab',
'^tmpfs /tmp tmpfs noatime,nosuid,nodev 0 0',
'tmpfs /tmp tmpfs noatime,nosuid,nodev 0 0'
sudo :mount, '-a'
end
|
#password=(password) ⇒ Object
64
65
66
|
# File 'lib/colonize/machine.rb', line 64
def password=(password)
@conn.password = password
end
|
#service(name) {|s| ... } ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/colonize/machine.rb', line 47
def service(name)
k = name.downcase.to_sym
d = Colonize::Service.descendants
if d.has_key?(k)
s = d[k].new(name, self)
else
s = Colonize::Service.new(name, self)
end
yield s if block_given?
s
end
|
#sudo(cmd, *opts) ⇒ Object
72
73
74
|
# File 'lib/colonize/machine.rb', line 72
def sudo(cmd, *opts)
@conn.sudo cmd, *opts
end
|
#update ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/colonize/machine.rb', line 76
def update
return if @update
apt_get :update, '--assume-yes'
@update = true
end
|
#upgrade ⇒ Object
84
85
86
87
88
89
90
91
|
# File 'lib/colonize/machine.rb', line 84
def upgrade
return if @upgrade
update
apt_get :upgrade, '--assume-yes'
@upgrade = true
end
|
#user=(user) ⇒ Object
60
61
62
|
# File 'lib/colonize/machine.rb', line 60
def user=(user)
@conn.user = user
end
|