From ae9f4a58c4bbd72d182e69a564c5e278b4ff13e9 Mon Sep 17 00:00:00 2001 From: Michal Papis Date: Tue, 4 Dec 2012 09:38:43 +0100 Subject: [PATCH 1/2] fix openbsd50 architecture customizations --- templates/openbsd50_amd64/definition.rb | 2 +- templates/openbsd50_i386/definition.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/openbsd50_amd64/definition.rb b/templates/openbsd50_amd64/definition.rb index ee3bdafa..21ea2307 100644 --- a/templates/openbsd50_amd64/definition.rb +++ b/templates/openbsd50_amd64/definition.rb @@ -2,7 +2,7 @@ :cpu_count => '1', :memory_size=> '256', :disk_size => '40960', :disk_format => 'VDI', :hostiocache => 'off', :os_type_id => 'OpenBSD_64', - :iso_file => "install50.iso", + :iso_file => "openbsd50_64.iso", :iso_src => "http://ftp3.usa.openbsd.org/pub/OpenBSD/5.0/amd64/install50.iso", :iso_md5 => "2b7d7ca2acc7f148bd92f065034f9f5a", :iso_download_timeout => "1000", diff --git a/templates/openbsd50_i386/definition.rb b/templates/openbsd50_i386/definition.rb index 843fb4dc..47f12b4e 100644 --- a/templates/openbsd50_i386/definition.rb +++ b/templates/openbsd50_i386/definition.rb @@ -1,8 +1,8 @@ Veewee::Session.declare({ :cpu_count => '1', :memory_size=> '256', :disk_size => '40960', :disk_format => 'VDI', :hostiocache => 'off', - :os_type_id => 'OpenBSD_64', - :iso_file => "install50.iso", + :os_type_id => 'OpenBSD_32', + :iso_file => "openbsd50_32.iso", :iso_src => "http://ftp.plig.net/pub/OpenBSD/5.0/i386/install50.iso", :iso_md5 => "2f0cc4df7dfe095f15a8ddadf8a02f69", :iso_download_timeout => "1000", @@ -12,7 +12,7 @@ # set the keyboard 'us', # set the hostname - 'OpenBSD50-x64', + 'OpenBSD50-x32', # Which nic to config ? [em0] '', # do you want dhcp ? [dhcp] @@ -57,7 +57,7 @@ 'cd', # Available cd-roms : cd0 '', -# Pathneame to sets ? [5.0/amd64] +# Pathneame to sets ? [5.0/i386] '', # Remove games and X '-game50.tgz', From 7655c0ed53ca68593bdeda993b07f7fdb9fb2886 Mon Sep 17 00:00:00 2001 From: Michal Papis Date: Tue, 4 Dec 2012 09:40:31 +0100 Subject: [PATCH 2/2] add openbsd 5.2 --- templates/openbsd52_amd64/README | 28 ++++++++ templates/openbsd52_amd64/definition.rb | 85 ++++++++++++++++++++++++ templates/openbsd52_amd64/postinstall.sh | 81 ++++++++++++++++++++++ templates/openbsd52_i386/README | 28 ++++++++ templates/openbsd52_i386/definition.rb | 85 ++++++++++++++++++++++++ templates/openbsd52_i386/postinstall.sh | 81 ++++++++++++++++++++++ 6 files changed, 388 insertions(+) create mode 100644 templates/openbsd52_amd64/README create mode 100644 templates/openbsd52_amd64/definition.rb create mode 100644 templates/openbsd52_amd64/postinstall.sh create mode 100644 templates/openbsd52_i386/README create mode 100644 templates/openbsd52_i386/definition.rb create mode 100644 templates/openbsd52_i386/postinstall.sh diff --git a/templates/openbsd52_amd64/README b/templates/openbsd52_amd64/README new file mode 100644 index 00000000..f512a152 --- /dev/null +++ b/templates/openbsd52_amd64/README @@ -0,0 +1,28 @@ +The boxes come with: +- ports system already installed +- puppet and chef +- check the postinstall.sh script to see what is built in the box on top of the default install +- add/remove to your heart's content + +a. Easy to use boxes for experimentation +- with puppet +- with chef +- with whatever else you can dream of :) + +b. Mount +# freebsd mouting NFS patch for FreeBSD +# https://github.com/mitchellh/vagrant/commit/8a0a1bddb5afc6b99cab595d6f3cc9a95bb1a509 +# OpenBSD will need patching to use it as NFS host +From the validation steps just the mount step fails +Virtualbox mount can be achieved using NFS mounts, it is not possible using the VBox tools since you can't compile them on OpenBSD +1. you can have your host expose NFS mounts that can be mounted by the Openbsd guest (checkout the vagrant documentation on using NFS mounts) +2. another way can be to work with vagrant in Puppet-server / chef-server mode since it will get manifests over the network from the puppet/chef server. +3. use a shell provisioner and scp/rsync your manifests from the host to the guest + + +c. Wait times +I've commented in all the steps in the OpenBSD install (definitions.rb) +Adjust the times if your machine is slower/faster than those times. + +d. More on puppet usage with OpenBSD +# http://puppetlabs.com/blog/guest-post-a-puffy-in-the-corporate-aquarium-the-sequel/ diff --git a/templates/openbsd52_amd64/definition.rb b/templates/openbsd52_amd64/definition.rb new file mode 100644 index 00000000..998d987d --- /dev/null +++ b/templates/openbsd52_amd64/definition.rb @@ -0,0 +1,85 @@ +Veewee::Session.declare({ + :cpu_count => '1', :memory_size=> '256', + :disk_size => '40960', :disk_format => 'VDI', :hostiocache => 'off', + :os_type_id => 'OpenBSD_64', + :iso_file => "openbsd52_64.iso", + :iso_src => "http://ftp3.usa.openbsd.org/pub/OpenBSD/5.2/amd64/install52.iso", + :iso_md5 => "a10f51d910052b477147e198c08089f8", + :iso_download_timeout => "1000", + :boot_wait => "40", :boot_cmd_sequence => [ +# I - install + 'I', +# set the keyboard + 'us', +# set the hostname + 'OpenBSD52-x64', +# Which nic to config ? [em0] + '', +# do you want dhcp ? [dhcp] + '', + ''*5, +# IPV6 for em0 ? [none] + 'none', +# Which other nic do you wish to configure [done] + 'done', +# Pw for root account + 'vagrant', + 'vagrant', +# Start sshd by default ? [yes] + 'yes', +# Start ntpd by default ? [yes] + 'no', +# Do you want the X window system [yes] + 'no', +# Setup a user ? + 'vagrant', +# Full username + 'vagrant', +# Pw for this user + 'vagrant', + 'vagrant', +# Do you want to disable sshd for root ? [yes] + 'no', +# What timezone are you in ? + 'GB', +# Available disks [sd0] + '', +# Use DUIDs rather than device names in fstab ? [yes] + '', +# Use (W)whole disk or (E)edit MBR ? [whole] + 'W', +# Use (A)auto layout ... ? [a] + 'A', + ''*60, +# location of the sets [cd] + 'cd', +# Available cd-roms : cd0 + '', +# Pathneame to sets ? [5.2/amd64] + '', +# Remove games and X + '-game52.tgz', + '-xbase52.tgz', + '-xetc52.tgz', + '-xshare52.tgz', + '-xfont52.tgz', + '-xserv52.tgz', + 'done', + ''*90, +# Done installing ? + 'done', +# Time appears wrong. Set to ...? [yes] + 'yes', + ''*6, +# Install non-free firmware files on first boot ? [no] <-- don't know what this is so I'm saying no + 'no', + 'reboot', + ''*6 + ], + :kickstart_port => "7122", :kickstart_timeout => "10000", :kickstart_file => "", + :ssh_login_timeout => "10000", :ssh_user => "root", :ssh_password => "vagrant", :ssh_key => "", + :ssh_host_port => "7222", :ssh_guest_port => "22", + :sudo_cmd => "sh '%f'", + :shutdown_cmd => "/sbin/halt -p", + :postinstall_files => [ "postinstall.sh"], :postinstall_timeout => "10000" +}) diff --git a/templates/openbsd52_amd64/postinstall.sh b/templates/openbsd52_amd64/postinstall.sh new file mode 100644 index 00000000..8ccbe730 --- /dev/null +++ b/templates/openbsd52_amd64/postinstall.sh @@ -0,0 +1,81 @@ +# set pkg path for users +echo " " +echo " Setting PKG_PATH for users " +echo " " +echo " export PKG_PATH=http://ftp3.usa.openbsd.org/pub/OpenBSD/`uname -r`/packages/`arch -s`/ " >> /root/.profile +echo " export PKG_PATH=http://ftp3.usa.openbsd.org/pub/OpenBSD/`uname -r`/packages/`arch -s`/ ">> /home/vagrant/.profile + +# giving root & vagrant bash as shell +echo " " +echo " Giving root/vagrant bash as a shell " +echo " " +usermod -s /usr/local/bin/bash vagrant +usermod -s /usr/local/bin/bash root + +# install wget/curl/bash/vim and its dependencies +echo " " +echo " Installing needed packages " +echo " " +export PKG_PATH=http://ftp3.usa.openbsd.org/pub/OpenBSD/`uname -r`/packages/`arch -s`/ +pkg_add wget curl bash vim-7.3.154p2-no_x11 rsync-3.0.9 bzip2 ngrep +pkg_add ruby-1.9.3.194 +pkg_add ruby-gems + ln -sf /usr/local/bin/gem19 /usr/local/bin/gem + + ln -sf /usr/local/bin/ruby19 /usr/local/bin/ruby + ln -sf /usr/local/bin/erb19 /usr/local/bin/erb + ln -sf /usr/local/bin/irb19 /usr/local/bin/irb + ln -sf /usr/local/bin/rdoc19 /usr/local/bin/rdoc + ln -sf /usr/local/bin/ri19 /usr/local/bin/ri + ln -sf /usr/local/bin/testrb19 /usr/local/bin/testrb + +pkg_add ruby-iconv +pkg_add ruby-puppet-2.7.14 + +gem install chef --no-ri --no-rdoc + + +/etc/rc.d/sendmail stop + +# Create puppet user/group +echo " " +echo " Creating puppet user / group " +echo " " +groupadd puppet +useradd -g puppet -d /var/lib/puppet -s /usr/bin/false puppet + + +# install the ports system for who wants to use it +echo " " +echo " Installing the ports system ! " +echo " " +cd /tmp +wget http://ftp3.usa.openbsd.org/pub/OpenBSD/`uname -r`/ports.tar.gz +cd /usr +sudo tar xzf /tmp/ports.tar.gz + +# sudo +# Defaults requiretty is not present in the sudoers file +# env_keep I'll leave it as it is since user's path is same or more comprehensive than root's path +echo " " +echo " Setting sudo to work with vagrant " +echo " " +echo "# Uncomment to allow people in group wheel to run all commands without a password" >> /etc/sudoers +echo "%wheel ALL=(ALL) NOPASSWD: SETENV: ALL" >> /etc/sudoers + +# setup the vagrant key +# you can replace this key-pair with your own generated ssh key-pair +echo " " +echo " Setting the vagrant ssh pub key " +echo " " +mkdir /home/vagrant/.ssh +chmod 700 /home/vagrant/.ssh +chown vagrant.vagrant /home/vagrant/.ssh +touch /home/vagrant/.ssh/authorized_keys +curl -sL http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub > /home/vagrant/.ssh/authorized_keys +chmod 600 /home/vagrant/.ssh/authorized_keys +chown vagrant.vagrant /home/vagrant/.ssh/authorized_keys + +echo +echo "Post-install done" +exit 0 diff --git a/templates/openbsd52_i386/README b/templates/openbsd52_i386/README new file mode 100644 index 00000000..f512a152 --- /dev/null +++ b/templates/openbsd52_i386/README @@ -0,0 +1,28 @@ +The boxes come with: +- ports system already installed +- puppet and chef +- check the postinstall.sh script to see what is built in the box on top of the default install +- add/remove to your heart's content + +a. Easy to use boxes for experimentation +- with puppet +- with chef +- with whatever else you can dream of :) + +b. Mount +# freebsd mouting NFS patch for FreeBSD +# https://github.com/mitchellh/vagrant/commit/8a0a1bddb5afc6b99cab595d6f3cc9a95bb1a509 +# OpenBSD will need patching to use it as NFS host +From the validation steps just the mount step fails +Virtualbox mount can be achieved using NFS mounts, it is not possible using the VBox tools since you can't compile them on OpenBSD +1. you can have your host expose NFS mounts that can be mounted by the Openbsd guest (checkout the vagrant documentation on using NFS mounts) +2. another way can be to work with vagrant in Puppet-server / chef-server mode since it will get manifests over the network from the puppet/chef server. +3. use a shell provisioner and scp/rsync your manifests from the host to the guest + + +c. Wait times +I've commented in all the steps in the OpenBSD install (definitions.rb) +Adjust the times if your machine is slower/faster than those times. + +d. More on puppet usage with OpenBSD +# http://puppetlabs.com/blog/guest-post-a-puffy-in-the-corporate-aquarium-the-sequel/ diff --git a/templates/openbsd52_i386/definition.rb b/templates/openbsd52_i386/definition.rb new file mode 100644 index 00000000..9dfe685a --- /dev/null +++ b/templates/openbsd52_i386/definition.rb @@ -0,0 +1,85 @@ +Veewee::Session.declare({ + :cpu_count => '1', :memory_size=> '256', + :disk_size => '40960', :disk_format => 'VDI', :hostiocache => 'off', + :os_type_id => 'OpenBSD_32', + :iso_file => "openbsd52_32.iso", + :iso_src => "http://ftp3.usa.openbsd.org/pub/OpenBSD/5.2/i386/install52.iso", + :iso_md5 => "a10f51d910052b477147e198c08089f8", + :iso_download_timeout => "1000", + :boot_wait => "40", :boot_cmd_sequence => [ +# I - install + 'I', +# set the keyboard + 'us', +# set the hostname + 'OpenBSD52-x32', +# Which nic to config ? [em0] + '', +# do you want dhcp ? [dhcp] + '', + ''*5, +# IPV6 for em0 ? [none] + 'none', +# Which other nic do you wish to configure [done] + 'done', +# Pw for root account + 'vagrant', + 'vagrant', +# Start sshd by default ? [yes] + 'yes', +# Start ntpd by default ? [yes] + 'no', +# Do you want the X window system [yes] + 'no', +# Setup a user ? + 'vagrant', +# Full username + 'vagrant', +# Pw for this user + 'vagrant', + 'vagrant', +# Do you want to disable sshd for root ? [yes] + 'no', +# What timezone are you in ? + 'GB', +# Available disks [sd0] + '', +# Use DUIDs rather than device names in fstab ? [yes] + '', +# Use (W)whole disk or (E)edit MBR ? [whole] + 'W', +# Use (A)auto layout ... ? [a] + 'A', + ''*60, +# location of the sets [cd] + 'cd', +# Available cd-roms : cd0 + '', +# Pathneame to sets ? [5.2/i386] + '', +# Remove games and X + '-game52.tgz', + '-xbase52.tgz', + '-xetc52.tgz', + '-xshare52.tgz', + '-xfont52.tgz', + '-xserv52.tgz', + 'done', + ''*90, +# Done installing ? + 'done', +# Time appears wrong. Set to ...? [yes] + 'yes', + ''*6, +# Install non-free firmware files on first boot ? [no] <-- don't know what this is so I'm saying no + 'no', + 'reboot', + ''*6 + ], + :kickstart_port => "7122", :kickstart_timeout => "10000", :kickstart_file => "", + :ssh_login_timeout => "10000", :ssh_user => "root", :ssh_password => "vagrant", :ssh_key => "", + :ssh_host_port => "7222", :ssh_guest_port => "22", + :sudo_cmd => "sh '%f'", + :shutdown_cmd => "/sbin/halt -p", + :postinstall_files => [ "postinstall.sh"], :postinstall_timeout => "10000" +}) diff --git a/templates/openbsd52_i386/postinstall.sh b/templates/openbsd52_i386/postinstall.sh new file mode 100644 index 00000000..8ccbe730 --- /dev/null +++ b/templates/openbsd52_i386/postinstall.sh @@ -0,0 +1,81 @@ +# set pkg path for users +echo " " +echo " Setting PKG_PATH for users " +echo " " +echo " export PKG_PATH=http://ftp3.usa.openbsd.org/pub/OpenBSD/`uname -r`/packages/`arch -s`/ " >> /root/.profile +echo " export PKG_PATH=http://ftp3.usa.openbsd.org/pub/OpenBSD/`uname -r`/packages/`arch -s`/ ">> /home/vagrant/.profile + +# giving root & vagrant bash as shell +echo " " +echo " Giving root/vagrant bash as a shell " +echo " " +usermod -s /usr/local/bin/bash vagrant +usermod -s /usr/local/bin/bash root + +# install wget/curl/bash/vim and its dependencies +echo " " +echo " Installing needed packages " +echo " " +export PKG_PATH=http://ftp3.usa.openbsd.org/pub/OpenBSD/`uname -r`/packages/`arch -s`/ +pkg_add wget curl bash vim-7.3.154p2-no_x11 rsync-3.0.9 bzip2 ngrep +pkg_add ruby-1.9.3.194 +pkg_add ruby-gems + ln -sf /usr/local/bin/gem19 /usr/local/bin/gem + + ln -sf /usr/local/bin/ruby19 /usr/local/bin/ruby + ln -sf /usr/local/bin/erb19 /usr/local/bin/erb + ln -sf /usr/local/bin/irb19 /usr/local/bin/irb + ln -sf /usr/local/bin/rdoc19 /usr/local/bin/rdoc + ln -sf /usr/local/bin/ri19 /usr/local/bin/ri + ln -sf /usr/local/bin/testrb19 /usr/local/bin/testrb + +pkg_add ruby-iconv +pkg_add ruby-puppet-2.7.14 + +gem install chef --no-ri --no-rdoc + + +/etc/rc.d/sendmail stop + +# Create puppet user/group +echo " " +echo " Creating puppet user / group " +echo " " +groupadd puppet +useradd -g puppet -d /var/lib/puppet -s /usr/bin/false puppet + + +# install the ports system for who wants to use it +echo " " +echo " Installing the ports system ! " +echo " " +cd /tmp +wget http://ftp3.usa.openbsd.org/pub/OpenBSD/`uname -r`/ports.tar.gz +cd /usr +sudo tar xzf /tmp/ports.tar.gz + +# sudo +# Defaults requiretty is not present in the sudoers file +# env_keep I'll leave it as it is since user's path is same or more comprehensive than root's path +echo " " +echo " Setting sudo to work with vagrant " +echo " " +echo "# Uncomment to allow people in group wheel to run all commands without a password" >> /etc/sudoers +echo "%wheel ALL=(ALL) NOPASSWD: SETENV: ALL" >> /etc/sudoers + +# setup the vagrant key +# you can replace this key-pair with your own generated ssh key-pair +echo " " +echo " Setting the vagrant ssh pub key " +echo " " +mkdir /home/vagrant/.ssh +chmod 700 /home/vagrant/.ssh +chown vagrant.vagrant /home/vagrant/.ssh +touch /home/vagrant/.ssh/authorized_keys +curl -sL http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub > /home/vagrant/.ssh/authorized_keys +chmod 600 /home/vagrant/.ssh/authorized_keys +chown vagrant.vagrant /home/vagrant/.ssh/authorized_keys + +echo +echo "Post-install done" +exit 0