Tag And Release Chef Cookbooks As A Library
Kick it up a notch! Emeril is a library that helps you release your Chef
cookbooks from Rake, Thor, or a Ruby library. If rake release
is all you
are after, this should fit the bill.
How do you get started? Without much fanfare…
echo "gem 'emeril'" > Gemfile
bundle install
echo "require 'emeril/rake'" > Rakefile
bundle exec rake release
Bam!
Need more details? Read on…
Here is a short screencast demonstating how Emeril can be used to release a cookbook to the Supermarket site.
Emeril has 2 primary tasks and goals:
"v1.2.5"
(by
default)The Git tagging is currently accomplished via shell out, so Git must be installed on your system.
In order to bypass the deeply coupled cookbook_path
assumptions that exist
in the Knife plugins, the publishing task (implemented by the
Publisher class) will create a temporary sandboxed copy
of the primary cookbook files for use by the
CookbookSiteShare Knife plugin. The following files are
considered production cookbook files:
README.*
CHANGELOG.*
metadata.{json,rb}
attributes/**/*
definitions/**/*
files/**/*
libraries/**/*
providers/**/*
recipes/**/*
resources/**/*
templates/**/*
If the above list seems incomplete or incorrect, please submit an issue.
Add this line to your application's Gemfile:
gem 'emeril'
And then execute:
bundle
Or install it yourself as:
gem install emeril
Emeril currently uses the CookbookSiteShare to do most of the heavy lifting, so you will need a minimally configured knife.rb file with some required attributes set.
There are 2 configuration items you need:
*.pem
file.The easiest way to get setup is to add both of these items to your default
knife.rb
file located at $HOME/.chef/knife.rb
. If you are setting this
file up for the first time, give this a go (substituting your username, and
key location):
mkdir -p $HOME/.chef
cat <<KNIFE_RB > $HOME/.chef/knife.rb
node_name "fnichol"
client_key File.expand_path('~/.chef/fnichol.pem')
KNIFE_RB
To add the default Rake task (rake release
), add the following to your
Rakefile
:
require 'emeril/rake'
If you need to further customize the Emeril::Releaser
object you can use
the more explicit format with a block:
require 'emeril/rake_tasks'
Emeril::RakeTasks.new do |t|
# turn on debug logging
t.config[:logger].level = :debug
# disable git tag prefix string
t.config[:tag_prefix] = false
# set a category for this cookbook
t.config[:category] = "Applications"
end
If your cookbook is not on the Supermarket site, you can skip the publishing step with the block form:
require 'emeril/rake_tasks'
Emeril::RakeTasks.new do |t|
t.config[:publish_to_supermarket] = false
end
To add the default Thor task (thor emeril:release
), add the following to your
Thorfile
:
require 'emeril/thor'
If you need to further customize the Emeril::Releaser
object you can use
the more explicit format with a block:
require 'emeril/thor_tasks'
Emeril::ThorTasks.new do |t|
# turn on debug logging
t.config[:logger].level = :debug
# disable git tag prefix string
t.config[:tag_prefix] = false
# set a category for this cookbook
t.config[:category] = "Applications"
end
If your cookbook is not on the Supermarket site, you can skip the publishing step with the block form:
require 'emeril/thor_tasks'
Emeril::ThorTasks.new do |t|
t.config[:publish_to_supermarket] = false
end
The Ruby API is fairly straight forward, but keep in mind that loading or
populating Chef::Config[:node_name]
and Chef::Config[:client_key]
is
the responsibility of the caller, not Emeril.
For example, to load configuration from knife.rb and invoke the same code as the default Rake and Thor tasks, use the following:
# Populate Chef::Config from knife.rb
require 'chef/knife'
Chef::Knife.new.configure_chef
# Perform the git tagging and share to the Supermarket site
require 'emeril'
Emeril::Releaser.new(logger: Chef::Log).run
"Other"
category. Otherwise, check out
the Rake and Thor sections for further
configuration help.Pull requests are very welcome! Make sure your patches are well tested. Ideally create a topic branch for every separate change you make. For example:
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)Created and maintained by Fletcher Nichol (fnichol@nichol.ca)
MIT (see LICENSE.txt)