9

I am not sure if I should use Puppet for this. I update and install through provision.sh.

My Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu32"
  config.vm.provision :shell, path: './provision.sh'  
  config.vm.network "public_network"
end

provision.sh

apt-get update
apt-get -y install build-essential git-core python-software-properties nodejs
apt-get -y install vim
apt-get -y install curl
curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash

Now I need to add the following to ~/.bashrc at the top. Or I can prepare a file .bashrc and replace it with ~/.bashrc

export RBENV_ROOT="${HOME}/.rbenv"

if [ -d "${RBENV_ROOT}" ]; then
  export PATH="${RBENV_ROOT}/bin:${PATH}"
  eval "$(rbenv init -)"
fi

Then run source .bashrc

Then run following commands.

rbenv install 2.0.0-p247
rbenv rehash
gem install bundler
bundle
sudo apt-get install libpq-dev 
gem install pg -v '0.15.0'
shin
  • 31,901
  • 69
  • 184
  • 271

1 Answers1

8

You can do this in your provision.sh script. Vagrant automatically shares the directory where your Vagrantfile lives with the guest VM as the /vagrant folder.

Create the .bashrc file as you want it, and put it in the same directory as your Vagrantfile. I would leave out the '.' and call it bashrc so you don't loose track of it.

Then you can add to your provision.sh script:

cp /vagrant/bashrc ~/.bashrc
source ~/.bashrc

Note: the bash provisioning runs as the root user, you'll have to modify this a bit if you want to use it as a non-root user.

cp /vagrant/bashrc /home/<username>/.bashrc
su - <username> -c "<command to run as user>"
mattwise
  • 1,464
  • 1
  • 10
  • 20
  • For some reason I had no `/vagrant` directory, so I had to copy the `.bashrc` file from my `config.vm.synced_folder` set up in `Vagantfile`. – meridius Mar 27 '17 at 15:31