0

I was using serverspec in a VM where internet is available and it was so nice.

But when we need to give the script to testers they have to install it in a machine where internet is not available.

I was trying to install in a local folder in a VM where internet available then installed in test VM. But when i run Serverspec-init it says rspec is not found.

Seems some dependent gems also need to be installed before using it.

Is it not possible to install the whole bundle as one step? How to do that?

Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230
  • I have done this by packaging it as an rpm, but you could also do it a tarball or docker container. What route seems best for you? – Matthew Schuchard Aug 17 '16 at 12:03
  • @Samselvaprabu did my solution help you? – sixty4bit Oct 05 '16 at 16:46
  • @sixty4bit I found this link was helpful and it worked for me http://help.rubygems.org/kb/rubygems/installing-gems-with-no-network – Samselvaprabu Oct 06 '16 at 04:40
  • 1
    @Samselvaprabu that link doesn't mention anything about doing this with your entire bundle of gems like my answer does, but glad it helped you. :) You should create your own answer and mark it as correct if it gave you what you needed so that others can benefit. – sixty4bit Oct 06 '16 at 12:09

1 Answers1

2

Managing gems on a server that doesn't have internet access is definitely a challenge.

One relatively-straightforward way to do what you need is to make use of the vendor/cache directory in your application and make bundle know about it when using bundle install by using the --local flag.

First, download the gem archive (.gem file extension) of the bundler gem by going to its Rubygems page and clicking the "download" link in the bottom right. You'll need to upload that file to your test server and run $ gem install bundler-1.12.15.gem from the command line.

Now you need to get the .gem archives for serverspec, its dependencies, and all of its dependencies' dependencies, and put them inside your application in the vendor/cache directory (create those with $ mkdir -p vendor/cache) if they don't exist.

Now when you deploy the application to the server, with these .gem files in vendor/cache, run bundle install --local. This will install the gems. You can see the official documentation of the --local option at the bundler docs.

sixty4bit
  • 7,422
  • 7
  • 33
  • 57
  • If rpm and tarball are old school and docker is new school, that would make this a cool... mid--school(?) method. – Matthew Schuchard Aug 17 '16 at 13:23
  • haha well yeah the assumption here is that you are setting your application up like this locally with the `vendor/cache` directory but then you probably would archive the app before manually uploading it to the internet-restrictured server and unarchive it there – sixty4bit Aug 17 '16 at 16:35