Showing with 75 additions and 78 deletions.
  1. +2 −2 Modulefile
  2. +23 −11 manifests/config.pp
  3. +7 −12 manifests/init.pp
  4. +20 −1 manifests/install.pp
  5. +0 −12 manifests/install/pe_ruby.pp
  6. +13 −15 manifests/install/ruby.pp
  7. +6 −3 manifests/params.pp
  8. +2 −7 templates/etc/r10k.yaml.erb
  9. +2 −15 tests/init.pp
4 changes: 2 additions & 2 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'zack-r10k'
version '0.0.2'
version '0.0.7'
source 'https://github.com/acidprime/r10k'
author 'zack'
license 'Apache License, Version 2.0'
Expand All @@ -8,7 +8,7 @@ description 'Module for setting up dynamic environments using r10k'
project_page 'https://github.com/acidprime/r10k'

## Add dependencies, if any:
dependency 'puppetlabs/stdlib', '>= 4.1.0'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/ruby', '>= 0.0.2'
dependency 'puppetlabs/gcc', '>= 0.0.3'
dependency 'puppetlabs/pe_gem', '>= 0.0.1'
Expand Down
34 changes: 23 additions & 11 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,29 @@
class r10k::config (
$configfile,
$cachedir,
$sources = {},
$purgedirs = [],
$r10k_basedir,
$modulepath,
$manage_modulepath,
) {
$remote = '',
$sources = 'UNSET',
$purgedirs = [],
$puppetconf_path = $r10k::params::puppetconf_path,
$r10k_basedir = $r10k::params::r10k_basedir,
) inherits r10k::params {


if $sources == 'UNSET' {
$r10k_sources = {
'puppet' => {
'remote' => $remote,
'basedir' => $r10k_basedir,
},
}
} else {
validate_hash($sources)

$r10k_sources = $sources
}

file { 'r10k.yaml':
ensure => file,
owner => 'root',
Expand All @@ -58,18 +75,13 @@
content => template("${module_name}/${configfile}.erb"),
}

$puppetconf_path = $::is_pe ? {
'true' => '/etc/puppetlabs/puppet',
default => '/etc/puppet',
}

if $manage_modulepath {
ini_setting { "R10k Modulepath":
ini_setting { 'R10k Modulepath':
ensure => present,
path => "${puppetconf_path}/puppet.conf",
section => 'main',
setting => 'modulepath',
value => $modulepath,
ensure => present,
}
}
}
19 changes: 7 additions & 12 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
# This class configures r10k
class r10k (
$sources = {},
$remote = $r10k::params::remote,
$source_name = $r10k::params::source_name,
$sources = $r10k::params::sources,
$purgedirs = $r10k::params::r10k_purgedirs,
$basedir = $r10k::params::r10k_basedir,
$cachedir = $r10k::params::r10k_cache_dir,
$configfile = $r10k::params::r10k_config_file,
$version = $r10k::params::version,
$pe_ruby = $r10k::params::pe_ruby,
$modulepath = $r10k::params::modulepath,
$manage_modulepath = $r10k::params::manage_modulepath,
$r10k_basedir = $r10k::params::r10k_basedir,
) inherits r10k::params {
if $pe_ruby {
class { 'r10k::install::pe_ruby' :
version => $version,
}
} else {
class { 'r10k::install::ruby' :
version => $version,
}

class { 'r10k::install':
version => $version,
pe_ruby => $pe_ruby,
}

class { 'r10k::config':
cachedir => $cachedir,
configfile => $configfile,
sources => $sources,
purgedirs => $purgedirs,
r10k_basedir => $basedir,
modulepath => $modulepath,
remote => $remote,
manage_modulepath => $manage_modulepath,
}
}
21 changes: 20 additions & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
# This class is used by the ruby or pe_ruby class
class r10k::install (
$version,
$provider = 'gem',
$pe_ruby,
) {

# There are currently bugs in r10k 1.x which make using 0.x desireable in
# certain circumstances. However, 0.x requires make and gcc. Conditionally
# include those classes if necessary due to 0.x r10k version usage. When
# 1.x is just as good or better than 0.x, we can stop supporting 0.x and
# remove this block.
if versioncmp('1.0.0', $version) > 0 {
require gcc
require make
}

if $pe_ruby {
$provider = 'pe_gem'
} else {
$provider = 'gem'
class { 'r10k::install::ruby': version => $version; }
}

package { 'r10k':
ensure => $version,
provider => $provider,
}

}
12 changes: 0 additions & 12 deletions manifests/install/pe_ruby.pp

This file was deleted.

28 changes: 13 additions & 15 deletions manifests/install/ruby.pp
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
# Install the r10k gem using system ruby
class r10k::install::ruby(
class r10k::install::ruby (
$version,
) {
# Install the r10k dependacies
require gcc
require make

# Breaking up my chaining a little here
Class['::ruby'] -> Class['ruby::dev'] -> Package['gcc']

# rubygems_update => false
# https://projects.puppetlabs.com/issues/19741
class {'::ruby':
class { '::ruby':
rubygems_update => false,
}
class { 'ruby::dev':
tag => 'amineeded',
}

# I am not sure this is required as I assumed the
# ruby::dev class would have taken care of it
Package['gcc'] -> Package['make'] -> Package['r10k']

class { 'r10k::install':
version => $version,
provider => 'gem',
# Explicit dependency chaining to make sure the system is ready to compile
# native extentions for dependent rubygems by the time r10k installation
# begins
if versioncmp('1.0.0', $version) > 0 {
# I am not sure all of this is required as I assumed the
# ruby::dev class would have taken care of some of it
Class['::ruby'] ->
Class['ruby::dev'] ->
Package['gcc'] ->
Package['make'] ->
Package['r10k']
}

}
9 changes: 6 additions & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@
$git_server = $::settings::ca_server
$repo_path = '/var/repos'
$remote = "ssh://${git_server}${repo_path}/modules.git"
$source_name = 'jiminy'

# Puppet Enterprise specific settings
if $::is_pe == 'true' {
# Puppet Enterprise specific settings
$puppetconf_path = '/etc/puppetlabs/puppet'

$pe_module_path = '/opt/puppet/share/puppet/modules'
# Mcollective configuration dynamic
$mc_service_name = 'pe-mcollective'
$plugins_dir = '/opt/puppet/libexec/mcollective/mcollective'
$modulepath = "${r10k_basedir}/\$environment/modules:/opt/puppet/share/puppet/modules"
$modulepath = "${r10k_basedir}/\$environment/modules:${pe_module_path}"
$pe_ruby = true
} else {
# Getting ready for FOSS support in this module
$puppetconf_path = '/etc/puppet'

# Mcollective configuration dynamic
$mc_service_name = 'mcollective'
Expand Down
9 changes: 2 additions & 7 deletions templates/etc/r10k.yaml.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
:cachedir: <%= @cachedir %>
<% if @sources.empty? -%>
:sources:
:<%= @source_name %>:
remote: <%= @remote %>
basedir: <%= @basedir %>
<% else -%>
<% unless @r10k_sources.empty? -%>
:sources:
<%# The splitting/joining monkeybusiness trims the YAML document header: `---` -%>
<%= @sources.to_yaml.split("\n")[1..-1].join("\n") %>
<%= @r10k_sources.to_yaml.split("\n")[1..-1].join("\n") %>
<% end %>
<%# The Array boxing/flattening ensures we don't get bitten by bug #15813 -%>
<% unless [@purgedirs].flatten.empty? -%>
Expand Down
17 changes: 2 additions & 15 deletions tests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@
# Learn more about module testing here: http://docs.puppetlabs.com/guides/tests_smoke.html
#
class { 'r10k':
pe_ruby => false,
sources => {
'puppet' => {
'remote' => 'git@github.com:acidprime/puppet.git',
'basedir' => "${::settings::confdir}/environments"
},
'hiera' => {
'remote' => 'git@github.com:acidprime/hiera.git',
'basedir' => "${::settings::confdir}/hiera"
},
},
purgedirs => [
"${::settings::confdir}/environments",
"${::settings::confdir}/hiera",
],
remote => 'git@github.com:acidprime/puppet.git',
pe_ruby => false,
}