veewee 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/.gitignore +7 -0
  2. data/.rvmrc +2 -0
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +53 -0
  5. data/README.md +124 -0
  6. data/Rakefile +92 -0
  7. data/bin/veewee +79 -0
  8. data/iso/.gitignore +2 -0
  9. data/lib/vagrant_init.rb +1 -0
  10. data/lib/veewee/command.rb +66 -0
  11. data/lib/veewee/config.rb +5 -0
  12. data/lib/veewee/export.rb +81 -0
  13. data/lib/veewee/scancode.rb +108 -0
  14. data/lib/veewee/session.rb +712 -0
  15. data/lib/veewee/shell.rb +54 -0
  16. data/lib/veewee/ssh.rb +164 -0
  17. data/lib/veewee/transaction.rb +112 -0
  18. data/lib/veewee/version.rb +3 -0
  19. data/lib/veewee/web.rb +48 -0
  20. data/lib/veewee.rb +2 -0
  21. data/templates/CentOS-4.8-i386/definition.rb +14 -0
  22. data/templates/CentOS-4.8-i386/ks.cfg +45 -0
  23. data/templates/CentOS-4.8-i386/postinstall.sh +47 -0
  24. data/templates/CentOS-5.5-i386/definition.rb +16 -0
  25. data/templates/CentOS-5.5-i386/ks.cfg +45 -0
  26. data/templates/CentOS-5.5-i386/postinstall.sh +48 -0
  27. data/templates/CentOS-5.5-i386-netboot/definition.rb +17 -0
  28. data/templates/CentOS-5.5-i386-netboot/ks.cfg +45 -0
  29. data/templates/CentOS-5.5-i386-netboot/postinstall.sh +48 -0
  30. data/templates/ubuntu-10.04.1-server-amd64/definition.rb +25 -0
  31. data/templates/ubuntu-10.04.1-server-amd64/postinstall.sh +33 -0
  32. data/templates/ubuntu-10.04.1-server-amd64/preseed.cfg +87 -0
  33. data/templates/ubuntu-10.04.1-server-i386/definition.rb +25 -0
  34. data/templates/ubuntu-10.04.1-server-i386/postinstall.sh +43 -0
  35. data/templates/ubuntu-10.04.1-server-i386/postinstall2.sh +9 -0
  36. data/templates/ubuntu-10.04.1-server-i386/preseed.cfg +87 -0
  37. data/templates/ubuntu-10.10-server-amd64/definition.rb +25 -0
  38. data/templates/ubuntu-10.10-server-amd64/postinstall.sh +43 -0
  39. data/templates/ubuntu-10.10-server-amd64/postinstall2.sh +9 -0
  40. data/templates/ubuntu-10.10-server-amd64/preseed.cfg +87 -0
  41. data/templates/ubuntu-10.10-server-i386/definition.rb +25 -0
  42. data/templates/ubuntu-10.10-server-i386/postinstall.sh +43 -0
  43. data/templates/ubuntu-10.10-server-i386/postinstall2.sh +9 -0
  44. data/templates/ubuntu-10.10-server-i386/preseed.cfg +87 -0
  45. data/trials/docu-vbox.txt +83 -0
  46. data/trials/f.rb +29 -0
  47. data/trials/t.rb +15 -0
  48. data/veewee.gemspec +30 -0
  49. metadata +219 -0
