Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a self-contained librarian installation #28

Open
josegonzalez opened this issue Dec 3, 2013 · 0 comments
Open

Use a self-contained librarian installation #28

josegonzalez opened this issue Dec 3, 2013 · 0 comments

Comments

@josegonzalez
Copy link

You can use multiple provisioners to remove the need to have anything other than virtualbox/vagrant installed as follows:

# add the following before the `Vagrant.configure` line
$script = <<-SCRIPT
cat > /root/.gemrc << 'EOF'
gem: --no-ri --no-rdoc
EOF

if ! grep -q cd-to-directory "/home/vagrant/.bashrc"; then
  echo "- setting up auto chdir on ssh"
  echo "\n[ -n \\"\\$SSH_CONNECTION\\" ] && cd /vagrant # cd-to-directory" >> "/home/vagrant/.bashrc"
fi

cd /vagrant

if [ ! -f /opt/chef/embedded/bin/librarian-chef ]; then
  echo "- installing librarian-chef"
  /opt/chef/embedded/bin/gem install librarian-chef > /dev/null
fi

echo "- running librarian-chef"
/opt/chef/embedded/bin/librarian-chef install > /dev/null

SCRIPT

And then place this before the existing config.vm.provision block:

  config.vm.provision :shell, inline: $script

This removes the need to install gems outside of the vagrant vm.

A few notes:

  • Other than git, I don't run any code outside of a vm on my mac. It's a way to ensure that all development environments can be replicated anywhere without my poking/prodding, since I regularly rebuild my vms.
  • This requires the use of the opscode ruby to install things. A bit annoying, and there should be some fallbacks, but still good to note.
  • This sort of pollutes the embedded opscode ruby. We could install ruby1.9 (I do that for other vms) but it doesn't matter that much.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant