bryanwb / chef-ark

An archive unpacker and installer
59 stars 20 forks source link

chef-ark Build Status

Overview

An ''ark'' is like an archive but ''Kewler''

Does the fetch-unpack-configure-build-install dance. This is a modified verion of Infochimps awesome install_from cookbook [http://github.com/infochimps-cookbooks/install_from]. It has been heavily refactored and extended to meet different use cases.

Given a simple project archive available at a url:

ark 'pig' do
  url 'http://apache.org/pig/pig-0.8.0.tar.gz'
end

this provider will

By default, the ark will not run again if the :path is not empty. Ark provides many actions to accommodate different use cases, such as :dump, :cherry_pick, :put, and :install_with_make.

At this time ark only handles files available from URLs. It does not handle local files.

Attributes

Customize the attributes to suit site specific conventions and defaults.

Resources/Providers

Actions

:put

Extract the archive to a specified path, does not create any symbolic links.

Attribute Parameters for :put

:dump

Strips all directories from the archive and dumps the contained files into a specified path.

NOTE: This currently only works for zip archives

Attribute Parameters for :dump

:cherry_pick

Extract a specified file from an archive and places in specified path.

Relevant Attribute Parameters for :cherry_pick

Attribute Parameters

Examples

 # install Apache Ivy dependency resolution tool
 ark "ivy" do
   url 'http://someurl.example.com/ivy.tar.gz'
   version '2.2.0'
   checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'
   action :install
 end

This example copies ivy.tar.gz to /var/cache/chef/ivy-2.2.0.tar.gz, unpacks its contents to /usr/local/ivy-2.2.0/ -- stripping the leading directory, and symlinks /usr/local/ivy to /usr/local/ivy-2.2.0

 ark 'jdk' do
   url 'http://download.example.com/jdk-7u2-linux-x64.tar.gz'
   version '7.2'
   path "/usr/local/jvm/"
   home_dir "/usr/local/jvm/default"
   checksum  '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'
   append_env_path true
   owner 'foobar'
 end

This example copies jdk-7u2-linux-x64.tar.gz to /var/cache/chef/jdk-7.2.tar.gz, unpacks its contents to /usr/local/jvm/jdk-7.2/ -- stripping the leading directory, symlinks /usr/local/jvm/default to /usr/local/jvm/jdk-7.2, and adds /usr/local/jvm/jdk-7.2/bin/ to the global PATH for all users. The user 'foobar' is the owner of the /usr/local/jvm/jdk-7.2 directory

 # install Apache Ivy dependency resolution tool
 # in <path>/resource_name in this case
 # /usr/local/ivy, no symlink created
 # it strips any leading directory if one exists in the tarball

 ark "ivy" do
    url 'http://someurl.example.com/ivy.tar.gz'
    checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'
    action :put
 end

 # install Apache Ivy dependency resolution tool
 # in /home/foobar/ivy
 # it does strip any leading directory if one exists

 ark "ivy" do
   path "/home/foobar
   url 'http://someurl.example.com/ivy.tar.gz'
   checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'
   action :put
 end

# strip all directories and dump files into path specified by
 # the path attribute, you must specify the `creates` attribute
 # in order to keep the extraction from running every time
 # the directory path will be created if it doesn't already exist

 ark "my_jars" do
   url  "http://example.com/bunch_of_jars.zip"
   path "/usr/local/tomcat/lib"
   creates "mysql.jar"
   owner "tomcat"
   action :dump
 end

 # extract specific files from a tarball, currently only handles
 # one named file

 ark 'mysql-connector-java' do
   url 'http://oracle.com/mysql-connector.zip'
   creates 'mysql-connector-java-5.0.8-bin.jar'
   path '/usr/local/tomcat/lib'
   action :cherry_pick
 end

 # build and install haproxy and use alternave values for
 # prefix_root, prefix_home, and prefix_bin

 ark "haproxy" do
   url  "http://haproxy.1wt.eu/download/1.5/src/snapshot/haproxy-ss-20120403.tar.gz"
   version "1.5"
   checksum 'ba0424bf7d23b3a607ee24bbb855bb0ea347d7ffde0bec0cb12a89623cbaf911'
   make_opts [ 'TARGET=linux26' ]
   prefix_root '/opt'
   prefix_home '/opt'
   prefix_bin  '/opt/bin'
   action :install_with_make
 end

 # you can also pass multiple actions to ark and supply the file extension
 # in case the file extension can not be determined by the URL

 ark "test_autogen" do
   url 'https://github.com/zeromq/libzmq/tarball/master'
   extension "tar.gz"
   action [ :configure, :build_with_make ]
 end

 # you can also pass multiple actions to ark and supply the file extension
 # in case the file extension can not be determined by the URL
 ark "test_autogen" do
   url 'https://github.com/zeromq/libzmq/tarball/master'
   extension "tar.gz"
   action [ :configure, :build_with_make ]
 end

License and Author

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.