From c395351784aca06ecf5b6ae071c5c845ebc4a124 Mon Sep 17 00:00:00 2001 From: Evan Stachowiak Date: Tue, 10 Jul 2012 17:52:11 -0400 Subject: initial commit --- .gitignore | 1 + README.md | 50 +++++++++++++++++++++++++++++++++++ manifests/config.pp | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ manifests/install.pp | 39 ++++++++++++++++++++++++++++ manifests/params.pp | 32 +++++++++++++++++++++++ 5 files changed, 195 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 manifests/config.pp create mode 100644 manifests/install.pp create mode 100644 manifests/params.pp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/README.md b/README.md new file mode 100644 index 0000000..29b3fc7 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +puppet-bundler - Bundler gem manager for Ruby +========================================== + +This puppet module will install bundler and set config +variables. + +This module supports Ubuntu 10.04 + +Installation +------------ + +1. Copy this directory to your puppet master module path $(git clone https://github.com/evanstachowiak/puppet-bundler bundler) +2. Apply the `bundler` class to any nodes you want bundler installed on: + class { 'bundler': } +3. Set whatever config variables are necessary: + bundler::config { 'linecache19': + user => ubuntu, + config_flag => "--with-ruby-include=/usr/local/rvm/src/ruby-1.9.2-p290", + app_dir => your_app_dir, + } + + +Contributing +------------ + +- fork on github (https://github.com/evanstachowiak/puppet-bundler) +- send a pull request + +Author +------ +Evan Stachowiak (https://github.com/evanstachowiak) + +LICENSE +------- + + Author:: Evan Stachowiak + Copyright:: Copyright (c) 2012 Evan Stachowiak + License:: Apache License, Version 2.0 + + 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. diff --git a/manifests/config.pp b/manifests/config.pp new file mode 100644 index 0000000..f2ba186 --- /dev/null +++ b/manifests/config.pp @@ -0,0 +1,73 @@ +# Define bundler::config +# +# All config settings for candiapp class +# +# == Parameters +# +# [*user*] +# App directory owner +# [*config_flag*] +# config flag for specific gem compile settings +# [*app_dir*] +# App directory where Gemfile is located +# [*home_dir_base_path*] +# Home directory of the specified user +# [*use_rvm*] +# Sets whether rvm is used. Defaults to true +# [*rvm_bin*] +# RVM install location. Defaults to /usr/local/rvm/bin/rvm +# [*rvm_gem_path*] +# RVM gem directory. Defaults to /usr/local/rvm/gems +# [*rvm_gemset*] +# RVM gemset to use. Defaults to global. +# [*ruby_version*] +# Ruby version for RVM purposes. Defaults to ruby-1.9.2-p290 +# [*bundler_path*] +# Bundler install directory +# +# == Examples +# +# +# == Requires: +# +# class { bundler::install: } +# +define bundler::config ( + $user, + $config_flag, + $app_dir, + $home_dir_base_path = $bundler::params::home_dir_base_path, + $use_rvm = $bundler::params::use_rvm, + $rvm_bin = $bundler::params::rvm_bin, + $rvm_gem_path = $bundler::params::rvm_gem_path, + $rvm_gemset = $bundler::params::rvm_gemset, + $ruby_version = $bundler::params::ruby_version, + $bundler_path = $bundler::params::bundler_path +) { + + Class['bundler::install'] -> Bundler::Config["${name}"] + + if $user == 'root' { + $home_dir = '/root' + } + else { + $home_dir = "${home_dir_base_path}/$user" + } + + # Must use $bundler_path_real, otherwise cannot reassign variable error is thrown + if $use_rvm == 'true' { + $bundler_path_rvm = "${rvm_gem_path}/${ruby_version}@${rvm_gemset}/bin" + $bundler_config_command = "${rvm_bin} ${ruby_version} exec ${bundler_path_rvm}/bundle config build.${name} ${config_flag}" + } + else { + $bundler_config_command = "${bundler_path}/bundle config build.${name} ${config_flag}" + } + + exec { "bundler_config_${name}": + cwd => $app_dir, + command => $bundler_config_command, + unless => "/bin/grep -i \"BUNDLE_BUILD__${name}: ${config_flag}\" ${home_dir}/.bundle/config", + user => $user, + } + +} diff --git a/manifests/install.pp b/manifests/install.pp new file mode 100644 index 0000000..57e0cf5 --- /dev/null +++ b/manifests/install.pp @@ -0,0 +1,39 @@ +# Class bundler::install +# +# Installs bundler Ruby gem manager +# +# == Parameters +# +# [*use_rvm*] +# Sets whether rvm is used. Defaults to true. +# [*ruby_version*] +# Ruby version that bundler will use. +# +# == Examples +# +# +# == Requires: +# +# If use_rvm = 'true': +# include rvm::system +# +class bundler::install ( + $use_rvm = $bundler::params::use_rvm, + $ruby_version = $bundler::params::ruby_version +) inherits bundler::params { + + if $use_rvm == 'true' { + #Install bundler with correct RVM + rvm_gem { 'bundler': + ensure => 'present', + ruby_version => $ruby_version, + } + } + else { + package { 'bundler': + ensure => 'present', + provider => 'gem', + } + } + +} diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 0000000..e016279 --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,32 @@ +# Class bundler::params +# +# All config settings for candiapp class +# +# == Parameters +# +# +# +# == Examples +# +# +# == Requires: +# +class bundler::params { + + case $::operatingsystem { + ubuntu, debian: { + $user = 'root' + $home_dir_base_path = '/home' + $use_rvm = 'true' + $rvm_bin = '/usr/local/rvm/bin/rvm' + $rvm_gem_path = '/usr/local/rvm/gems' + $rvm_gemset = 'global' + $ruby_version = 'ruby-1.9.2-p290' + $bundler_path = '/usr/bin' + } + default: { + fail("Unsupported platform: ${::operatingsystem}") + } + } + +} -- cgit v1.2.3