You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/04/24 06:54:51 UTC

[46/50] [abbrv] git commit: Changes for automating the vagrant build

Changes for automating the vagrant build

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/e6136bd3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/e6136bd3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/e6136bd3

Branch: refs/heads/tv/docs
Commit: e6136bd36d87deef6133714e19ca38b9ff3edf96
Parents: 42c758d
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Apr 23 17:39:14 2013 -0400
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Apr 23 17:59:53 2013 -0400

----------------------------------------------------------------------
 vagrant/README                                |   15 +++++-
 vagrant/Vagrantfile                           |   54 ++++++++++++--------
 vagrant/Vagrantfile.pkg                       |   10 ++--
 vagrant/allura_setup.sh                       |    9 +--
 vagrant/compress.sh                           |   21 ++++++++
 vagrant/manifests/ubuntu-1204-server-amd64.pp |   20 ++++++-
 6 files changed, 92 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6136bd3/vagrant/README
----------------------------------------------------------------------
diff --git a/vagrant/README b/vagrant/README
index 27f85d1..8bbe34e 100644
--- a/vagrant/README
+++ b/vagrant/README
@@ -24,7 +24,8 @@ $ mkdir ~/vagrant_allura && cd ~/vagrant_allura
 $ vagrant box add ubuntu-1204-server-amd64 http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box
 $ vagrant init ubuntu-1204-server-amd64
 
