Skip to content

Commit

Permalink
Switch to Test Kitchen for boostrapping environments
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo committed Mar 18, 2014
1 parent 2f05f5c commit 5e4f6bf
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 63 deletions.
5 changes: 3 additions & 2 deletions lib/omnibus/cli/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ def project(name)
template(File.join('software', 'erlang-example.rb.erb'), File.join(config_software, 'erlang-example.rb'), opts)
template(File.join('software', 'ruby-example.rb.erb'), File.join(config_software, 'ruby-example.rb'), opts)

# Vagrant build lab
# Kitchen build environment
template(File.join('.kitchen.local.yml.erb'), File.join(target, '.kitchen.local.yml'), opts)
template(File.join('.kitchen.yml.erb'), File.join(target, '.kitchen.yml'), opts)
template(File.join('Berksfile.erb'), File.join(target, 'Berksfile'), opts)
template(File.join('Vagrantfile.erb'), File.join(target, 'Vagrantfile'), opts)

# render out stub packge scripts
%w(makeselfinst preinst prerm postinst postrm).each do |package_script|
Expand Down
10 changes: 10 additions & 0 deletions lib/omnibus/templates/.kitchen.local.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# The .kitchen.local.yml takes preference and is compiled into the top-level
# .kitchen.yml. Uncomment the following section to use VMWare Fusion instead of
# the default Vagrant driver of VirtualBox.
#

# driver:
# provider: vmware_fusion
# customize:
# memsize: 4096
26 changes: 26 additions & 0 deletions lib/omnibus/templates/.kitchen.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
driver:
name: vagrant
customize:
cpus: 2
memory: 2048
synced_folders:
- ['.', '/home/vagrant/<%= config[:name] %>']

provisioner:
require_chef_omnibus: 11.8.0

platforms:
- name: ubuntu-12.04
- name: ubuntu-11.04
- name: ubuntu-10.04
- name: centos-5.10
- name: centos-6.5

suites:
- name: default
run_list: omnibus::default
attributes:
omnibus:
build_user: vagrant
build_dir: /home/vagrant/<%= config[:name] %>
install_dir: /opt/<%= config[:name] %>
7 changes: 5 additions & 2 deletions lib/omnibus/templates/Berksfile.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
site :opscode
source 'https://api.berkshelf.com'

cookbook "omnibus"
cookbook 'omnibus'

# Uncomment to use the latest version of the Omnibus cookbook from GitHub
# cookbook 'omnibus', github: 'opscode-cookbooks/omnibus'
8 changes: 8 additions & 0 deletions lib/omnibus/templates/Gemfile.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
source 'https://rubygems.org'

# Use Berkshelf for resolving cookbook dependencies
gem 'berkshelf', '~> 3.0.0.beta'

# Install omnibus software
gem 'omnibus', '~> 2.0'
gem 'omnibus-software', github: 'opscode/omnibus-software'

# Use Test Kitchen with Vagrant for convering the build environment
gem 'test-kitchen', '~> 1.2'
gem 'kitchen-vagrant', '~> 0.14'
82 changes: 37 additions & 45 deletions lib/omnibus/templates/README.md.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# <%= config[:name] %> Omnibus project

<%= config[:name] %> Omnibus project
<%= '='*(config[:name].length + 16) %>
This project creates full-stack platform-specific packages for
`<%= config[:name] %>`!

## Installation

We'll assume you have Ruby 1.9+ and Bundler installed. First ensure all
required gems are installed and ready to use:
Installation
------------
You must have a sane Ruby 1.9+ environment with Bundler installed. Ensure all
the required gems are installed:

```shell
$ bundle install --binstubs
```

## Usage

Usage
-----
### Build

You create a platform-specific package using the `build project` command:
Expand All @@ -23,9 +23,9 @@ $ bin/omnibus build project <%= config[:name] %>
```

The platform/architecture type of the package created will match the platform
where the `build project` command is invoked. So running this command on say a
MacBook Pro will generate a Mac OS X specific package. After the build
completes packages will be available in `pkg/`.
where the `build project` command is invoked. For example, running this command
on a MacBook Pro will generate a Mac OS X package. After the build completes
packages will be available in the `pkg/` folder.

### Clean

Expand Down Expand Up @@ -53,50 +53,42 @@ Full help for the Omnibus command line interface can be accessed with the
$ bin/omnibus help
```

## Vagrant-based Virtualized Build Lab

