Skip to content

Instantly share code, notes, and snippets.

@chiradeep
Created April 29, 2014 18:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chiradeep/11407727 to your computer and use it in GitHub Desktop.
Save chiradeep/11407727 to your computer and use it in GitHub Desktop.
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
@rohityadavcloud
Copy link

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