-# Get a copy of the provisioning scripts (note, Vagrantfile may change from release to release and may need manual updating)
+# Get a copy of the provisioning scripts (note, Vagrantfile may change from
+# release to release and may need manual updating)
 $ cp -R /var/local/allura/vagrant/* .
 
 # At this point you can make whatever changes you want to the provisioning
@@ -34,7 +35,17 @@ $ cp -R /var/local/allura/vagrant/* .
 # Provision the box (this will take a while)
 $ vagrant up
 
-# If you get an error, you can run `vagrant ssh` to get in and debug, and then `vagrant destroy` to start over
+# If you get an error, you can run `vagrant ssh` to get in and debug, and then
+# `vagrant destroy` to start over
+
+# Once the provisioning succeeds, `vagrant ssh` to the vm and do any testing
+# you want to do. You should at least run `./update.sh && ~/start_allura` and
+# make sure you can access the app at http://localhost:8080. After testing,
+# remain logged into the vm for the next step (compression).
+
+# Compress the VM. This will make your final .box file much smaller. It'll
+# take a while. Once it finished, logout of the vm.
+$ sudo /vagrant/compress.sh
 
 # Package the Allura box
 $ vagrant package --vagrantfile Vagrantfile.pkg

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6136bd3/vagrant/Vagrantfile
----------------------------------------------------------------------
diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile
index f21346c..7572922 100644
--- a/vagrant/Vagrantfile
+++ b/vagrant/Vagrantfile
@@ -18,7 +18,7 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
-Vagrant::Config.run do |config|
+Vagrant.configure("2") do |config|
   # All Vagrant configuration is done here. The most common configuration
   # options are documented and commented below. For a complete reference,
   # please see the online documentation at vagrantup.com.
@@ -30,29 +30,41 @@ Vagrant::Config.run do |config|
   # doesn't already exist on the user's system.
   # config.vm.box_url = "http://domain.com/path/to/above.box"
 
-  # Boot with a GUI so you can see the screen. (Default is headless)
-  # config.vm.boot_mode = :gui
+  # Create a forwarded port mapping which allows access to a specific port
+  # within the machine from a port on the host machine. In the example below,
+  # accessing "localhost:8080" will access port 80 on the guest machine.
+  config.vm.network :forwarded_port, guest: 8080, host: 8080
+  config.vm.network :forwarded_port, guest: 8983, host: 8983
 
-  # Assign this VM to a host-only network IP, allowing you to access it
-  # via the IP. Host-only networks can talk to the host machine as well as
-  # any other machines on the same network, but cannot be accessed (through this
-  # network interface) by any external networks.
-  # config.vm.network :hostonly, "192.168.33.10"
+  # Create a private network, which allows host-only access to the machine
+  # using a specific IP.
+  # config.vm.network :private_network, ip: "192.168.33.10"
 
-  # Assign this VM to a bridged network, allowing you to connect directly to a
-  # network using the host's network device. This makes the VM appear as another
-  # physical device on your network.
-  # config.vm.network :bridged
-
-  # Forward a port from the guest to the host, which allows for outside
-  # computers to access the VM, whereas host only networking does not.
-  config.vm.forward_port 8080, 8080
-  config.vm.forward_port 8983, 8983 # solr
+  # Create a public network, which generally matched to bridged network.
+  # Bridged networks make the machine appear as another physical device on
+  # your network.
+  # config.vm.network :public_network
 
   # Share an additional folder to the guest VM. The first argument is
-  # an identifier, the second is the path on the guest to mount the
-  # folder, and the third is the path on the host to the actual folder.
-  # config.vm.share_folder "v-data", "/vagrant_data", "../data"
+  # the path on the host to the actual folder. The second argument is
+  # the path on the guest to mount the folder. And the optional third
+  # argument is a set of non-required options.
+  # config.vm.synced_folder "../data", "/vagrant_data"
+
+  # Provider-specific configuration so you can fine-tune various
+  # backing providers for Vagrant. These expose provider-specific options.
+  # Example for VirtualBox:
+  #
+  config.vm.provider :virtualbox do |vb|
+    # Don't boot with headless mode
+    # vb.gui = true
+  
+    # Use VBoxManage to customize the VM. For example to change memory:
+    vb.customize ["modifyvm", :id, "--memory", "1024"]
+  end
+  #
+  # View the documentation for the provider you're using for more
+  # information on available options.
 
   # Enable provisioning with Puppet stand alone.  Puppet manifests
   # are contained in a directory path relative to this Vagrantfile.
@@ -112,7 +124,7 @@ Vagrant::Config.run do |config|
   # If you're using the Opscode platform, your validator client is
   # ORGNAME-validator, replacing ORGNAME with your organization name.
   #
-  # IF you have your own Chef Server, the default validation client name is
+  # If you have your own Chef Server, the default validation client name is
   # chef-validator, unless you changed the configuration.
   #
   #   chef.validation_client_name = "ORGNAME-validator"

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6136bd3/vagrant/Vagrantfile.pkg
----------------------------------------------------------------------
diff --git a/vagrant/Vagrantfile.pkg b/vagrant/Vagrantfile.pkg
index 8d17d78..51f6181 100644
--- a/vagrant/Vagrantfile.pkg
+++ b/vagrant/Vagrantfile.pkg
@@ -15,9 +15,9 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
-Vagrant::Config.run do |config|
-  # Forward Allura web port so you can browse the site at
-  # http://localhost:8080 (local port is the second number)
-  config.vm.forward_port 8080, 8080
-  config.vm.forward_port 8983, 8983 # solr
+Vagrant.configure("2") do |config|
+  # allura
+  config.vm.network :forwarded_port, guest: 8080, host: 8080
+  # solr
+  config.vm.network :forwarded_port, guest: 8983, host: 8983 
 end

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6136bd3/vagrant/allura_setup.sh
----------------------------------------------------------------------
diff --git a/vagrant/allura_setup.sh b/vagrant/allura_setup.sh
index e4973f6..6a38b74 100755
--- a/vagrant/allura_setup.sh
+++ b/vagrant/allura_setup.sh
@@ -47,6 +47,9 @@ then
     chown vagrant:vagrant /home/vagrant/.bash_profile
 fi
 
+# Make sure vagrant user can execute venv bin scripts
+sudo chown -R vagrant:vagrant /home/vagrant/env-allura/bin/
+
 # Setup Allura python packages
 cd /home/vagrant/src/allura
 sudo -u vagrant bash -c '. /home/vagrant/env-allura/bin/activate; ./rebuild-all.bash'
@@ -58,12 +61,6 @@ aptitude -y -q purge installation-report landscape-client landscape-common wirel
 aptitude -y -q purge python-dbus libnl1 python-smartpm linux-headers-server python-twisted-core libiw30 language-selector-common
 aptitude -y -q purge cloud-init juju python-twisted python-twisted-bin libdbus-glib-1-2 python-pexpect python-serial python-gobject python-pam accountsservice libaccountsservice0
 
-echo "Zeroing free space to aid VM compression..."
-cat /dev/zero > zero.fill;
-echo "Errors about 'No space left' are ok; carrying on..."
-sync;sleep 1;sync;rm -f zero.fill
-dd if=/dev/zero of=/EMPTY bs=1M
-rm -f /EMPTY
 echo "Done with allura_setup.sh"
 
 # sometimes mongo ends up stopped

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6136bd3/vagrant/compress.sh
----------------------------------------------------------------------
diff --git a/vagrant/compress.sh b/vagrant/compress.sh
new file mode 100755
index 0000000..c9bcd77
--- /dev/null
+++ b/vagrant/compress.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+echo 'Cleanup bash history'
+unset HISTFILE
+[ -f /root/.bash_history ] && rm /root/.bash_history
+[ -f /home/vagrant/.bash_history ] && rm /home/vagrant/.bash_history
+ 
+echo 'Cleanup log files'
+find /var/log -type f | while read f; do echo -ne '' > $f; done;
+ 
+echo 'Whiteout root'
+count=`df --sync -kP / | tail -n1  | awk -F ' ' '{print $4}'`; 
+let count--
+dd if=/dev/zero of=/tmp/whitespace bs=1024 count=$count;
+rm /tmp/whitespace;
+ 
+echo 'Whiteout /boot'
+count=`df --sync -kP /boot | tail -n1 | awk -F ' ' '{print $4}'`;
+let count--
+dd if=/dev/zero of=/boot/whitespace bs=1024 count=$count;
+rm /boot/whitespace;

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6136bd3/vagrant/manifests/ubuntu-1204-server-amd64.pp
----------------------------------------------------------------------
diff --git a/vagrant/manifests/ubuntu-1204-server-amd64.pp b/vagrant/manifests/ubuntu-1204-server-amd64.pp
index c6aabe0..1feb18e 100644
--- a/vagrant/manifests/ubuntu-1204-server-amd64.pp
+++ b/vagrant/manifests/ubuntu-1204-server-amd64.pp
@@ -107,18 +107,32 @@ file { '/home/vagrant/src/allura':
   require => [ File['/home/vagrant/src'], Exec['clone repo'] ],
 }
 
+# HACK to get numpy installed in the venv before installing
+# remaining dependencies via requirements file
+exec { "pip install numpy":
+  command => "/home/vagrant/env-allura/bin/pip install numpy==1.6.1",
+  cwd     => "/vagrant/allura",
+  timeout => 0,
+  logoutput => true,
+  returns => 0,
+  tries => 3,
+  require => [ Exec[ "clone repo"], Exec[ "create allura venv" ],
+               ],
+}
+
 # install Allura dependencies
 exec { "pip install":
-  command => "/usr/bin/sudo /home/vagrant/env-allura/bin/pip install -r requirements.txt",
+  command => "/home/vagrant/env-allura/bin/pip install -r requirements.txt",
   cwd     => "/vagrant/allura",
-  user => "vagrant",
-  group => "vagrant",
+  # user => "vagrant",
+  # group => "vagrant",
   timeout => 0,
   logoutput => true,
   returns => 0,
   tries => 3,
   require => [ Exec[ "clone repo"], Exec[ "create allura venv" ],
                File["/usr/lib/libjpeg.so"], File["/usr/lib/libz.so"],
+               Exec["pip install numpy"],
                ],
 }