2 changes: 1 addition & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fixtures:
repositories:
stdlib:
repo: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
ref: "3.2.1"
ref: "4.6.0"
ruby: "git://github.com/puppetlabs/puppetlabs-ruby.git"
gcc: "git://github.com/puppetlabs/puppetlabs-gcc.git"
pe_gem: "git://github.com/puppetlabs/puppetlabs-pe_gem.git"
Expand Down
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- jruby-19mode
env:
- PUPPET_VERSION="~> 2.7.0"
- PUPPET_VERSION="~> 3.1.0"
Expand All @@ -25,6 +26,8 @@ env:
- PUPPET_VERSION="~> 3.5.1"
- PUPPET_VERSION="~> 3.6.0"
- PUPPET_VERSION="~> 3.7.0"
- PUPPET_VERSION="~> 3.8.0"
- PUPPET_VERSION="~> 3.8.1"

global:
- PUBLISHER_LOGIN=acidprime
Expand All @@ -36,6 +39,25 @@ matrix:
env: PUPPET_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_VERSION="~> 3.1.0"
- rvm: jruby-19mode
env: PUPPET_VERSION="~> 2.7.0"
- rvm: jruby-19mode
env: PUPPET_VERSION="~> 3.1.0"
- rvm: jruby-19mode
env: PUPPET_VERSION="~> 3.2.0"
- rvm: jruby-19mode
env: PUPPET_VERSION="~> 3.3.0"
- rvm: jruby-19mode
env: PUPPET_VERSION="~> 3.4.0"
- rvm: jruby-19mode
env: PUPPET_VERSION="~> 3.5.1"
- rvm: jruby-19mode
env: PUPPET_VERSION="~> 3.6.0"
include:
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
# - rvm: 2.1.6
# env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes"
notifications:
email: false
webhooks:
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
3.0.0 - Lots o Folks' see linked tickets
* Webhook compatibility on non masters servers (razor) #219
* Webhook YAML recreated on every run on ruby 1.8.7 #209
* Add postrun command support #211
* Add r10k_path fact #222
* Remove depricated params git_ssl_verify
* add git_settings param for rugged support
* Fix webhook issue when running as root #217
* Added support for Bitbucket merge hooks #193
* Add ability to be installed on non-masters i.e. razor #219
* Updated for PE 2015.2 and Puppet 4 ( which are pretty much the same thing now)
2.8.2 - Jordan Olshevski
* Fix for RHEL 7 webhook
2.8.2 - Jerald Sheets
Expand Down
62 changes: 48 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# r10k Configuration Module
[![Puppet Forge](http://img.shields.io/puppetforge/v/zack/r10k.svg)](https://forge.puppetlabs.com/zack/r10k)
[![Github Tag](https://img.shields.io/github/tag/acidprime/r10k.svg)](https://github.com/acidprime/r10k)
[![Build Status](https://travis-ci.org/acidprime/r10k.png?branch=master)](https://travis-ci.org/acidprime/r10k)
[![Github Tag](https://img.shields.io/github/tag/acidprime/r10k.svg)](https://github.com/acidprime/r10k)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/acidprime/r10k?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

#### Table of Contents
Expand Down Expand Up @@ -56,8 +56,8 @@ class { 'r10k':

* Installation of the r10k `gem`
* Installation of git
* Installation of ruby when not using an existing ruby stack i.e. when using `pe_gem`
* Installation of ruby if not using an existing ruby stack i.e. when using `pe_gem`.
* Installation of ruby when not using an existing ruby stack i.e. when using `pe_gem` or `puppet_gem`
* Installation of ruby if not using an existing ruby stack i.e. when using `pe_gem` or `puppet_gem`.
* Management of the `r10k.yaml` in /etc
* Instllation and configuration of a sinatra app when using the [webhook](#webhook-support).

Expand All @@ -69,7 +69,9 @@ You can override this by passing the `version` parameter.

| Module Version | r10k Version |
| -------------- | ------------ |
| Next Release | [![Latest Version](https://img.shields.io/gem/v/r10k.svg?style=flat-square)](https://rubygems.org/gems/r10k) |
| Next Major | [![Latest Version](https://img.shields.io/gem/v/r10k.svg?style=flat-square)](https://rubygems.org/gems/r10k) |
| v3.0.x | 1.5.1 |
| v2.8.2 | 1.5.1 |
| v2.7.x | 1.5.1 |
| v2.6.5 | 1.4.1 |
| v2.5.4 | 1.4.0 |
Expand Down Expand Up @@ -130,15 +132,28 @@ ruby using the [puppetlabs/ruby](http://forge.puppetlabs.com/puppetlabs/ruby) mo

It also supports installation via multiple providers, such as installation in the puppet_enterprise ruby stack in versions less than 3.8

Installing into the puppet enterprise ruby stack
Installing into the puppet enterprise ruby stack in PE 3.x
```puppet
class { 'r10k':
remote => 'git@github.com:someuser/puppet.git',
provider => 'pe_gem',
}
```
_Note: On Puppet Enterprise 3.8 and higher the package is not declared as 3.8
ships with an embdedded r10k gem installed via the PE packages_
ships with an embdedded r10k gem installed via the PE packages. To install r10k on a PE 3.8+ non-master, set puppet_master to false for the main r10k class (e.g. to use r10k with Razor)_

Installing into the Puppet Enterprise ruby stack in PE 2015.x

```puppet
class { 'r10k':
remote => 'git@github.com:someuser/puppet.git',
provider => 'puppet_gem',
}
```

_Note: It is recommended you migrate to using the `pe_r10k` module which is basically
a clone of this modules features and file tickets for anything missing._


## Usage

Expand Down Expand Up @@ -229,7 +244,7 @@ The mcollective agent can be configured to supply r10k/git environment `http_pro
```puppet
class { '::r10k::mcollective':
http_proxy => 'http://proxy.example.lan:3128',
git_ssl_verify => 1,
git_ssl_no_verify => 1,
}
```

Expand Down Expand Up @@ -415,7 +430,8 @@ git_webhook { 'web_post_receive_webhook_for_module' :
### Running without mcollective
If you have only a single master, you may want to have the webhook run r10k directly rather then
as peadmin via mcollective. This requires you to run as the user that can perform `r10k` commands
which is typically root.
which is typically root. The peadmin certificate no longer is managed or required.


```puppet
# Instead of running via mco, run r10k directly
Expand All @@ -427,9 +443,10 @@ class {'r10k::webhook::config':
# It will issue r10k deploy environment <branch_from_gitlab_payload> -p
# When git pushes happen.
class {'r10k::webhook':
user => 'root',
group => '0',
require => Class['r10k::webhook::config'],
use_mcollective => false,
user => 'root',
group => '0',
require => Class['r10k::webhook::config'],
}
```

Expand Down Expand Up @@ -510,9 +527,6 @@ A string to be passed in as the source with a hardcode prefix of `puppet`
##### `sources`
A hash of all sources, this gets read out into the file as yaml. Must not be declared with `remote`

##### `purgedirs`
A single string setting the `r10k.yaml` configuration value of the same name

##### `cachedir`
A single string setting the `r10k.yaml` configuration value of the same name

Expand Down Expand Up @@ -574,6 +588,22 @@ Install mcollective application and agents. This does NOT configure mcollective
##### `manage_configfile_symlink`
Manage a symlink to the configuration file, for systems installed in weird file system configurations

##### `git_settings`
This is the `git:` key in r10k, it accepts a hash that can be used to configure
rugged support.

```puppet
$git_settings = {
'provider' => 'rugged',
'private_key' => '/root/.ssh/id_rsa',
}
class {'r10k':
remote => 'git@github.com:acidprime/puppet.git',
git_settings => $git_settings,
}
```

##### `configfile_symlink`
boolean if to manage symlink

Expand Down Expand Up @@ -620,6 +650,7 @@ Quickstart:
gem install bundler
bundle install
bundle exec rake spec
bundle exec rake lint
```

####Ruby = 1.8.7
Expand All @@ -628,4 +659,7 @@ Quickstart:
gem install bundler
bundle install --without system_tests
bundle exec rake spec
bundle exec rake lint
```

Check the .travis.yml for supported Operating System Versions
11 changes: 11 additions & 0 deletions lib/facter/r10k_path.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Facter.add(:r10k_path) do
confine :kernel => :linux
setcode do
path = Facter::Util::Resolution.exec("which r10k")
if path
path.to_s
else
nil
end
end
end
12 changes: 11 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
# * [*sources*]
# Hash containing data sources to be used by r10k to create dynamic Puppet
# environments. Default: {}
# * [*postrun*]
# **Optional:** Array containing the parts of a system call.
# Example: ['/usr/bin/curl', '-F', 'deploy=done', 'http://my-app.site/endpoint']
# Default: undef
# * [*manage_configfile_symlink*]
# Boolean to determine if a symlink to the r10k config file is to be managed.
# Default: false
Expand Down Expand Up @@ -46,11 +50,13 @@
$modulepath = undef,
$remote = '',
$sources = 'UNSET',
$postrun = undef,
$puppetconf_path = $r10k::params::puppetconf_path,
$r10k_basedir = $r10k::params::r10k_basedir,
$manage_configfile_symlink = $r10k::params::manage_configfile_symlink,
$configfile_symlink = '/etc/r10k.yaml',
$r10k_yaml_template = 'r10k/r10k.yaml.erb'
$r10k_yaml_template = 'r10k/r10k.yaml.erb',
$git_settings = {},
) inherits r10k::params {

validate_bool($manage_modulepath)
Expand Down Expand Up @@ -79,6 +85,10 @@
$source_keys = keys($r10k_sources)
}

if $postrun != undef {
validate_array($postrun)
}

file { 'r10k.yaml':
ensure => file,
owner => 'root',
Expand Down
17 changes: 17 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$cachedir = $r10k::params::r10k_cache_dir,
$configfile = $r10k::params::r10k_config_file,
$version = $r10k::params::version,
$puppet_master = $r10k::params::puppet_master,
$modulepath = $r10k::params::modulepath,
$manage_modulepath = $r10k::params::manage_modulepath,
$manage_ruby_dependency = $r10k::params::manage_ruby_dependency,
Expand All @@ -16,12 +17,24 @@
$mcollective = $r10k::params::mcollective,
$manage_configfile_symlink = $r10k::params::manage_configfile_symlink,
$configfile_symlink = $r10k::params::configfile_symlink,
$git_settings = $r10k::params::git_settings,
$postrun = undef,
$include_prerun_command = false,
$include_postrun_command = false,
$install_gcc = false,
) inherits r10k::params {

# Check if user is declaring both classes
# Other classes like r10k::webhook is supported but
# using both classes makes no sense unless given pe_r10k
# overrides this modules default config
if defined(Class['pe_r10k']) {
fail('This module does not support being declared with pe_r10k')
}

$ruby_dependency_options=['include','declare','ignore']
validate_re($manage_ruby_dependency,$ruby_dependency_options)
validate_hash($git_settings)

# TODO: Clean this up when 3.0 to require a boolean
if $include_prerun_command == true or $include_prerun_command == 'true'{
Expand All @@ -40,6 +53,8 @@
package_name => $package_name,
provider => $provider,
version => $version,
puppet_master => $puppet_master,
install_gcc => $install_gcc,
}

class { 'r10k::config':
Expand All @@ -52,6 +67,8 @@
r10k_basedir => $r10k_basedir,
manage_configfile_symlink => $manage_configfile_symlink,
configfile_symlink => $configfile_symlink,
git_settings => $git_settings,
postrun => $postrun,
}

if $mcollective {
Expand Down
28 changes: 22 additions & 6 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,30 @@
$keywords,
$install_options,
$manage_ruby_dependency,
) {
$puppet_master = true,
$is_pe_server = $r10k::params::is_pe_server,
$install_gcc = false,
) inherits r10k::params {

# 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 {
if versioncmp('1.0.0', $version) > 0 or $install_gcc {
require gcc
require make
}

if $package_name == '' {
case $provider {
'openbsd': { $real_package_name = 'ruby21-r10k' }
'openbsd': {
if (versioncmp($::kernelversion, '5.8') < 0) {
$real_package_name = 'ruby21-r10k'
} else {
$real_package_name = 'ruby22-r10k'
}
}
'portage': { $real_package_name = 'app-admin/r10k' }
'yum': { $real_package_name = 'rubygem-r10k' }
default: { $real_package_name = 'r10k' }
Expand All @@ -47,11 +56,17 @@
version => $version;
}
}
elsif $provider == 'puppet_gem' {
# Puppet FOSS 4.2 and up ships a vendor provided ruby.
# Using puppet_gem uses that instead of the system ruby.
include r10k::install::puppet_gem
}
elsif $provider == 'pe_gem' {
include r10k::install::pe_gem
class { 'r10k::install::pe_gem':
puppet_master => $puppet_master,
}
}


# Currently we share a package resource to keep things simple
# Puppet seems to have a bug (see #87 ) related to passing an
# empty to value to the gem,pe_gem providers. This code
Expand All @@ -65,13 +80,14 @@

# Puppet Enterprise 3.8 and ships an embedded r10k so thats all thats supported
# This conditional should not effect FOSS customers based on the fact
unless ($::is_pe == 'true' or $::is_pe == true) and versioncmp($::pe_version, '3.8.0') >= 0 {
unless ($::is_pe == 'true' or $::is_pe == true) and versioncmp($::pe_version, '3.8.0') >= 0 and $puppet_master {
package { $real_package_name:
ensure => $version,
provider => $provider,
install_options => $provider_install_options
}
}

}
default: { fail("${module_name}: ${provider} is not supported. Valid values are: 'gem', 'pe_gem', 'puppet_gem', 'bundle', 'openbsd', 'portage', 'yum', 'zypper'") }
}
Expand Down
6 changes: 4 additions & 2 deletions manifests/install/pe_gem.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# This class links the r10k binary for PE
class r10k::install::pe_gem {
class r10k::install::pe_gem (
$puppet_master,
) {

require git

# Puppet Enterprise 3.8 ships code to manage this symlink on install
# This conditional should not effect FOSS customers based on the fact
unless versioncmp($::pe_version, '3.8.0') >= 0 {
unless versioncmp($::pe_version, '3.8.0') >= 0 and $puppet_master {
file { '/usr/bin/r10k':
ensure => link,
target => '/opt/puppet/bin/r10k',
Expand Down
Loading