How to setup a Vagrant box for a stasis project? - ruby

I'm learning how to use vagrant, and I've a simple project that uses stasis to generate static files.
I'm looking for a setup to run stasis on a vagrant box.
So the question would be: what's box do I need to make stasis work?
(Any hints on what should the Puppetfile include would be nice)

As a posible solution I've used this setup. It's a Ubuntu precise 64 using puppet as provisioner with:
rvm
ruby 2.0.0
git
nodejs
stasis gem
project specific gems
I can compile the project and see it on http://localhost:4000 using stasis -d 4000.
There is another related question that came along when finding this solution.

Related

How to install Ruby Gems for Vagrant, i.e. for usage in a Vagrantfile and executed on the host, on linux and windows?

I am using Vagrant for provisioning virtual machines. The Vagrantfile executes some custom Ruby code on the host. (This Ruby code is executed directly in the Vagrantfile, but could also be executed as part of a proper Vagrant plugin. It is the same situation.)
I would like to use the functionality of 3rdparty Ruby Gems in this very code, but I'm not sure how to properly install the Gems in the Vagrant context.
1) I don't know how Vagrant invokes Ruby. Is it some modified Ruby interpreter for Vagrant? Or is it a standard Ruby installation?
2) How do I, preferably on the command line (linux shell/PowerShell), install Ruby Gems that can be used from the Vagrantfile? Is there a special location for the Gems so that Vagrant can include them?
I would write about what I did so far at this point, but I just don't know where to start. This seems to be an uncommon use case, because I haven't found anything that goes into this direction. Maybe the answer is obvious, but I seem to lack proper understanding of what is required for Vagrant/Ruby to 'see' an installed Ruby Gem.
According to the documentation for Vagrant plugins:
This installs a plugin with the given name or file path. If the name is not a path to a file, then the plugin is installed from remote repositories, usually RubyGems.
# Installing a plugin from a known gem source
$ vagrant plugin install my-plugin
I don't use Vagrant so I can't confirm that it works, however a quick search shows that someone else wanted to accomplish the same goal and this worked for them:
require 'inifile'
settings = IniFile.load(CONFIGFILE)
Message: LoadError: cannot load such file -- inifile
I found that I can get these to work if I do:
vagrant plugin install inifile

Specify ruby version to use with Pik

I need to run two Ruby apps on a Windows 2008 server. So, I'm thinking to install Pik for the job (I understand I could use also RVM but the install process doesn't seem very 'stable' to me).
Before installing Pik, however, I'd like to know if there is a way to specify which Ruby version should be used for each app. Something like a .ruby-version file. I have looked for the answer on the official Pik repo but I couldn't find anything about it.
In my opinion, Ref 1, Ref 2 are the two simple references you could have to install different ruby versions using Pik in Windows.
After setting up the environment correctly, you could just use the command similar to RVM.
pik use ruby-2.0.0-p0
Then ruby -v will show ruby 2.0.0p0. So, for different projects, from with in each project folder choose which ruby you want to have.
Hope it helps :)

How do I deploy ruby into a server without compiling or installing?

I'm given a server without any root access and very limited access to do any stuff. And I'm trying to install ruby on that box. I have a look at Omnibus chef and it looks like they pack embedded-ruby inside the package. So, the server doesn't need ruby installed on that box. I'm trying to achieve the same thing. How can I package my own embedded ruby so I can deploy like a tarball to the box without any compiling or installing?
RVM supports installing pre-built binaries (RVM installs Rubies local to the user, no admin access required):
http://syntaxi.net/2012/12/21/installing-prebuilt-binaries-with-rvm/
It's a little different than just dumping a tarball on the machine, but it will setup paths and everything for you, so odds are it will actually work.

Why doesn't rails.vim recognize any gems that I install?

I'm a ruby and vim newbie. I recently installed the rails.vim plugin and all the commands work fine apart from the commands to create a new Rails project. Every time I do this it says rails is not installed on my system, but it is! It also acts up when I create a class that requires a gem that I've installed. Can anyone help with this?
Did you rvm use system before building / brew install-ing macvim? I didn't and got many errors. Doing rvm use system beforehand fixed things up for me.

Installing Ruby 1.9.2 on Ubuntu using Chef and Vagrant

I would like to provision a new Ubuntu 10.04 box with Ruby 1.9.2. I'm using Vagrant and Chef Solo to provision the box with everything else I need (e.g. Rails, Rake, MongoDB). The default Ruby version is 1.8.7.
Is there a way to install Ruby 1.9.2 as part of the Vagrant/Chef provisioning process?
I've read on the Chef website about using my own bootstrap template — possibly with knife — such as this one, but because I'm using Vagrant I'm not sure where to put this template — I don't have a chef-repo, a .chef directory or even any Chef stuff installed in /etc/chef.
First, a bit of context. Most Vagrant baseboxes install Ruby for use by Chef and Puppet, but the latest ones do this into /opt/ruby rather than using the system packages. They also add /opt/ruby/bin to the path, but at the end.
This VeeWee template shows how the 10.04 box is currently built: https://github.com/jedi4ever/veewee/blob/master/templates/ubuntu-10.04.3-server-i386/postinstall.sh
As for your question, their are several different contexts you might be trying to address, each with a different solution. Hopefully one of these will be what you're looking for.
Run Chef recipes with 1.9.2
You might be wanting to test running Chef recipes under 1.9.2 and you don't want 1.8.7 anywhere near your box. The best way of approaching this would be to create your own VeeWee template and build yourself a new basebox. You could modify the one linked above to compile 1.9.2 instead of 1.8.7 and follow the instructions on https://github.com/jedi4ever/veewee
Develop with Ruby 1.9.2
Probably more likely is that you want to hack on some Ruby code using 1.9.2. For this you just need to install Ruby and have the binaries on your path before the /opt/ruby entry. There are several ways of doing this:
Compile Ruby from scratch yourself
Use a package. The apt packages in lucid won't give you 1.9.2 so you can roll your own if you like. Or here's one I'm currently using https://github.com/garethr/packages/downloads
Use something like RVM http://beginrescueend.com/
All of these could be managed using a Chef recipe. I'd probably not go for the compile option, leaving either just a straight download and package resource or the following RVM cookbook might be handy http://community.opscode.com/cookbooks/rvm for RVM.
The *gem_binary* option on the package resource might also be useful here depending on how you want to ensure gems get installed for your new 1.9.2 Ruby (rather than the 1.8.7 in opt)
The goal of knife bootstrap is to get Chef installed on the target system so it can run Chef Client. The Vagrant baseboxes tend to already have Chef installed so unless you're doing something specific and want to run multiple versions of Chef I'd avoid this route. The built in Chef provisioners like http://vagrantup.com/docs/provisioners/chef_solo.html are a better bet.
I know the question is quite old and already answered, but I hope this still may be interesting for someone stumbling upon this question.
I've built a Github repo which intends to provide several configurations for building and provisioning a Vagrant box without requiring to write a provisioning recipe from scratch.
For example, using the currently provided configuration, you can build and provision a box with:
Ruby 1.9.2-p290, managed with rbenv and using Bundler for gems
PostgreSQL 8.4
MongoDB
Here is an introduction article on my blog.
Since this almost match the request, I felt it was worth adding this late answer :)
Here's the recipe i'm using to install Ruby 1.9.2
package "libffi5" do
action :install
provider Chef::Provider::Package::Apt
end
package "ruby-1.9.2" do
action :install
source "/tmp/vagrant-chef/cookbooks-0/ruby-1.9.2/files/default/ruby-1.9.2-p290_i386.deb"
provider Chef::Provider::Package::Dpkg
end

Resources