Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby script to ssh into base wheezy template and install stuff necessary for systemvm
#!/usr/bin/env ruby
require 'rubygems'
require 'net/ssh'
host = ''
user = 'root'
pass = 'root'
options = {}
opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: provision.rb IP [options]"
opts.separator ""
opts.separator "Specific options:"
opts.on(:REQUIRED, "-u","--user", String, "Username (e.g., root)") do |u|
options[:user] = u
end
opts.on(:REQUIRED, "-p", "--password", String, "Password for user") do |p|
options[:pass] = p
end
end
begin
opt_parser.parse!(ARGV)
if ARGV.size == 1
host = ARGV[0]
end
unless options[:user] && options[:pass]
raise OptionParser::MissingArgument
end
user = options[:user]
pass = options[:pass]
puts host, user, pass
rescue => e
puts e.message.capitalize
puts opt_parser.help()
exit 1
end
Net::SSH.start( host, user, :password => pass ) do |ssh|
result = ssh.exec!("apt-get -q -y --force-yes --no-install-recommends install wget")
puts result
end
Net::SSH.start( host, user, :password => pass) do |ssh|
result = ssh.exec!("wget --no-check-certificate https://gist.githubusercontent.com/chiradeep/11388137/raw/51a98bfb61fd4cff6b282a43523c7d945f63416e/postinstall_lxc.sh -O postinstall.sh")
puts result
end
Net::SSH.start( host, user, :password => pass ) do |ssh|
result = ssh.exec!("chmod +x postinstall.sh")
puts result
end
Net::SSH.start( host, user, :password => pass ) do |ssh|
result = ssh.exec!("./postinstall.sh")
puts result
end
@rhtyd

This comment has been minimized.

Copy link

rhtyd commented Jul 31, 2014

Does it actually work, do we have systemvms for LXC now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.