@@ -0,0 +1,54 @@
1
+ #require 'open4'
2
+
3
+ module Veewee
4
+ class Shell
5
+
6
+ def self.execute2(command,options = {})
7
+
8
+ IO.popen("#{command}") { |f| print f }
9
+ end
10
+
11
+ #pty allows you to gradually see the output of a local command
12
+ #http://www.shanison.com/?p=415
13
+ def self.execute(command, options = {} )
14
+ require "pty"
15
+ begin
16
+ PTY.spawn( command ) do |r, w, pid|
17
+ begin
18
+ r.each { }
19
+ #r.each { |line| print line;}
20
+
21
+ rescue Errno::EIO
22
+ end
23
+ end
24
+ rescue PTY::ChildExited => e
25
+ puts "The child process exited!"
26
+ end
27
+ end
28
+
29
+ #occassinally fails with 'no child processes
30
+ def self.execute3(command, options = {} )
31
+ defaults= { :port => "22", :exitcode => "0", :user => "root"}
32
+ options=defaults.merge(options)
33
+
34
+ status = POpen4::popen4(command) do |stdout,stderr,stdin|
35
+ stdout.each do |line|
36
+ puts line
37
+ end
38
+ end
39
+
40
+ @status=status.to_i
41
+
42
+ if (@status.to_s != options[:exitcode] )
43
+ if (options[:exitcode]=="*")
44
+ #its a test so we don't need to worry
45
+ else
46
+ raise "Exitcode was not what we expected"
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+
53
+ end #Class
54
+ end #Module
data/lib/veewee/ssh.rb ADDED
@@ -0,0 +1,164 @@
1
+ module Veewee
2
+ class Ssh
3
+
4
+ def self.when_ssh_login_works(ip="localhost", options = { } , &block)
5
+
6
+ defaults={ :port => '22', :timeout => 200 , :user => 'vagrant', :password => 'vagrant'}
7
+
8
+ options=defaults.merge(options)
9
+
10
+ puts
11
+ puts "Trying ssh login with user #{options[:user]} to sshd on port => #{options[:port]}"
12
+
13
+ begin
14
+ Timeout::timeout(options[:timeout]) do
15
+ connected=false
16
+ while !connected do
17
+ begin
18
+ print "."
19
+ Net::SSH.start(ip, options[:user], { :port => options[:port] , :password => options[:password], :paranoid => false, :timeout => options[:timeout] }) do |ssh|
20
+ block.call(ip);
21
+ puts ""
22
+ return true
23
+ end
24
+ rescue Net::SSH::Disconnect,Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNABORTED, Errno::ECONNRESET, Errno::ENETUNREACH
25
+ sleep 5
26
+ end
27
+ end
28
+ end
29
+ rescue Timeout::Error
30
+ raise 'ssh timeout'
31
+ end
32
+ puts ""
33
+ return false
34
+ end
35
+
36
+
37
+ def self.transfer_file(host,filename,destination = '.' , options)
38
+ Net::SSH.start( host,options[:user],options ) do |ssh|
39
+ puts "Transferring #{filename} to #{destination} "
40
+ ssh.scp.upload!( filename, destination ) do |ch, name, sent, total|
41
+ # print "\r#{destination}: #{(sent.to_f * 100 / total.to_f).to_i}%"
42
+ print "."
43
+
44
+ end
45
+ end
46
+ puts
47
+ end
48
+
49
+
50
+ #we need to try the actual login because vbox gives us a connect
51
+ #after the machine boots
52
+ def self.execute_when_tcp_available(ip="localhost", options = { } , &block)
53
+
54
+ defaults={ :port => 22, :timeout => 2 , :pollrate => 5}
55
+
56
+ options=defaults.merge(options)
57
+
58
+ begin
59
+ Timeout::timeout(options[:timeout]) do
60
+ connected=false
61
+ while !connected do
62
+ begin
63
+ puts "trying connection"
64
+ s = TCPSocket.new(ip, options[:port])
65
+ s.close
66
+ block.call(ip);
67
+ return true
68
+ rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
69
+ sleep options[:pollrate]
70
+ end
71
+ end
72
+ end
73
+ rescue Timeout::Error
74
+ raise 'timeout connecting to port'
75
+ end
76
+
77
+ return false
78
+ end
79
+
80
+ def self.execute(host,command, options = { :progress => "on"} )
81
+ defaults= { :port => "22", :exitcode => "0", :user => "root"}
82
+ options=defaults.merge(options)
83
+ @pid=""
84
+ @stdin=command
85
+ @stdout=""
86
+ @stderr=""
87
+ @status=-99999
88
+
89
+ puts "Executing command: #{command}"
90
+
91
+ Net::SSH.start(host, options[:user], { :port => options[:port], :password => options[:password], :paranoid => false }) do |ssh|
92
+
93
+ # open a new channel and configure a minimal set of callbacks, then run
94
+ # the event loop until the channel finishes (closes)
95
+ channel = ssh.open_channel do |ch|
96
+
97
+ #request pty for sudo stuff and so
98
+ ch.request_pty do |ch, success|
99
+ raise "Error requesting pty" unless success
100
+ end
101
+
102
+
103
+ ch.exec "#{command}" do |ch, success|
104
+ raise "could not execute command" unless success
105
+
106
+
107
+
108
+ # "on_data" is called when the process writes something to stdout
109
+ ch.on_data do |c, data|
110
+ @stdout+=data
111
+
112
+ puts data
113
+
114
+ end
115
+
116
+ # "on_extended_data" is called when the process writes something to stderr
117
+ ch.on_extended_data do |c, type, data|
118
+ @stderr+=data
119
+
120
+ puts data
121
+
122
+ end
123
+
124
+ #exit code
125
+ #http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/a806b0f5dae4e1e2
126
+ channel.on_request("exit-status") do |ch, data|
127
+ exit_code = data.read_long
128
+ @status=exit_code
129
+ if exit_code > 0
130
+ puts "ERROR: exit code #{exit_code}"
131
+ else
132
+ #puts "Successfully executed"
133
+ end
134
+ end
135
+
136
+ channel.on_request("exit-signal") do |ch, data|
137
+ puts "SIGNAL: #{data.read_long}"
138
+ end
139
+
140
+ ch.on_close {
141
+ #puts "done!"
142
+ }
143
+ #status=ch.exec "echo $?"
144
+ end
145
+ end
146
+ channel.wait
147
+ end
148
+
149
+
150
+ if (@status.to_s != options[:exitcode] )
151
+ if (options[:exitcode]=="*")
152
+ #its a test so we don't need to worry
153
+ else
154
+ raise "Exitcode was not what we expected"
155
+ end
156
+
157
+ end
158
+
159
+ end
160
+
161
+
162
+
163
+ end #Class
164
+ end #Module
@@ -0,0 +1,112 @@
1
+ module Veewee
2
+ class Transaction
3
+
4
+ def transaction(name,params, &block)
5
+ end
6
+
7
+ def transaction2(name,options= { :checksum => "nochecksum"}, &block)
8
+ if snapshot_exists(@vmname,name+"-"+options[:checksum])
9
+ load_snapshot_vmachine(@vmname,name+"-"+options[:checksum])
10
+ else
11
+ if snapshot_version_exists(@vmname,name)
12
+ rollback_snapshot(@vmname,name)
13
+ #rollback to snapshot prior to this one
14
+ end
15
+ yield
16
+ create_snapshot_vmachine(@vmname,name+"-"+options[:checksum])
17
+ end
18
+ #end
19
+ end
20
+
21
+ def self.remove_snapshot_vmachine(vmname,snapname)
22
+ Veewee::Shell.execute("VBoxManage snapshot '#{vmname}' delete '#{snapname}'")
23
+ end
24
+
25
+ def self.create_snapshot_vmachine(vmname,snapname)
26
+ Veewee::Shell.execute("VBoxManage snapshot '#{vmname}' take '#{snapname}'")
27
+ end
28
+
29
+ def self.load_snapshot_vmachine(vmname,snapname)
30
+ #if it running , shutdown first
31
+ if (state_vmachine(vmname)=="running")
32
+ stop_vmachine(vmname)
33
+ end
34
+
35
+ Veewee::Shell.execute("VBoxManage snapshot '#{vmname}' restore '#{snapname}'")
36
+ #sometimes it takes some time to shutdown
37
+ sleep 2
38
+ Veewee::Shell.execute("VBoxManage startvm '#{vmname}'")
39
+ end
40
+
41
+ def self.snapshot_exists(vmname,snapname)
42
+ list_snapshots(vmname).each { |name|
43
+ if (name==snapname) then
44
+ return true
45
+ end
46
+ }
47
+ return false
48
+ end
49
+
50
+ def self.snapshot_version_exists(vmname,snapname)
51
+ list_snapshots(vmname).each { |name|
52
+ if name.match(/^#{snapname}-/) then
53
+ return true
54
+ end
55
+ }
56
+ return false
57
+ end
58
+
59
+ def self.rollback_snapshot(vmname,snapname)
60
+ delete_flag=false
61
+
62
+ savestate_recover=false
63
+ if (state_vmachine(vmname)=="running")
64
+ Veewee::Shell.execute("VBoxManage controlvm '#{vmname}' savestate")
65
+ savestate_recover=true
66
+ end
67
+
68
+ list_snapshots(vmname).each { |name|
69
+ if name.match(/^#{snapname}-/) then
70
+ delete_flag=true
71
+ end
72
+ if (delete_flag) then
73
+ remove_snapshot_vmachine(vmname,name)
74
+ end
75
+ }
76
+
77
+
78
+ sleep 2
79
+
80
+ Veewee::Shell.execute("VBoxManage startvm '#{vmname}'")
81
+
82
+ if (savestate_recover)
83
+ #Recovering from savestate nukes the network! This trick seem to work
84
+ #Also within the vm /etc/init.d/networking restart , but that is OS specific
85
+ #http://www.virtualbox.org/ticket/5666
86
+ #http://www.virtualbox.org/ticket/5654
87
+ #This is supposed to be fixed: http://www.virtualbox.org/changeset/25205 but alas
88
+ Veewee::Shell.execute("VBoxManage controlvm '#{vmname}' nic1 nat")
89
+ Veewee::Shell.execute("VBoxManage controlvm '#{vmname}' setlinkstate1 off")
90
+ Veewee::Shell.execute("VBoxManage controlvm '#{vmname}' setlinkstate1 on")
91
+ sleep 2
92
+
93
+ #hmmm, virtualbox => when recovering from a restore , it looses the nat settings!!! So we need to do this again!!
94
+ #thebox.ssh_enable_vmachine({:hostport => host_port , :guestport => 22} )
95
+ #http://www.virtualbox.org/changeset/25402
96
+ #[25402]: NAT: re-establish port-forwarding after savestate / restore state
97
+
98
+ end
99
+
100
+ end
101
+
102
+
103
+ def self.list_snapshots(vmname)
104
+ snapshotresult=Veewee::Shell.execute("VBoxManage showvminfo --machinereadable '#{vmname}' |grep ^SnapshotName| cut -d '=' -f 2").stdout
105
+ snapshotlist=snapshotresult.gsub(/\"/,'').split(/\n/)
106
+ return snapshotlist
107
+ end
108
+
109
+ end
110
+ end
111
+
112
+
@@ -0,0 +1,3 @@
1
+ module Veewee
2
+ VERSION = "0.0.2"
3
+ end
data/lib/veewee/web.rb ADDED
@@ -0,0 +1,48 @@
1
+ module Veewee
2
+ class Web
3
+
4
+ require 'webrick'
5
+ include WEBrick
6
+
7
+ class FileServlet < WEBrick::HTTPServlet::AbstractServlet
8
+
9
+ def initialize(server,localfile)
10
+ super(server)
11
+ @server=server
12
+ @localfile=localfile
13
+ end
14
+ def do_GET(request,response)
15
+ response['Content-Type']='text/plain'
16
+ response.status = 200
17
+ puts "Serving file #{@localfile}"
18
+ displayfile=File.open(@localfile,'r')
19
+ content=displayfile.read()
20
+ response.body=content
21
+ #If we shut too fast it might not get the complete file
22
+ sleep 2
23
+ @server.shutdown
24
+ end
25
+ end
26
+
27
+ def self.wait_for_request(filename,options={:timeout => 10, :web_dir => "", :port => 7125})
28
+
29
+ webrick_logger=WEBrick::Log.new("/dev/null", WEBrick::Log::INFO)
30
+
31
+ web_dir=options[:web_dir]
32
+ filename=filename
33
+ s= HTTPServer.new(
34
+ :Port => options[:port],
35
+ :Logger => webrick_logger,
36
+ :AccessLog => webrick_logger
37
+ )
38
+ s.mount("/#{filename}", FileServlet,File.join(web_dir,filename))
39
+ trap("INT"){
40
+ s.shutdown
41
+ puts "Stopping webserver"
42
+ exit
43
+ }
44
+ s.start
45
+ end
46
+
47
+ end
48
+ end
data/lib/veewee.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'vagrant'
2
+ require 'veewee/command'
@@ -0,0 +1,14 @@
1
+ Veewee::Session.declare( {
2
+ :cpu_count => '1', :memory_size=> '384',
3
+ :disk_size => '10140', :disk_format => 'VDI',:disk_size => '10240' ,
4
+ :os_type_id => 'RedHat',
5
+ :iso_file => "CentOS-4.8-i386-bin-DVD.iso", :iso_src => "", :iso_md5 => "", :iso_download_timeout => 1000,
6
+ :boot_wait => "10",:boot_cmd_sequence => [ 'linux text ks=http://%IP%:%PORT%/ks.cfg<Enter>' ],
7
+ :kickstart_port => "7122", :kickstart_timeout => 10000,:kickstart_file => "ks.cfg",
8
+ :ssh_login_timeout => "100",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
9
+ :ssh_host_port => "2222", :ssh_guest_port => "22",
10
+ :sudo_cmd => "echo '%p'|sudo -S sh '%f'",
11
+ :shutdown_cmd => "/sbin/halt -h -p",
12
+ :postinstall_files => [ "postinstall.sh"],:postinstall_timeout => 10000
13
+ }
14
+ )
@@ -0,0 +1,45 @@
1
+ # Kickstart file automatically generated by anaconda.
2
+
3
+ install
4
+ cdrom
5
+ lang en_US.UTF-8
6
+ langsupport --default=en_US.UTF-8 en_US.UTF-8
7
+ keyboard be-latin1
8
+ xconfig --card "VMWare" --videoram 16384 --hsync 31.5-37.9 --vsync 50-70 --resolution 800x600 --depth 16
9
+ network --device eth0 --bootproto dhcp
10
+ rootpw --iscrypted $1$vSG8FjAu$ekQ0grf16hS4G93HTPcco/
11
+ firewall --enabled --trust eth0 --ssh
12
+ selinux --enforcing
13
+ authconfig --enableshadow --enablemd5
14
+ timezone Europe/Brussels
15
+ bootloader --location=mbr
16
+ # The following is the partition information you requested
17
+ # Note that any partitions you deleted are not expressed
18
+ # here so unless you clear all partitions first, this is
19
+ # not guaranteed to work
20
+ clearpart --all --drives=sda --initlabel
21
+ part /boot --fstype ext3 --size=100 --ondisk=sda
22
+ part pv.2 --size=0 --grow --ondisk=sda
23
+ volgroup VolGroup00 --pesize=32768 pv.2
24
+ logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=528 --grow --maxsize=1056
25
+ logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
26
+ reboot
27
+
28
+ %packages
29
+ #@ admin-tools
30
+ #@ text-internet
31
+ #@ dialup
32
+ #@ smb-server
33
+ #@ web-server
34
+ #@ printing
35
+ #@ server-cfg
36
+ @ core
37
+ grub
38
+ e2fsprogs
39
+ lvm2
40
+
41
+ %post
42
+ /usr/sbin/groupadd vagrant
43
+ /usr/sbin/useradd vagrant -g vagrant -G wheel
44
+ echo "vagrant"|passwd --stdin vagrant
45
+ echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
@@ -0,0 +1,47 @@
1
+ #http://chrisadams.me.uk/2010/05/10/setting-up-a-centos-base-box-for-development-and-testing-with-vagrant/
2
+ #kernel source is needed for vbox additions
3
+
4
+ yum -y install gcc bzip2 make kernel-devel-`uname -r`
5
+
6
+ #yum -y update
7
+ #yum -y upgrade
8
+
9
+ yum -y install gcc-c++ zlib-devel openssl-devel readline-devel sqlite3-devel
10
+
11
+ yum -y erase wireless-tools gtk2 libX11 hicolor-icon-theme avahi freetype bitstream-vera-fonts
12
+
13
+ #Installing ruby
14
+ wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz
15
+ tar xzvf ruby-enterprise-1.8.7-2010.02.tar.gz
16
+ ./ruby-enterprise-1.8.7-2010.02/installer -a /opt/ruby
17
+ echo 'PATH=$PATH:/opt/ruby/bin/'> /etc/profile.d/rubyenterprise.sh
18
+ rm -rf ./ruby-enterprise-1.8.7-2010.02/
19
+ rm ruby-enterprise-1.8.7-2010.02.tar.gz
20
+
21
+ #Installing chef
22
+ /opt/ruby/bin/gem install chef
23
+
24
+ #Installing vagrant keys
25
+ mkdir /home/vagrant/.ssh
26
+ chmod 700 /home/vagrant/.ssh
27
+ cd /home/vagrant/.ssh
28
+ wget --no-check-certificate 'http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub' -O authorized_keys
29
+ chown -R vagrant /home/vagrant/.ssh
30
+
31
+ VBOX_VERSION=$(cat /home/vagrant/.vbox_version)
32
+ #INstalling the virtualbox guest additions
33
+ cd /tmp
34
+ wget http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso
35
+ mount -o loop VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
36
+ sh /mnt/VBoxLinuxAdditions-x86.run
37
+ umount /mnt
38
+
39
+ rm VBoxGuestAdditions_$VBOX_VERSION.iso
40
+
41
+ #poweroff -h
42
+
43
+ exit
44
+
45
+
46
+
47
+
@@ -0,0 +1,16 @@
1
+ Veewee::Session.declare( {
2
+ :cpu_count => '1', :memory_size=> '384',
3
+ :disk_size => '10140', :disk_format => 'VDI',:disk_size => '10240' ,
4
+ :os_type_id => 'RedHat',
5
+ :iso_file => "CentOS-5.5-i386-bin-DVD.iso", :iso_src => "", :iso_md5 => "75c92246479df172de41b14c9b966344", :iso_download_timeout => 1000,
6
+ :boot_wait => "10",:boot_cmd_sequence => [
7
+ 'linux text ks=http://%IP%:%PORT%/ks.cfg<Enter>'
8
+ ],
9
+ :kickstart_port => "7122", :kickstart_timeout => 10000,:kickstart_file => "ks.cfg",
10
+ :ssh_login_timeout => "100",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
11
+ :ssh_host_port => "2222", :ssh_guest_port => "22",
12
+ :sudo_cmd => "echo '%p'|sudo -S sh '%f'",
13
+ :shutdown_cmd => "/sbin/halt -h -p",
14
+ :postinstall_files => [ "postinstall.sh"],:postinstall_timeout => 10000
15
+ }
16
+ )
@@ -0,0 +1,45 @@
1
+ # Kickstart file automatically generated by anaconda.
2
+
3
+ install
4
+ cdrom
5
+ lang en_US.UTF-8
6
+ langsupport --default=en_US.UTF-8 en_US.UTF-8
7
+ keyboard be-latin1
8
+ xconfig --card "VMWare" --videoram 16384 --hsync 31.5-37.9 --vsync 50-70 --resolution 800x600 --depth 16
9
+ network --device eth0 --bootproto dhcp
10
+ rootpw --iscrypted $1$vSG8FjAu$ekQ0grf16hS4G93HTPcco/
11
+ firewall --enabled --trust eth0 --ssh
12
+ selinux --enforcing
13
+ authconfig --enableshadow --enablemd5
14
+ timezone Europe/Brussels
15
+ bootloader --location=mbr
16
+ # The following is the partition information you requested
17
+ # Note that any partitions you deleted are not expressed
18
+ # here so unless you clear all partitions first, this is
19
+ # not guaranteed to work
20
+ clearpart --all --drives=sda --initlabel
21
+ part /boot --fstype ext3 --size=100 --ondisk=sda
22
+ part pv.2 --size=0 --grow --ondisk=sda
23
+ volgroup VolGroup00 --pesize=32768 pv.2
24
+ logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=528 --grow --maxsize=1056
25
+ logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
26
+ reboot
27
+
28
+ %packages
29
+ #@ admin-tools
30
+ #@ text-internet
31
+ #@ dialup
32
+ #@ smb-server
33
+ #@ web-server
34
+ #@ printing
35
+ #@ server-cfg
36
+ @ core
37
+ grub
38
+ e2fsprogs
39
+ lvm2
40
+
41
+ %post
42
+ /usr/sbin/groupadd vagrant
43
+ /usr/sbin/useradd vagrant -g vagrant -G wheel
44
+ echo "vagrant"|passwd --stdin vagrant
45
+ echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
@@ -0,0 +1,48 @@
1
+ #http://chrisadams.me.uk/2010/05/10/setting-up-a-centos-base-box-for-development-and-testing-with-vagrant/
2
+ #kernel source is needed for vbox additions
3
+
4
+ yum -y install gcc bzip2 make kernel-devel-`uname -r`
5
+
6
+ #yum -y update
7
+ #yum -y upgrade
8
+
9
+ yum -y install gcc-c++ zlib-devel openssl-devel readline-devel sqlite3-devel
10
+
11
+ yum -y erase wireless-tools gtk2 libX11 hicolor-icon-theme avahi freetype bitstream-vera-fonts
12
+
13
+ #Installing ruby
14
+ wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz
15
+ tar xzvf ruby-enterprise-1.8.7-2010.02.tar.gz
16
+ ./ruby-enterprise-1.8.7-2010.02/installer -a /opt/ruby
17
+ echo 'PATH=$PATH:/opt/ruby/bin/'> /etc/profile.d/rubyenterprise.sh
18
+ rm -rf ./ruby-enterprise-1.8.7-2010.02/
19
+ rm ruby-enterprise-1.8.7-2010.02.tar.gz
20
+
21
+ #Installing chef
22
+ /opt/ruby/bin/gem install chef
23
+
24
+ #Installing vagrant keys
25
+ mkdir /home/vagrant/.ssh
26
+ chmod 700 /home/vagrant/.ssh
27
+ cd /home/vagrant/.ssh
28
+ wget --no-check-certificate 'http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub' -O authorized_keys
29
+ chown -R vagrant /home/vagrant/.ssh
30
+
31
+ VBOX_VERSION=$(cat /home/vagrant/.vbox_version)
32
+ #INstalling the virtualbox guest additions
33
+ cd /tmp
34
+ wget http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso
35
+ mount -o loop VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
36
+ sh /mnt/VBoxLinuxAdditions-x86.run
37
+ umount /mnt
38
+
39
+ rm VBoxGuestAdditions_$VBOX_VERSION.iso
40
+
41
+ #poweroff -h
42
+
43
+ exit
44
+
45
+
46
+
47
+
48
+
@@ -0,0 +1,17 @@
1
+ Veewee::Session.declare( {
2
+ :cpu_count => '1', :memory_size=> '384',
3
+ :disk_size => '10140', :disk_format => 'VDI',:disk_size => '10240' ,
4
+ :os_type_id => 'RedHat',
5
+ :iso_file => "CentOS-5.5-i386-netinstall.iso",
6
+ :iso_src => "http://mirror.bytemark.co.uk/centos/5.5/isos/i386/CentOS-5.5-i386-netinstall.iso",
7
+ :iso_md5 => "0172883a3039772165db073693debae5",
8
+ :iso_download_timeout => 1000,
9
+ :boot_wait => "10",:boot_cmd_sequence => [ 'linux text ks=http://%IP%:%PORT%/ks.cfg<Enter>' ],
10
+ :kickstart_port => "7122", :kickstart_timeout => 10000,:kickstart_file => "ks.cfg",
11
+ :ssh_login_timeout => "100",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
12
+ :ssh_host_port => "2222", :ssh_guest_port => "22",
13
+ :sudo_cmd => "echo '%p'|sudo -S sh '%f'",
14
+ :shutdown_cmd => "/sbin/halt -h -p",
15
+ :postinstall_files => [ "postinstall.sh"],:postinstall_timeout => 10000
16
+ }
17
+ )
@@ -0,0 +1,45 @@
1
+ # Kickstart file automatically generated by anaconda.
2
+
3
+ install
4
+ url --url=http://mirror.bytemark.co.uk/centos/5.5/os/i386
5
+ lang en_US.UTF-8
6
+ langsupport --default=en_US.UTF-8 en_US.UTF-8
7
+ keyboard uk
8
+ xconfig --card "VMWare" --videoram 16384 --hsync 31.5-37.9 --vsync 50-70 --resolution 800x600 --depth 16
9
+ network --device eth0 --bootproto dhcp
10
+ rootpw --iscrypted $1$vSG8FjAu$ekQ0grf16hS4G93HTPcco/
11
+ firewall --enabled --trust eth0 --ssh
12
+ selinux --enforcing
13
+ authconfig --enableshadow --enablemd5
14
+ timezone Europe/London
15
+ bootloader --location=mbr
16
+ # The following is the partition information you requested
17
+ # Note that any partitions you deleted are not expressed
18
+ # here so unless you clear all partitions first, this is
19
+ # not guaranteed to work
20
+ clearpart --all --drives=sda --initlabel
21
+ part /boot --fstype ext3 --size=100 --ondisk=sda
22
+ part pv.2 --size=0 --grow --ondisk=sda
23
+ volgroup VolGroup00 --pesize=32768 pv.2
24
+ logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=528 --grow --maxsize=1056
25
+ logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
26
+ reboot
27
+
28
+ %packages
29
+ #@ admin-tools
30
+ #@ text-internet
31
+ #@ dialup
32
+ #@ smb-server
33
+ #@ web-server
34
+ #@ printing
35
+ #@ server-cfg
36
+ @ core
37
+ grub
38
+ e2fsprogs
39
+ lvm2
40
+
41
+ %post
42
+ /usr/sbin/groupadd vagrant
43
+ /usr/sbin/useradd vagrant -g vagrant -G wheel
44
+ echo "vagrant"|passwd --stdin vagrant
45
+ echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers