Kiss Your Travis-CI Good-Bye with Symfony2 Vagrant

I have problems with vagrant right from the get go. The idea is to setup a travis like environment to pre-test tests to be send to travis.
The problem I am trying to overcome appears when we have too elaborated settings in travis and experience too long wait time that make the whole testing experience very tedious.

Right from the get go i ran into a wrong assumption. I assume that i had installed vagrant just because rvm and ruby 1.9.2 was present on my system. The vagrant site tells you to download the package and run it with standard procedures. However ubuntu has the right version on its channels if you are using precise. So just use that and don’t try to either download the package or try to install it on your rvm or gems. Yes sorry ruby got me frustrated this morning. I don’t say it sucks, I say it is a mess!

Then next step is to do:

~ git clone git://
~ cd vagrant-php-dev-box
~ vagrant box add precise64
~ #vagrant init precise64 (this will tell you there is an already vagrant file created so just move on)
~ vagrant up (first time failed me because of port collisions)

So if port collisions check it with (thanks @boonkerz):

~ netstat -lnptu
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 *               LISTEN      -               
tcp        0      0*               LISTEN      -

Then enter the Vagrantfile on the root vagrant dev box project directory and change the numbers (27017 before):

  config.vm.forward_port 80, 1234

Then rerun `vagrant up` and there you go.

If you forget or need some special things to have either composer or your project dependencies to work well then you can proceed to do `vagrant ssh` and install inside the needed dependencies, for example:

~ sudo apt-get install php5-curl

If after you run `vagrant up` you get something like the following:

~ vagrant up
[default] Importing base box 'precise64'...
[default] The guest additions on this VM do not match the install version of
VirtualBox! This may cause things such as forwarded ports, shared
folders, and more to not work properly. If any of those things fail on
this machine, please update the guest additions and repackage the
Guest Additions Version: 4.1.16
VirtualBox Version: 4.1.18
[default] Matching MAC address for NAT networking...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 80 => 1234 (adapter 1)
[default] -- 27017 => 1235 (adapter 1)
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Running any VM customizations...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Mounting shared folders...
[default] -- v-root: /vagrant
[default] -- manifests: /tmp/vagrant-puppet/manifests
[default] Running provisioner: Vagrant::Provisioners::Puppet...
[default] Running Puppet with /tmp/vagrant-puppet/manifests/default.pp...
stdin: is not a tty
No LSB modules are available.
warning: Could not retrieve fact fqdn
notice: /Stage[main]/Development/Exec[apt-get update]/returns: executed successfully
notice: /Stage[main]/Php5/Package[php5-mysql]/ensure: ensure changed 'purged' to 'present'
notice: /Stage[main]/Development/Package[git]/ensure: created
notice: /Stage[main]/Php5/Package[php-apc]/ensure: ensure changed 'purged' to 'present'
notice: /Stage[main]/Php5/File[/etc/php5/conf.d/custom.ini]/ensure: defined content as '{md5}d918da65f01e420a256bd5721848f8a6'
notice: /Stage[main]/Php5/Package[php5-xdebug]/ensure: ensure changed 'purged' to 'present'
notice: /Stage[main]/Php5/Package[php5-sqlite]/ensure: ensure changed 'purged' to 'present'
notice: /Stage[main]/Development/Package[php-pear]/ensure: ensure changed 'purged' to 'present'
notice: /Stage[main]/Development/Package[curl]/ensure: ensure changed 'purged' to 'present'
notice: /Stage[main]/Php5/Package[php5-cgi]/ensure: ensure changed 'purged' to 'present'
notice: /Stage[main]/Development/Exec[set pear autodiscover]/returns: executed successfully
notice: /Stage[main]/Development/Exec[install phpunit]/returns: executed successfully
notice: /Stage[main]/Symfony-standard/Exec[run composer for symfony when composer is used]/returns: executed successfully
notice: /Stage[main]/Symfony-standard/Exec[install composer for symfony when needed]/returns: executed successfully
notice: /Stage[main]/Php5/Package[php5-intl]/ensure: ensure changed 'purged' to 'present'
notice: Finished catalog run in 494.53 seconds

Then even the virtual box was created you need to update your virtualbox guest additions with this script (thanks @debo).

# Installing the virtualbox guest additions
sudo apt-get -y install linux-headers-$(uname -r) build-essential
sudo apt-get -y install dkms
VBOX_VERSION=4.1.18 # this is the latest version at the time of the blog post
cd /tmp
sudo mount -o loop VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
sudo sh /mnt/
sudo umount /mnt

After this step you want to exit the virtualbox and then do a `virtual reload`. Be mindful you may need to reinstall some things but your virtualbox is certain to have Guest Additions already upgraded to 4.1.18. The Guest Additions step is a MUST because of this 3 day nightmare. Here is another link that can serve the explanation and also be useful. But the script is enough to make it work.

At this point I ran into this blog post: so the idea now is to add the user-group www-data to vagrant as in the blog post.

Another note I can make is regarding the time outs from composer within a vagrant slow connection box. Here is the link and the command:

vagrant@precise64:/vagrant/www/KnpBundles$ COMPOSER_PROCESS_TIMEOUT=4000 php composer.phar install --dev -v

2 thoughts on “Kiss Your Travis-CI Good-Bye with Symfony2 Vagrant

  1. I’m getting:

    stdin: is not a tty
    No LSB modules are available.
    warning: Could not retrieve fact fqdn

    I ran the virtualbox guest additions from inside the vagarant up box that was created. But I still get that problem. Am I supposed to installing the virtualbox guest additions in the Virtualbox I just created or on my Mac?

Leave a Reply to Ed Cancel reply

Your email address will not be published. Required fields are marked *