Kitchen-based Build Environment
-------------------------------
Every Omnibus project ships will a project-specific
[Berksfile](http://berkshelf.com/) and [Vagrantfile](http://www.vagrantup.com/)
that will allow you to build your projects on the following platforms:

* CentOS 5 64-bit
* CentOS 6 64-bit
* Ubuntu 10.04 64-bit
* Ubuntu 11.04 64-bit
* Ubuntu 12.04 64-bit
that will allow you to build your omnibus projects on all of the projects listed
in the `.kitchen.yml`. You can add/remove additional platforms as needed by
changing the list found in the `.kitchen.yml` `platforms` YAML stanza.

Please note this build-lab is only meant to get you up and running quickly;
there's nothing inherent in Omnibus that restricts you to just building CentOS
or Ubuntu packages. See the Vagrantfile to add new platforms to your build lab.
This build environment is designed to get you up-and-running quickly. However,
there is nothing that restricts you to building on other platforms. Simply use
the [omnibus cookbook](https://github.com/opscode-cookbooks/omnibus) to setup
your desired platform and execute the build steps listed above.

The only requirements for standing up this virtualized build lab are:

* VirtualBox - native packages exist for most platforms and can be downloaded
from the [VirtualBox downloads page](https://www.virtualbox.org/wiki/Downloads).
* Vagrant 1.2.1+ - native packages exist for most platforms and can be downloaded
from the [Vagrant downloads page](http://downloads.vagrantup.com/).

The [vagrant-berkshelf](https://github.com/RiotGames/vagrant-berkshelf) and
[vagrant-omnibus](https://github.com/schisamo/vagrant-omnibus) Vagrant plugins
are also required and can be installed easily with the following commands:

```shell
$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus
```
The default build environment requires Test Kitchen and VirtualBox for local
development. Test Kitchen also exposes the ability to provision instances using
various cloud providers like AWS, DigitalOcean, or OpenStack. For more
information, please see the [Test Kitchen documentation](http://kitchen.ci).

Once the pre-requisites are installed you can build your package across all
platforms with the following command:
Once you have tweaked your `.kitchen.yml` (or `.kitchen.local.yml`) to your
liking, you can bring up an individual build environment using the `kitchen`
command.

```shell
$ vagrant up
$ bundle exec kitchen converge ubuntu-12.04
```

If you would like to build a package for a single platform the command looks like this:
Then login to the instance and build the project as described in the Usage
section:

```shell
$ vagrant up PLATFORM
$ bundle exec kitchen login ubuntu-12.04
[vagrant@ubuntu...] $ cd <%= config[:name] %>
[vagrant@ubuntu...] $ bundle install
[vagrant@ubuntu...] $ ...
[vagrant@ubuntu...] $ ./bin/omnibus build project <%= config[:name] %>
```

The complete list of valid platform names can be viewed with the
`vagrant status` command.
For a complete list of all commands and platforms, run `kitchen list` or
`kitchen help`.
2 changes: 2 additions & 0 deletions lib/omnibus/templates/gitignore.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*.gem
.bundle
.kitchen/
.kitchen.local.yml
vendor/bundle
pkg/*
.vagrant
Expand Down
8 changes: 4 additions & 4 deletions lib/omnibus/templates/omnibus.rb.example.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# s3_access_key "something"
# s3_secret_key "something"
# s3_bucket "some-bucket"
# s3_access_key 'something'
# s3_secret_key 'something'
# s3_bucket 'some-bucket'
# use_s3_caching true
# solaris_compiler "gcc"
# solaris_compiler 'gcc'
# build_retries 3
20 changes: 10 additions & 10 deletions lib/omnibus/templates/project.rb.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@

name "<%= config[:name] %>"
maintainer "CHANGE ME"
homepage "CHANGEME.com"
name '<%= config[:name] %>'
maintainer 'CHANGE ME'
homepage 'CHANGEME.com'

replaces "<%= config[:name] %>"
install_path "<%= config[:install_path] %>"
replaces '<%= config[:name] %>'
install_path '<%= config[:install_path] %>'
build_version Omnibus::BuildVersion.new.semver
build_iteration 1

# creates required build directories
dependency "preparation"
dependency 'preparation'

# <%= config[:name] %> dependencies/components
# dependency "somedep"
# dependency 'somedep'

# version manifest file
dependency "version-manifest"
dependency 'version-manifest'

exclude "\.git*"
exclude "bundler\/git"
exclude '\.git*'
exclude 'bundler\/git'

0 comments on commit 5e4f6bf

Please sign in to comment.