Showing with 1,547 additions and 147 deletions.
  1. +1 −1 .fixtures.yml
  2. +1 −0 .gitignore
  3. +23 −1 .travis.yml
  4. +15 −0 CHANGELOG
  5. +9 −6 Gemfile
  6. +48 −14 README.md
  7. +4 −0 Rakefile
  8. +1 −1 files/prefix_command.rb
  9. +11 −0 lib/facter/r10k_path.rb
  10. +11 −1 manifests/config.pp
  11. +17 −0 manifests/init.pp
  12. +22 −6 manifests/install.pp
  13. +4 −2 manifests/install/pe_gem.pp
  14. +13 −0 manifests/install/puppet_gem.pp
  15. +1 −9 manifests/mcollective.pp
  16. +108 −24 manifests/params.pp
  17. +23 −12 manifests/webhook.pp
  18. +3 −1 manifests/webhook/config.pp
  19. +29 −9 manifests/webhook/package.pp
  20. +3 −3 metadata.json
  21. +62 −0 spec/acceptance/basic_webhook_spec.rb
  22. +12 −0 spec/acceptance/nodesets/centos-64-x64-pe.yml
  23. +12 −0 spec/acceptance/nodesets/centos-66-x64.yml
  24. +12 −0 spec/acceptance/nodesets/centos-70-x64.yml
  25. +12 −0 spec/acceptance/nodesets/debian-78-x64.yml
  26. +1 −0 spec/acceptance/nodesets/default.yml
  27. +13 −0 spec/acceptance/nodesets/ubuntu-server-1204-x86.yml
  28. +13 −0 spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
  29. +65 −0 spec/acceptance/prefix_webhook_spec.rb
  30. +62 −8 spec/classes/config_spec.rb
  31. +1 −1 spec/classes/init_spec.rb
  32. +52 −2 spec/classes/install/pe_gem_spec.rb
  33. +19 −0 spec/classes/install/puppet_gem_spec.rb
  34. +165 −5 spec/classes/install_spec.rb
  35. +1 −1 spec/classes/mcollective_spec.rb
  36. +2 −2 spec/classes/params_spec.rb
  37. +67 −1 spec/classes/postrun_command_spec.rb
  38. +67 −1 spec/classes/prerun_command_spec.rb
  39. +138 −0 spec/classes/webhook/config_spec.rb
  40. +166 −0 spec/classes/webhook/package_spec.rb
  41. +84 −6 spec/classes/webhook_spec.rb
  42. +37 −0 spec/spec_helper_acceptance.rb
  43. +16 −0 spec/unit/facter/r10k_path_spec.rb
  44. +13 −1 templates/agent/r10k.rb.erb
  45. +10 −0 templates/r10k.yaml.erb
  46. +80 −28 templates/webhook.bin.erb
  47. 0 templates/{webhook.rehat.service.erb → webhook.redhat.service.erb}
  48. +18 −1 templates/webhook.yaml.erb
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ spec/fixtures/manifests/site.pp
.bundle
.ruby-version
Gemfile.lock
log/*
24 changes: 23 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ branches:
only:
- master
language: ruby
bundler_args: --without development
bundler_args: --without acceptance
script:
- "bundle exec rake lint"
- "bundle exec rake syntax"
Expand All @@ -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
15 changes: 15 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
3.1.0 - Mickaël Canévet & Ben Ford
* Fix typo related to cachedir
* Add support for automatically calculated prefixes from github ( backwarda compatible)
* Add some new prefix acceptance tests ( WIP )
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
15 changes: 9 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org"
group :development, :test do
gem 'rake', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-core', '2.99.2', :require => false
gem 'rspec-puppet', '~> 1.0', :require => false
gem "rspec", '< 3.2.0'
gem "rspec-core", "3.1.7"
gem "rspec-puppet", "~> 2.1"
gem 'puppet-lint', :require => false
gem 'puppet-syntax', :require => false
end

#group :system_tests do
# gem 'beaker-rspec', :require => false
# gem 'serverspec', :require => false
#end
group :acceptance do
gem "beaker", "> 2.0.0"
gem "beaker-rspec", ">= 5.1.0"
gem 'serverspec', :require => false
gem "vagrant-wrapper"
end

if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion, :require => false
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
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ PuppetSyntax.exclude_paths = exclude_paths
# :spec,
#]

desc "Run acceptance tests"
RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
end
2 changes: 1 addition & 1 deletion files/prefix_command.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/puppet/bin/ruby
#!/usr/bin/env ruby
require 'json'
require 'yaml'

Expand Down
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
Loading