Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move ssh port to 7222 and update Archlinux support

  • Loading branch information...
commit 7a1e9c53ea76189ae9293a495e7815aef0f69c91 1 parent 43eaf9a
@jedi4ever jedi4ever authored
View
6 Gemfile.lock
@@ -21,7 +21,7 @@ GEM
rake (>= 0.8.7)
highline (1.6.1)
i18n (0.5.0)
- json (1.4.6)
+ json (1.5.1)
mario (0.0.6)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
@@ -33,11 +33,11 @@ GEM
progressbar (0.9.0)
rake (0.8.7)
thor (0.14.6)
- vagrant (0.7.1)
+ vagrant (0.7.2)
archive-tar-minitar (= 0.5.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
- json (~> 1.4.6)
+ json (~> 1.5.1)
mario (~> 0.0.6)
net-scp (~> 1.0.4)
net-ssh (~> 2.1.0)
View
2  lib/veewee/command.rb
@@ -52,7 +52,7 @@ def ostypes
desc "destroy BOXNAME", "Destroys the virtualmachine that was build for a basebox"
def destroy(boxname)
- puts Veewee::Session.destroy_vm(boxname)
+ Veewee::Session.destroy_vm(boxname)
end
desc "list", "Lists all defined baseboxes"
View
33 lib/veewee/session.rb
@@ -349,7 +349,7 @@ def self.add_ssh_nat_mapping(boxname)
def self.destroy_vm(boxname)
load_definition(boxname)
-
+ @vboxcmd=determine_vboxcmd
#:destroy_medium => :delete, will delete machine + all media attachments
#vm.destroy(:destroy_medium => :delete)
##vm.destroy(:destroy_image => true)
@@ -366,12 +366,19 @@ def self.destroy_vm(boxname)
if (!vm.nil? && !(vm.powered_off?))
puts "Shutting down vm #{boxname}"
#We force it here, maybe vm.shutdown is cleaner
- vm.stop
+ begin
+ vm.stop
+ rescue VirtualBox::Exceptions::InvalidVMStateException
+ puts "There was problem sending the stop command because the machine is in an Invalid state"
+ puts "Please verify leftovers from a previous build in your vm folder"
+ exit
+ end
+ sleep 3
end
- sleep 3
+
command="#{@vboxcmd} unregistervm '#{boxname}' --delete"
-
+ puts command
puts "Deleting vm #{boxname}"
#Exec and system stop the execution here
@@ -390,14 +397,14 @@ def self.destroy_vm(boxname)
command="#{@vboxcmd} closemedium disk '#{d.location}'"
end
- command="#{@vboxcmd} closemedium disk '#{d.location}' --delete"
+ #command="#{@vboxcmd} closemedium disk '#{d.location}' --delete"
puts "Deleting disk #{d.location}"
puts "#{command}"
Veewee::Shell.execute("#{command}")
if File.exists?(d.location)
- puts "We tried to delete the disk file via vmware '#{d.location} but failed"
+ puts "We tried to delete the disk file via virtualbox '#{d.location} but failed"
puts "Removing it manually"
FileUtils.rm(d.location)
exit
@@ -407,9 +414,6 @@ def self.destroy_vm(boxname)
break
end
end
-
-
-
end
def self.create_vm(boxname,force=false)
@@ -488,6 +492,8 @@ def self.create_disk(boxname)
end
end
+ @vboxcmd=determine_vboxcmd
+
if !found
puts "Creating new harddrive of size #{@definition[:disk_size].to_i} "
@@ -500,12 +506,13 @@ def self.create_disk(boxname)
##VirtualBox::Global.global.max_vdi_size=1000000
#newdisk.save
- command="VBoxManage list systemproperties|grep '^Default machine'|cut -d ':' -f 2|sed -e 's/^[ ]*//'"
+ command="#{@vboxcmd} list systemproperties|grep '^Default machine'|cut -d ':' -f 2|sed -e 's/^[ ]*//'"
results=IO.popen("#{command}")
place=results.gets.chop
results.close
command ="#{@vboxcmd} createhd --filename '#{place}/#{boxname}/#{boxname}.#{@definition[:disk_format]}' --size '#{@definition[:disk_size].to_i}' --format #{@definition[:disk_format]} > /dev/null"
+ puts "#{command}"
Veewee::Shell.execute("#{command}")
end
@@ -527,8 +534,10 @@ def self.add_sata_controller(boxname)
def self.attach_disk(boxname)
location=boxname+"."+@definition[:disk_format].downcase
-
- command="VBoxManage list systemproperties|grep '^Default machine'|cut -d ':' -f 2|sed -e 's/^[ ]*//'"
+
+ @vboxcmd=determine_vboxcmd
+
+ command="#{@vboxcmd} list systemproperties|grep '^Default machine'|cut -d ':' -f 2|sed -e 's/^[ ]*//'"
results=IO.popen("#{command}")
place=results.gets.chop
results.close
View
29 lib/veewee/transaction.rb
@@ -19,23 +19,29 @@ def transaction2(name,options= { :checksum => "nochecksum"}, &block)
end
def self.remove_snapshot_vmachine(vmname,snapname)
- Veewee::Shell.execute("VBoxManage snapshot '#{vmname}' delete '#{snapname}'")
+ @vboxcmd=Veewee::Session.determine_vboxcmd
+
+ Veewee::Shell.execute("#{@vboxcmd} snapshot '#{vmname}' delete '#{snapname}'")
end
def self.create_snapshot_vmachine(vmname,snapname)
- Veewee::Shell.execute("VBoxManage snapshot '#{vmname}' take '#{snapname}'")
+ @vboxcmd=Veewee::Session.determine_vboxcmd
+
+ Veewee::Shell.execute("#{@vboxcmd} snapshot '#{vmname}' take '#{snapname}'")
end
def self.load_snapshot_vmachine(vmname,snapname)
+ @vboxcmd=Veewee::Session.determine_vboxcmd
+
#if it running , shutdown first
if (state_vmachine(vmname)=="running")
stop_vmachine(vmname)
end
- Veewee::Shell.execute("VBoxManage snapshot '#{vmname}' restore '#{snapname}'")
+ Veewee::Shell.execute("#{@vboxcmd} snapshot '#{vmname}' restore '#{snapname}'")
#sometimes it takes some time to shutdown
sleep 2
- Veewee::Shell.execute("VBoxManage startvm '#{vmname}'")
+ Veewee::Shell.execute("#{@vboxcmd} startvm '#{vmname}'")
end
def self.snapshot_exists(vmname,snapname)
@@ -58,10 +64,11 @@ def self.snapshot_version_exists(vmname,snapname)
def self.rollback_snapshot(vmname,snapname)
delete_flag=false
+ @vboxcmd=Veewee::Session.determine_vboxcmd
savestate_recover=false
if (state_vmachine(vmname)=="running")
- Veewee::Shell.execute("VBoxManage controlvm '#{vmname}' savestate")
+ Veewee::Shell.execute("#{@vboxcmd} controlvm '#{vmname}' savestate")
savestate_recover=true
end
@@ -77,7 +84,7 @@ def self.rollback_snapshot(vmname,snapname)
sleep 2
- Veewee::Shell.execute("VBoxManage startvm '#{vmname}'")
+ Veewee::Shell.execute("#{@vboxcmd} startvm '#{vmname}'")
if (savestate_recover)
#Recovering from savestate nukes the network! This trick seem to work
@@ -85,9 +92,9 @@ def self.rollback_snapshot(vmname,snapname)
#http://www.virtualbox.org/ticket/5666
#http://www.virtualbox.org/ticket/5654
#This is supposed to be fixed: http://www.virtualbox.org/changeset/25205 but alas
- Veewee::Shell.execute("VBoxManage controlvm '#{vmname}' nic1 nat")
- Veewee::Shell.execute("VBoxManage controlvm '#{vmname}' setlinkstate1 off")
- Veewee::Shell.execute("VBoxManage controlvm '#{vmname}' setlinkstate1 on")
+ Veewee::Shell.execute("#{@vboxcmd} controlvm '#{vmname}' nic1 nat")
+ Veewee::Shell.execute("#{@vboxcmd} controlvm '#{vmname}' setlinkstate1 off")
+ Veewee::Shell.execute("#{@vboxcmd} controlvm '#{vmname}' setlinkstate1 on")
sleep 2
#hmmm, virtualbox => when recovering from a restore , it looses the nat settings!!! So we need to do this again!!
@@ -101,7 +108,9 @@ def self.rollback_snapshot(vmname,snapname)
def self.list_snapshots(vmname)
- snapshotresult=Veewee::Shell.execute("VBoxManage showvminfo --machinereadable '#{vmname}' |grep ^SnapshotName| cut -d '=' -f 2").stdout
+ @vboxcmd=Veewee::Session.determine_vboxcmd
+
+ snapshotresult=Veewee::Shell.execute("#{@vboxcmd} showvminfo --machinereadable '#{vmname}' |grep ^SnapshotName| cut -d '=' -f 2").stdout
snapshotlist=snapshotresult.gsub(/\"/,'').split(/\n/)
return snapshotlist
end
View
5 templates/Archlinux-experimental/autorun0
@@ -1,3 +1,6 @@
#!/bin/bash
-echo "we made it to autorun"
+echo "We are installing archlinux through the livecd of System Rescue"
+echo "Please wait while we do the grunt work ."
+
+echo "Occassinally this hangs because of network issues to the archlinux mirrors"
View
2  templates/Archlinux-experimental/definition.rb
@@ -13,7 +13,7 @@
],
:kickstart_port => "7122", :kickstart_timeout => "10000",:kickstart_file => "autorun0",
:ssh_login_timeout => "10000",:ssh_user => "root", :ssh_password => "vagrant",:ssh_key => "",
- :ssh_host_port => "2222", :ssh_guest_port => "22",
+ :ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "sh '%f'",
:shutdown_cmd => "shutdown -H",
:postinstall_files => [ "postinstall.sh"],:postinstall_timeout => "10000"
View
74 templates/Archlinux-experimental/postinstall.sh
@@ -36,6 +36,8 @@ done
#enable a mirror
#Partition the disk
+#This assumes a predefined layout - customize to your own liking
+
sfdisk --force /dev/sda <<EOF
# partition table of /dev/sda
unit: sectors
@@ -61,8 +63,14 @@ mount /dev/sda1 /newarch
mkdir -p /newarch/var/lib/pacman
#setting pacman - mirror - Belgium
+#Customize to your own liking
sed -i 's/^#\(.*kangaroot.*\)/\1/' /etc/pacman.d/mirrorlist
+# https://wiki.archlinux.org/index.php/Mirrors#List_by_speed
+# pacman -S reflector
+# export LC_ALL=C
+# reflector -c Belgium -l 8 -r -o /etc/pacman.d/mirrorlist
+
pacman -Sy -r /newarch
#pacman: error while loading shared libraries: libbz2.so.1.0: cannot open shared object file: No such file or directory
@@ -84,7 +92,6 @@ mount -t sysfs sys /newarch/sys
mount -o bind /dev /newarch/dev
chroot /newarch pacman --noconfirm -S kernel26
-#chroot /newarch pacman --noconfir -S packagename
#set the mirror list within the machine
chroot /newarch sed -i 's/^#\(.*kangaroot.*\)/\1/' /etc/pacman.d/mirrorlist
@@ -97,6 +104,7 @@ echo "echo '/dev/sda2 swap swap defaults
#/etc/rc.conf
#hostname
+
chroot /newarch sed -i 's/^HOSTNAME=\(.*\)/HOSTNAME=vagrant-arch/' /etc/rc.conf
#gateway
@@ -106,13 +114,69 @@ chroot /newarch sed -i 's/^HOSTNAME=\(.*\)/HOSTNAME=vagrant-arch/' /etc/rc.conf
#grub
-chroot /newarch grep -v rootfs /proc/mounts > /etc/mtab
+echo "grep -v rootfs /proc/mounts > /etc/mtab" |chroot /newarch sh -
chroot /newarch grub-install /dev/sda
-chroot /newarch cp -a /usr/lib/grub/i386-pc/* /boot/grub
+echo "cp -a /usr/lib/grub/i386-pc/* /boot/grub" | chroot /newarch sh -
+
+#/boot/grub/menu.lst
+
+echo "sed -i 's:^kernel\(.*\)$:kernel /boot/vmlinuz26 root=/dev/sda1 ro:' /boot/grub/menu.lst" | chroot /newarch sh -
+echo "sed -i 's:^initrd\(.*\)$:initrd /boot/kernel26.img:' /boot/grub/menu.lst" | chroot /newarch sh -
+
+#Configure ssh
+chroot /newarch pacman --noconfirm -S openssh
+
+#Still errors
+echo "sed -i 's:^DAEMONS\(.*\))$:DAEMONS\1 sshd):' /etc/rc.conf" | chroot /newarch sh -
+echo "echo 'sshd:ALL' > /etc/hosts.allow" | chroot /newarch sh -
+echo "echo 'ALL:ALL' > /etc/hosts.deny" | chroot /newarch sh -
+
+#Configure Sudo
+chroot /newarch pacman --noconfirm -S sudo
+echo "echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers" | chroot /newarch sh -
+
+#create vagrant user / password vagrant
+chroot /newarch useradd -m -r vagrant -p '$1$MPmczGP9$1SeNO4bw5YgiEJuo/ZkWq1'
+
+#get some ruby running
+chroot /newarch pacman --noconfirm -S git curl gcc make
+echo "bash < <( curl -L http://bit.ly/rvm-install-system-wide )"| chroot /newarch /bin/bash -
+echo "/usr/local/bin/rvm install ruby-1.8.7 "| chroot /newarch sh -
+echo "/usr/local/bin/rvm use ruby-1.8.7 --default "| chroot /newarch sh -
+
+
+#Installing chef & Puppet
+echo ". /usr/local/lib/rvm ; gem install chef --no-ri --no-rdoc"| chroot /newarch sh -
+echo ". /usr/local/lib/rvm ; gem install puppet --no-ri --no-rdoc"| chroot /newarch sh -
+
+#Installing vagrant keys
+echo "creating vagrant ssh keys"
+chroot /newarch mkdir /home/vagrant/.ssh
+chroot /newarch chmod 700 /home/vagrant/.ssh
+chroot /newarch cd /home/vagrant/.ssh
+chroot /newarch wget --no-check-certificate 'http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub' -O /home/vagrant/.ssh/authorized_keys
+chroot /newarch chmod 600 /home/vagrant/.ssh/authorized_keys
+chroot /newarch chown -R vagrant /home/vagrant/.ssh
+
+echo "adding rvm to global bash rc"
+echo "echo '. /usr/local/lib/rvm' >> /etc/bash/bash.rc" | chroot /newarch sh -
+
+#https://wiki.archlinux.org/index.php/VirtualBox
+#kernel pacman -S kernel26-headers
+chroot /newarch pacman --noconfirm -S kernel26-headers
+#/bin/cp -f /root/.vbox_version /newarch/root/.vbox_version
+#VBOX_VERSION=$(cat /home/vagrant/.vbox_version)
+##INstalling the virtualbox guest additions
+#cd /tmp
+#wget http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso
+#mount -o loop VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
+#sh /mnt/VBoxLinuxAdditions.run
+#chroot /newarch umount /mnt
+#rm VBoxGuestAdditions_$VBOX_VERSION.iso
+
+echo "sed -i 's:^DAEMONS\(.*\))$:DAEMONS\1 rc.vboxadd):' /etc/rc.conf" | chroot /newarch sh -
-#create vagrant user
-#chef
cd /
umount /newarch/{proc,sys,dev}
umount /newarch
View
2  templates/CentOS-4.8-i386/definition.rb
@@ -6,7 +6,7 @@
:boot_wait => "10",:boot_cmd_sequence => [ 'linux text ks=http://%IP%:%PORT%/ks.cfg<Enter>' ],
:kickstart_port => "7122", :kickstart_timeout => 10000,:kickstart_file => "ks.cfg",
:ssh_login_timeout => "100",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
- :ssh_host_port => "2222", :ssh_guest_port => "22",
+ :ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "echo '%p'|sudo -S sh '%f'",
:shutdown_cmd => "/sbin/halt -h -p",
:postinstall_files => [ "postinstall.sh"],:postinstall_timeout => 10000
View
2  templates/CentOS-5.5-i386-netboot/definition.rb
@@ -9,7 +9,7 @@
:boot_wait => "10",:boot_cmd_sequence => [ 'linux text ks=http://%IP%:%PORT%/ks.cfg<Enter>' ],
:kickstart_port => "7122", :kickstart_timeout => 10000,:kickstart_file => "ks.cfg",
:ssh_login_timeout => "100",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
-:ssh_host_port => "2222", :ssh_guest_port => "22",
+:ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "echo '%p'|sudo -S sh '%f'",
:shutdown_cmd => "/sbin/halt -h -p",
:postinstall_files => [ "postinstall.sh"],:postinstall_timeout => 10000
View
2  templates/CentOS-5.5-i386/definition.rb
@@ -8,7 +8,7 @@
],
:kickstart_port => "7122", :kickstart_timeout => 10000,:kickstart_file => "ks.cfg",
:ssh_login_timeout => "100",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
- :ssh_host_port => "2222", :ssh_guest_port => "22",
+ :ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "echo '%p'|sudo -S sh '%f'",
:shutdown_cmd => "/sbin/halt -h -p",
:postinstall_files => [ "postinstall.sh"],:postinstall_timeout => 10000
View
2  templates/Sysrescuecd-2.0.0-experimental/definition.rb
@@ -13,7 +13,7 @@
],
:kickstart_port => "7122", :kickstart_timeout => "10000",:kickstart_file => "autorun0",
:ssh_login_timeout => "10000",:ssh_user => "root", :ssh_password => "vagrant",:ssh_key => "",
- :ssh_host_port => "2222", :ssh_guest_port => "22",
+ :ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "sh '%f'",
:shutdown_cmd => "shutdown -H",
:postinstall_files => [ ],:postinstall_timeout => "10000"
View
2  templates/ubuntu-10.04.1-server-amd64/definition.rb
@@ -17,7 +17,7 @@
],
:kickstart_port => "7122", :kickstart_timeout => "10000",:kickstart_file => "preseed.cfg",
:ssh_login_timeout => "10000",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
- :ssh_host_port => "2222", :ssh_guest_port => "22",
+ :ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "echo '%p'|sudo -S sh '%f'",
:shutdown_cmd => "shutdown -H",
:postinstall_files => [ "postinstall.sh"],:postinstall_timeout => "10000"
View
2  templates/ubuntu-10.04.1-server-i386/definition.rb
@@ -17,7 +17,7 @@
],
:kickstart_port => "7122", :kickstart_timeout => "10000",:kickstart_file => "preseed.cfg",
:ssh_login_timeout => "10000",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
- :ssh_host_port => "2222", :ssh_guest_port => "22",
+ :ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "echo '%p'|sudo -S sh '%f'",
:shutdown_cmd => "shutdown -H",
:postinstall_files => [ "postinstall.sh"],:postinstall_timeout => "10000"
View
2  templates/ubuntu-10.10-server-amd64-netboot/definition.rb
@@ -17,7 +17,7 @@
],
:kickstart_port => "7122", :kickstart_timeout => "10000",:kickstart_file => "preseed.cfg",
:ssh_login_timeout => "10000",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
- :ssh_host_port => "2222", :ssh_guest_port => "22",
+ :ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "echo '%p'|sudo -S sh '%f'",
:shutdown_cmd => "shutdown -P now",
:postinstall_files => [ "postinstall.sh"],:postinstall_timeout => "10000"
View
2  templates/ubuntu-10.10-server-amd64/definition.rb
@@ -17,7 +17,7 @@
],
:kickstart_port => "7122", :kickstart_timeout => "10000",:kickstart_file => "preseed.cfg",
:ssh_login_timeout => "10000",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
- :ssh_host_port => "2222", :ssh_guest_port => "22",
+ :ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "echo '%p'|sudo -S sh '%f'",
:shutdown_cmd => "shutdown -P now",
:postinstall_files => [ "postinstall.sh"],:postinstall_timeout => "10000"
View
2  templates/ubuntu-10.10-server-i386-netboot/definition.rb
@@ -17,7 +17,7 @@
],
:kickstart_port => "7122", :kickstart_timeout => "10000",:kickstart_file => "preseed.cfg",
:ssh_login_timeout => "10000",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
- :ssh_host_port => "2222", :ssh_guest_port => "22",
+ :ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "echo '%p'|sudo -S sh '%f'",
:shutdown_cmd => "shutdown -P now",
:postinstall_files => [ "postinstall.sh"],:postinstall_timeout => "10000"
View
2  templates/ubuntu-10.10-server-i386/definition.rb
@@ -17,7 +17,7 @@
],
:kickstart_port => "7122", :kickstart_timeout => "10000",:kickstart_file => "preseed.cfg",
:ssh_login_timeout => "10000",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
- :ssh_host_port => "2222", :ssh_guest_port => "22",
+ :ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "echo '%p'|sudo -S sh '%f'",
:shutdown_cmd => "shutdown -P now",
:postinstall_files => [ "postinstall.sh"],:postinstall_timeout => "10000"
Please sign in to comment.
Something went wrong with that request. Please try again.