Giter Site home page Giter Site logo

cookbook-stow's Introduction

stow (Chef cookbook)

Cookbook Version Build Status Code Climate

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

cookbook-stow's People

Contributors

stevenhaddox avatar esabelhaus avatar

Watchers

Greg Ziskind avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.