Class: Tenderloin::Actions::VM::Provision
- Inherits:
-
Base
- Object
- Base
- Tenderloin::Actions::VM::Provision
show all
- Defined in:
- lib/tenderloin/actions/vm/provision.rb
Instance Attribute Summary
Attributes inherited from Base
#run_args, #runner
Instance Method Summary
collapse
Methods inherited from Base
#cleanup, #initialize, #prepare, #rescue
Methods included from Util
#error_and_exit, included, #logger, #wrap_output
Instance Method Details
#execute! ⇒ Object
5
6
7
8
9
|
# File 'lib/tenderloin/actions/vm/provision.rb', line 5
def execute!
run_rsync if Tenderloin.config.provisioning.rsync
setup_script if Tenderloin.config.provisioning.script
run_command if Tenderloin.config.provisioning.command
end
|
#run_command ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/tenderloin/actions/vm/provision.rb', line 30
def run_command
logger.info "Running Provisioning command..."
cmd = ""
cmd << "chmod +x /tmp/tenderloin_provision.sh && " if Tenderloin.config.provisioning.script
cmd << Tenderloin.config.provisioning.command
SSH.execute(@runner.fusion_vm.ip) do |ssh|
ssh.exec!(cmd) do |channel, data, stream|
logger.info("#{stream}: #{data}")
end
end
end
|
#run_rsync ⇒ Object
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/tenderloin/actions/vm/provision.rb', line 11
def run_rsync
Tenderloin.config.provisioning.rsync.each do |rsync|
logger.info "Running rsync for #{rsync.join(' -> ')}..."
src, dst = *rsync
SSH.execute(@runner.fusion_vm.ip) do |ssh|
ssh.exec!("mkdir -p #{dst}")
end
logger.info SSH.rsync(@runner.fusion_vm.ip, File.expand_path(src), File.expand_path(dst))
end
end
|
#setup_script ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/tenderloin/actions/vm/provision.rb', line 22
def setup_script
logger.info "Uploading provisioning script..."
SSH.upload!(@runner.fusion_vm.ip, StringIO.new(Tenderloin.config.provisioning.script), File.join('/tmp', "tenderloin_provision.sh"))
Tenderloin.config.provisioning.command = "/tmp/tenderloin_provision.sh"
end
|