Browse files

memory of ubuntu to 384, added full-upgrade to the preseed, first pro…

…totype for validating vagrant boxes
  • Loading branch information...
1 parent 0246d23 commit 4a8e26eed3821907085bf9cfb917362dc2f64505 @jedi4ever committed Feb 12, 2011
View
23 Gemfile.lock
@@ -2,10 +2,12 @@ PATH
remote: .
specs:
veewee (0.1.11)
+ cucumber
highline (~> 1.6.1)
net-ssh (~> 2.1.0)
popen4 (~> 0.1.2)
progressbar
+ rspec
thor (~> 0.14.6)
vagrant (~> 0.7.0)
@@ -15,13 +17,24 @@ GEM
Platform (0.4.0)
abstract (1.0.0)
archive-tar-minitar (0.5.2)
+ builder (2.1.2)
+ cucumber (0.8.5)
+ builder (~> 2.1.2)
+ diff-lcs (~> 1.1.2)
+ gherkin (~> 2.1.4)
+ json_pure (~> 1.4.3)
+ term-ansicolor (~> 1.0.4)
+ diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
ffi (0.6.3)
rake (>= 0.8.7)
+ gherkin (2.1.5)
+ trollop (~> 1.16.2)
highline (1.6.1)
i18n (0.5.0)
json (1.5.1)
+ json_pure (1.4.6)
mario (0.0.6)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
@@ -32,7 +45,17 @@ GEM
open4 (>= 0.4.0)
progressbar (0.9.0)
rake (0.8.7)
+ rspec (2.5.0)
+ rspec-core (~> 2.5.0)
+ rspec-expectations (~> 2.5.0)
+ rspec-mocks (~> 2.5.0)
+ rspec-core (2.5.1)
+ rspec-expectations (2.5.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.5.0)
+ term-ansicolor (1.0.5)
thor (0.14.6)
+ trollop (1.16.2)
vagrant (0.7.2)
archive-tar-minitar (= 0.5.2)
erubis (~> 2.6.6)
View
7 lib/veewee/command.rb
@@ -68,6 +68,13 @@ def export(boxname)
end
end
+ desc "validate [NAME]", "Validates a box against vagrant compliancy rules"
+ def validate(boxname)
+ if (!boxname.nil?)
+ Veewee::Session.validate_box(boxname)
+ end
+ end
+
end
end
View
27 lib/veewee/session.rb
@@ -592,6 +592,33 @@ def self.local_ip
Socket.do_not_reverse_lookup = orig
end
+ def self.validate_box(boxname)
+ require 'cucumber'
+
+ require 'cucumber/rspec/disable_option_parser'
+ require 'cucumber/cli/main'
+
+
+ feature_path=File.join(File.dirname(__FILE__),"..","..","validation","vagrant.feature")
+
+ features=Array.new
+ features[0]=feature_path
+
+
+ begin
+ # The dup is to keep ARGV intact, so that tools like ruby-debug can respawn.
+ failure = Cucumber::Cli::Main.execute(features.dup)
+ Kernel.exit(failure ? 1 : 0)
+ rescue SystemExit => e
+ Kernel.exit(e.status)
+ rescue Exception => e
+ STDERR.puts("#{e.message} (#{e.class})")
+ STDERR.puts(e.backtrace.join("\n"))
+ Kernel.exit(1)
+ end
+
+ end
+
def self.list_ostypes
puts
puts "Available os types:"
View
2 templates/CentOS-4.8-i386/postinstall.sh
@@ -41,7 +41,7 @@ rm VBoxGuestAdditions_$VBOX_VERSION.iso
#poweroff -h
-sed -i "s/Defaults requiretty/#Defaults requiretty/" /etc/sudoers
+sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
exit
View
3 templates/CentOS-5.5-i386-netboot/postinstall.sh
@@ -40,7 +40,8 @@ umount /mnt
rm VBoxGuestAdditions_$VBOX_VERSION.iso
-sed -i "s/Defaults requiretty/#Defaults requiretty/" /etc/sudoers
+sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
+
#poweroff -h
exit
View
2 templates/CentOS-5.5-i386/postinstall.sh
@@ -39,7 +39,7 @@ umount /mnt
rm VBoxGuestAdditions_$VBOX_VERSION.iso
-sed -i "s/Defaults requiretty/#Defaults requiretty/" /etc/sudoers
+sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
#poweroff -h
View
2 templates/ubuntu-10.04.1-server-amd64/definition.rb
@@ -1,5 +1,5 @@
Veewee::Session.declare( {
- :cpu_count => '1', :memory_size=> '256',
+ :cpu_count => '1', :memory_size=> '384',
:disk_size => '10140', :disk_format => 'VDI',:disk_size => '10240' ,
:os_type_id => 'Ubuntu_64',
:iso_file => "ubuntu-10.04.1-server-amd64.iso",
View
2 templates/ubuntu-10.04.1-server-amd64/preseed.cfg
@@ -65,7 +65,7 @@ d-i pkgsel/include string openssh-server ntp acpid
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
-d-i pkgsel/upgrade select none
+d-i pkgsel/upgrade select full-upgrade
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
View
2 templates/ubuntu-10.04.1-server-i386/definition.rb
@@ -1,5 +1,5 @@
Veewee::Session.declare( {
- :cpu_count => '1', :memory_size=> '256',
+ :cpu_count => '1', :memory_size=> '384',
:disk_size => '10140', :disk_format => 'VDI',:disk_size => '10240' ,
:os_type_id => 'Ubuntu',
:iso_file => "ubuntu-10.04.1-server-i386.iso",
View
2 templates/ubuntu-10.04.1-server-i386/preseed.cfg
@@ -65,7 +65,7 @@ d-i pkgsel/include string openssh-server ntp
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
-d-i pkgsel/upgrade select none
+d-i pkgsel/upgrade select full-upgrade
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
View
2 templates/ubuntu-10.10-server-amd64-netboot/preseed.cfg
@@ -65,7 +65,7 @@ d-i pkgsel/include string openssh-server ntp
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
-d-i pkgsel/upgrade select none
+d-i pkgsel/upgrade select full-upgrade
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
View
2 templates/ubuntu-10.10-server-amd64/definition.rb
@@ -1,5 +1,5 @@
Veewee::Session.declare( {
- :cpu_count => '1', :memory_size=> '256',
+ :cpu_count => '1', :memory_size=> '384',
:disk_size => '10140', :disk_format => 'VDI',
:os_type_id => 'Ubuntu_64',
:iso_file => "ubuntu-10.10-server-amd64.iso",
View
2 templates/ubuntu-10.10-server-amd64/preseed.cfg
@@ -65,7 +65,7 @@ d-i pkgsel/include string openssh-server ntp
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
-d-i pkgsel/upgrade select none
+d-i pkgsel/upgrade select full-upgrade
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
View
2 templates/ubuntu-10.10-server-i386-netboot/definition.rb
@@ -1,5 +1,5 @@
Veewee::Session.declare( {
- :cpu_count => '1', :memory_size=> '256',
+ :cpu_count => '1', :memory_size=> '384',
:disk_size => '10140', :disk_format => 'VDI',:disk_size => '10240' ,
:os_type_id => 'Ubuntu',
:iso_file => "ubuntu-10.10-server-i386-netboot.iso",
View
2 templates/ubuntu-10.10-server-i386-netboot/preseed.cfg
@@ -65,7 +65,7 @@ d-i pkgsel/include string openssh-server ntp
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
-d-i pkgsel/upgrade select none
+d-i pkgsel/upgrade select full-upgrade
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
View
2 templates/ubuntu-10.10-server-i386/definition.rb
@@ -1,5 +1,5 @@
Veewee::Session.declare( {
- :cpu_count => '1', :memory_size=> '256',
+ :cpu_count => '1', :memory_size=> '384',
:disk_size => '10140', :disk_format => 'VDI',:disk_size => '10240' ,
:os_type_id => 'Ubuntu',
:iso_file => "ubuntu-10.10-server-i386.iso",
View
2 templates/ubuntu-10.10-server-i386/preseed.cfg
@@ -65,7 +65,7 @@ d-i pkgsel/include string openssh-server ntp
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
-d-i pkgsel/upgrade select none
+d-i pkgsel/upgrade select full-upgrade
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
View
98 validation/features/steps/ssh_steps.rb
@@ -0,0 +1,98 @@
+# http://stackoverflow.com/questions/216202/why-does-an-ssh-remote-command-get-fewer-environment-variables-then-when-run-manu
+
+Given /^I have no public keys set$/ do
+ @auth_methods = %w(password)
+end
+
+Then /^I can ssh to "([^\"]*)" with the following credentials:$/ do |host, table|
+ @auth_methods ||= %w(publickey password)
+
+ credentials = table.hashes
+ credentials.each do |creds|
+ lambda {
+ Net::SSH.start(host, creds["username"], :password => creds["password"], :auth_methods => @auth_methods)
+ }.should_not raise_error(Net::SSH::AuthenticationFailed)
+ end
+end
+
+Then /^I can ssh to the following hosts with these credentials:$/ do |table|
+ @keys ||= []
+ @auth_methods ||= %w(password)
+ session_details = table.hashes
+
+ session_details.each do |session|
+ # initialize a list of keys and auth methods for just this session, as
+ # session can have session-specific keys mixed with global keys
+ session_keys = Array.new(@keys)
+ session_auth_methods = Array.new(@auth_methods)
+
+ # you can pass in a keyfile in the session details, so we need to
+ if session["keyfile"]
+ session_keys << session["keyfile"]
+ session_auth_methods << "publickey"
+ end
+
+ lambda {
+ Net::SSH.start(session["hostname"], session["username"], :password => session["password"],
+ :auth_methods => session_auth_methods,
+ :keys => session_keys)
+ }.should_not raise_error(Net::SSH::AuthenticationFailed)
+ end
+end
+
+Given /^I have the following public keys:$/ do |table|
+ @keys = []
+ public_key_paths = table.hashes
+
+ public_key_paths.each do |key|
+ File.exist?(key["keyfile"]).should be_true
+ @keys << key["keyfile"]
+ end
+
+ @auth_methods ||= %w(password)
+ @auth_methods << "publickey"
+end
+
+When /^I ssh to "([^\"]*)" with the following credentials:$/ do |hostname, table|
+ @keys = []
+ @auth_methods ||= %w(password)
+ session = table.hashes.first
+ session_keys = Array.new(@keys)
+ session_auth_methods = Array.new(@auth_methods)
+ if session["keyfile"]
+ session_keys << session["keyfile"]
+ session_auth_methods << "publickey"
+ end
+ session_port=22
+ if session["port"]
+ session_port=session["port"]
+ end
+
+
+ lambda {
+ @connection = Net::SSH.start(hostname, session["username"], :password => session["password"],
+ :auth_methods => session_auth_methods,
+# This is the list of authorization methods to try. It defaults to “publickey”, “hostbased”, “password”, and “keyboard-interactive”. (These are also the only authorization methods that are supported.) If
+#http://net-ssh.rubyforge.org/ssh/v1/chapter-2.html
+ :port => session_port,
+ :keys => session_keys)
+# :keys => session_keys,:verbose => :debug)
+ }.should_not raise_error
+end
+
+When /^I run "([^\"]*)"$/ do |command|
+# @connection.open_channel do |ch|
+#
+ #ch.request_pty do |ch, success|
+ #raise "Error requesting pty" unless success
+ #end
+ #@output = ch.exec(command)
+ #end
+ @output = @connection.exec!(command)
+
+end
+
+Then /^I should see "([^\"]*)" in the output$/ do |string|
+ @output.should =~ /#{string}/
+end
+
View
1 validation/support/env.rb
@@ -0,0 +1 @@
+require 'net/ssh'
View
27 validation/vagrant-private.key
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI
+w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP
+kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2
+hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO
+Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW
+yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQIBIwKCAQEA4iqWPJXtzZA68mKd
+ELs4jJsdyky+ewdZeNds5tjcnHU5zUYE25K+ffJED9qUWICcLZDc81TGWjHyAqD1
+Bw7XpgUwFgeUJwUlzQurAv+/ySnxiwuaGJfhFM1CaQHzfXphgVml+fZUvnJUTvzf
+TK2Lg6EdbUE9TarUlBf/xPfuEhMSlIE5keb/Zz3/LUlRg8yDqz5w+QWVJ4utnKnK
+iqwZN0mwpwU7YSyJhlT4YV1F3n4YjLswM5wJs2oqm0jssQu/BT0tyEXNDYBLEF4A
+sClaWuSJ2kjq7KhrrYXzagqhnSei9ODYFShJu8UWVec3Ihb5ZXlzO6vdNQ1J9Xsf
+4m+2ywKBgQD6qFxx/Rv9CNN96l/4rb14HKirC2o/orApiHmHDsURs5rUKDx0f9iP
+cXN7S1uePXuJRK/5hsubaOCx3Owd2u9gD6Oq0CsMkE4CUSiJcYrMANtx54cGH7Rk
+EjFZxK8xAv1ldELEyxrFqkbE4BKd8QOt414qjvTGyAK+OLD3M2QdCQKBgQDtx8pN
+CAxR7yhHbIWT1AH66+XWN8bXq7l3RO/ukeaci98JfkbkxURZhtxV/HHuvUhnPLdX
+3TwygPBYZFNo4pzVEhzWoTtnEtrFueKxyc3+LjZpuo+mBlQ6ORtfgkr9gBVphXZG
+YEzkCD3lVdl8L4cw9BVpKrJCs1c5taGjDgdInQKBgHm/fVvv96bJxc9x1tffXAcj
+3OVdUN0UgXNCSaf/3A/phbeBQe9xS+3mpc4r6qvx+iy69mNBeNZ0xOitIjpjBo2+
+dBEjSBwLk5q5tJqHmy/jKMJL4n9ROlx93XS+njxgibTvU6Fp9w+NOFD/HvxB3Tcz
+6+jJF85D5BNAG3DBMKBjAoGBAOAxZvgsKN+JuENXsST7F89Tck2iTcQIT8g5rwWC
+P9Vt74yboe2kDT531w8+egz7nAmRBKNM751U/95P9t88EDacDI/Z2OwnuFQHCPDF
+llYOUI+SpLJ6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ
+kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH
++vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ
+NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s=
+-----END RSA PRIVATE KEY-----
View
52 validation/vagrant.feature
@@ -0,0 +1,52 @@
+Feature: vagrant box validation
+ As a user of example.org
+ I need to login remotely
+
+Scenario: Checking login
+ When I ssh to "127.0.0.1" with the following credentials:
+ | username| password | port |
+ | vagrant | vagrant | 7222 |
+ And I run "whoami"
+ Then I should see "vagrant" in the output
+
+Scenario: Checking sudo
+ When I ssh to "127.0.0.1" with the following credentials:
+ | username| password | port |
+ | vagrant | vagrant | 7222 |
+ And I run "sudo whoami"
+ Then I should see "root" in the output
+
+Scenario: Checking ruby
+ When I ssh to "127.0.0.1" with the following credentials:
+ | username| password | port |
+ | vagrant | vagrant | 7222 |
+ And I run ". /etc/profile ;ruby --version 2> /dev/null 1> /dev/null; echo $?"
+ Then I should see "0" in the output
+
+Scenario: Checking gem
+ When I ssh to "127.0.0.1" with the following credentials:
+ | username| password | port |
+ | vagrant | vagrant | 7222 |
+ And I run ". /etc/profile; gem --version 2> /dev/null 1> /dev/null ; echo $?"
+ Then I should see "0" in the output
+
+Scenario: Checking chef
+ When I ssh to "127.0.0.1" with the following credentials:
+ | username| password | port |
+ | vagrant | vagrant | 7222 |
+ And I run ". /etc/profile ;chef-client --version 2> /dev/null 1>/dev/null; echo $?"
+ Then I should see "0" in the output
+
+Scenario: Checking puppet
+ When I ssh to "127.0.0.1" with the following credentials:
+ | username| password | port |
+ | vagrant | vagrant | 7222 |
+ And I run ". /etc/profile ; puppet --version 2> /dev/null 1>/dev/null; echo $?"
+ Then I should see "0" in the output
+
+Scenario: Checking puppet
+ When I ssh to "127.0.0.1" with the following credentials:
+ | username| password |keyfile | port |
+ | vagrant | vagrant | vagrant-private.key | 7222 |
+ And I run "whoami"
+ Then I should see "vagrant" in the output
View
1 validation/vagrant.pub
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key
View
2 veewee.gemspec
@@ -20,6 +20,8 @@ Gem::Specification.new do |s|
s.add_dependency "thor", "~> 0.14.6"
s.add_dependency "highline", "~> 1.6.1"
s.add_dependency "progressbar"
+ s.add_dependency "cucumber"
+ s.add_dependency "rspec"
s.add_development_dependency "bundler", ">= 1.0.0"

0 comments on commit 4a8e26e

Please sign in to comment.