cookbook 'stow', '= 0.3.1'
stow (13) Versions 0.3.1 Follow0
Installs GNU Stow & provides stow_package resource
cookbook 'stow', '= 0.3.1', :supermarket
knife supermarket install stow
knife supermarket download stow
stow (Chef cookbook)
Description
A simple chef cookbook to install GNU stow
via package management or source if a package is not available.
Attributes
-
['stow']['path'] = '/usr/local/stow'
path stow command uses for symlinking packages and libraries -
['stow']['target'] = nil
target directory for stow managed symlinks, defaults to stow path's parent directory if nil -
['stow']['version'] = '2.2.0'
version of stow to install for source installations -
['stow']['src_url'] = 'http://ftp.gnu.org/gnu/stow/stow-2.2.0.tar.gz'
URL for latest stow source tarball -
['stow']['rpm_url'] = nil # 'http://dl.fedoraproject.org/pub/epel/6/i386/stow-2.2.0-1.el6.noarch.rpm'
Default is nil and uses yum, but you can specify an alternative rpm package by URL -
['stow']['deb_url'] = nil # 'http://mirrors.kernel.org/ubuntu/pool/universe/s/stow/stow_2.2.0-2_all.deb'
Default is nil and uses apt, but you can specify an alternative deb package by URL
Usage
Add the recipes to the run_list
, it should probably be towards the beginning:
"recipe[stow]"
Configure attributes:
"stow" : {
"path" : "/opt/local/stow",
"version" : "2.2.0"
}
Resources Provided
The stow cookbook provides a stow_package
resource that can be used as follows:
stow_package 'openssl' do name 'openssl' version '1.0.2d' creates 'bin/openssl' # *Required* relative path to a file your source compiled package creates #action :stow # Also available `:destow`, the default action is `:stow` #destow_existing true # Defaults to `true` and will destow all out of date packages with prefix "#{name}-+-" #current_version '1.0.2c' # Destows `current_version` before `version` is stowed; ignored unless `destow_existing` is `false` end
NOTE: This cookbook expects you to compile your packages with the following prefix convention:
#{node['stow']['path']}/#{package_name}-+-#{version}/
For the example above, you would compile openssl
with the prefix:
--prefix #{node['stow']['path']}/openssl-+-1.0.2d/
If your package / library works with the tar cookbook there's a very easy way to do this, like so:
# Compile your package via the tar cookbook with proper prefix tar_package "#{tarball_path_or_url}" do prefix "#{node['stow']['path']}/#{your_pkg_name}-+-#{your_pkg_version}" creates "#{node['stow']['path']}/#{your_pkg_name}-+-#{your_pkg_version}/#{path/to/pkg/file}" end # Stow your package stow_package "#{your_pkg_name}" do name "#{your_pkg_name}" version "#{your_pkg_version}" creates 'path/to/pkg/file' # Note the relative path vs full path for `tar_package` end
ChefSpec Matchers
A set of ChefSpec matchers is included, for unit testing with ChefSpec. To illustrate:
# Recipe code stow_package 'openssl' do name 'openssl' version '1.0.2d' creates 'bin/openssl' end
# Spec code it 'should stow openssl version 1.0.2d' do expect(chef_run).to stow_package('openssl').with( name: 'openssl', version: '1.0.2d', creates: 'bin/openssl' ) # Stow package wraps the execute resource if you want further validation expect(chef_run).to run_execute('stow_openssl-1.0.2d') end
A matcher for the delete action is also available:
# Recipe code stow_package 'openssl' do action :destow name 'openssl' version '1.0.2c' creates 'bin/openssl' end
# Spec code it 'should destow package openssl 1.0.2c' do expect(chef_run).to destow_package('openssl').with( action: :destow, name: 'openssl', version: '1.0.2c', creates: 'bin/openssl' ) # Stow package wraps the execute resource if you want further validation expect(chef_run).to run_execute('destow_openssl-1.0.2c') end
Dependent cookbooks
apt ~> 2.7.0 |
build-essential ~> 2.2 |
tar ~> 0.6.0 |
yum-epel ~> 0.6.2 |
Contingent cookbooks
There are no cookbooks that are contingent upon this one.
Foodcritic Metric
0.3.1 failed this metric
FC031: Cookbook without metadata file: /tmp/cook/9494e4e78531d829517437f2/stow/metadata.rb:1
FC045: Consider setting cookbook name in metadata: /tmp/cook/9494e4e78531d829517437f2/stow/metadata.rb:1
0.3.1 failed this metric
FC045: Consider setting cookbook name in metadata: /tmp/cook/9494e4e78531d829517437f2/stow/metadata.rb:1