2

We have made some cookbooks in order to set up an environment that runs our software solution. These cookbooks are located on two git servers and depend on public cookbooks (we're using berkshelf).

We need to provision our software solution into different client environments (their hardware) and in order to do that we would like to be able to create a package of everything on one of our development machines and upload that package to a provisioning machine in the client environment. Then we'd like to use that provisioning machine to set everything up for that client.

The reason we need to do it this way is that the provisioning machine in the client environment won't have access to the git servers storing our cookbooks. It might not even have internet access. We basically want to treat the client environment as a completely isolated island.

I would like to be able to package and upload a whole environment (including dependencies) onto the provisioning server. There I would then fire up chef-zero and provision all the nodes for that environment from that.

Problem is, I don't really have any idea how to achieve this.

StFS
  • 1,639
  • 2
  • 15
  • 31

3 Answers3

0

Have a look at spiceweasel (https://github.com/mattray/spiceweasel)

I haven't used this recently, but this was our strategy (at use-'ta-work-there) when installing on a customer's cluster.

stensonb
  • 71
  • 7
0

Berkshelf documentation describes how to package cookbooks into a single archive:

$ cd ~/code/berkshelf-api/cookbook
$ berks package
Cookbook(s) packaged to /Users/reset/code/berkshelf-api/cookbook/cookbooks-1397512169.tar.gz

This archive an be given directly to Chef-Solo or extracted and uploaded to a Chef Server.

Example

Package the cookbooks

Use berkshelf to package your "myapp" cookbook and all its dependencies.

berks package myapp-1.0.tar.gz

Usage: Chef solo

tar zxf myapp-1.0.tar.gz
chef-solo -c ~/solo.rb -j ~/node.json

Usage: Chef server

Upload cookbooks to chef server

tar zxf myapp-1.0.tar.gz
knife environment create myapp-1_0 --description "myapp version 1.0" -d
knife cookbook upload --all --cookbook-path cookbooks --environment myapp-1_0 --freeze

Bootstrap some new client nodes against the chef server

knife bootstrap node1 -E myapp-1_0 -r recipe[myapp] ..
knife bootstrap node2 -E myapp-1_0 -r recipe[myapp] ..
..

The creation of an environment is deliberate. It enables the cookbook versions to be constrained at run-time, providing isolation on a shared chef server.

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
0

You should use Packer for for this task, since it will allow you to create these images for any platform including a Dockerized version and it can be provisioned with Chef cookbooks.

Then, upload the image wherever and change your Vagrantfile (or whatever you use) to point to that image as your starting point.

For an example, and starting point, just take a look at the Opscode Bento service repo (on GitHub) under the "packer" folder in the root directory. Opscode uses Packer heavily to provide specialized provisioned boxes for their ChefDK services etc.

dkinzer
  • 32,179
  • 12
  • 66
  • 85
  • Yes, you're quite correct. Creating a working binary is the most reliable way to deliver an app. However in my experience some clients do not allow 3rd party virtual appliances or containers. If they're already using chef and then you'll need a mechanism to deliver an integrated set of chef cookbooks, which I assumed was the question. – Mark O'Connor Nov 08 '14 at 12:30
  • Indeed, hopefully that will change now that Linux Containers are becoming more common place. – dkinzer Nov 08 '14 at 12:46