Showing with 102 additions and 63 deletions.
  1. +3 −0 CHANGELOG
  2. +7 −2 Gemfile
  3. +1 −1 Modulefile
  4. +29 −2 README.md
  5. +1 −1 files/webhook
  6. +19 −17 manifests/params.pp
  7. +1 −1 manifests/webhook.pp
  8. +39 −37 manifests/webhook/config.pp
  9. +1 −1 metadata.json
  10. +1 −1 spec/classes/params_spec.rb
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.6.0 - Gary Larizza
* Fix "local" non mcollective hook tiggers to add '-p'
* See #125 , this will cause any current users to default to turning this on
2.6.0 - Eli Young & Ranjit Viswakumar
* Add bind_address to webhook
* bump r10k version to 1.4.1
Expand Down
9 changes: 7 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
source 'https://rubygems.org'
source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :development, :test do
gem 'rake', :require => false
gem 'rspec-puppet', :require => false
gem 'rspec-puppet', '~> 1.0', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'serverspec', :require => false
gem 'rspec-system', :require => false
Expand All @@ -12,6 +12,11 @@ group :development, :test do
gem 'puppet-syntax', :require => false
end

group :system_tests do
gem 'beaker-rspec', :require => false
gem 'serverspec', :require => false
end

if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion, :require => false
else
Expand Down
2 changes: 1 addition & 1 deletion Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'zack-r10k'
version '2.6.0'
version '2.6.1'
source 'https://github.com/acidprime/r10k'
author 'zack'
license 'Apache License, Version 2.0'
Expand Down
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ This is an example of using the webhok without authentication
The `git_webhook` type will using the [api token](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) to add the webhook to the "control" repo that contains your puppetfile. This is typically useful when you want all automate the addtion of the webhook to the repo.

```puppet
# Internal webhooks often don't need authentication and ssl
# # Change the url below if this is changed
class {'r10k::webhook::config':
enable_ssl => false,
protected => false,
Expand All @@ -337,7 +339,7 @@ git_webhook { 'web_post_receive_webhook' :
webhook_url => 'http://master.of.masters:8088/payload',
token => hiera('github_api_token'),
project_name => 'organization/control',
server_url => 'http://github.com',
server_url => 'https://api.github.com',
provider => 'github',
}
Expand All @@ -346,15 +348,40 @@ git_webhook { 'web_post_receive_webhook' :
# mod 'module_name',
# :git => 'http://github.com/organization/puppet-module_name',
# :branch => 'master'
# The module name is determined from the repo name , i.e. <puppet-><module_name>
# All characters with left and including any hyphen are removed i.e. <puppet->
git_webhook { 'web_post_receive_webhook_for_module' :
ensure => present,
webhook_url => 'http://master.of.masters:8088/module',
token => hiera('github_api_token'),
project_name => 'organization/puppet-module_name',
server_url => 'http://github.com',
server_url => 'https://api.github.com',
provider => 'github',
}
```
### 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.

```puppet
# Instead of running via mco, run r10k directly
class {'r10k::webhook::config':
use_mcollective => false,
}
# The hook needs to run as root when not running using mcollective
# 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'],
}
```




##Support

Expand Down
2 changes: 1 addition & 1 deletion files/webhook
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class Server < Sinatra::Base
command = "/opt/puppet/bin/mco r10k deploy #{branch} >> #{$config['mco_logfile']} 2>&1 &"
else
# If you don't use mcollective then this hook needs to be running as r10k's user i.e. root
command = "/opt/puppet/bin/r10k deploy environment #{branch} >> #{$config['mco_logfile']} 2>&1 &"
command = "/opt/puppet/bin/r10k deploy environment #{branch} #{$config['r10k_deploy_arguments']} >> #{$config['mco_logfile']} 2>&1 &"
end
message = "triggered: #{command}"
Process.detach(fork{ exec "#{command}"})
Expand Down
36 changes: 19 additions & 17 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,25 @@
$mcollective = false

# Webhook configuration information
$webhook_user = 'puppet'
$webhook_pass = 'puppet'
$webhook_bind_address = '0.0.0.0'
$webhook_port = '8088'
$webhook_access_logfile = '/var/log/webhook/access.log'
$webhook_mco_logfile = '/var/log/webhook/mco_output.log'
$webhook_certname = 'peadmin'
$webhook_certpath = '/var/lib/peadmin/.mcollective.d'
$webhook_client_cfg = '/var/lib/peadmin/.mcollective'
$webhook_use_mco_ruby = false
$webhook_protected = true
$webhook_discovery_timeout = 10
$webhook_client_timeout = 120
$webhook_prefix = false
$webhook_prefix_command = '/bin/echo example'
$webhook_enable_ssl = true
$webhook_use_mcollective = true
$webhook_user = 'puppet'
$webhook_pass = 'puppet'
$webhook_bind_address = '0.0.0.0'
$webhook_port = '8088'
$webhook_access_logfile = '/var/log/webhook/access.log'
$webhook_mco_logfile = '/var/log/webhook/mco_output.log'
$webhook_certname = 'peadmin'
$webhook_certpath = '/var/lib/peadmin/.mcollective.d'
$webhook_client_cfg = '/var/lib/peadmin/.mcollective'
$webhook_use_mco_ruby = false
$webhook_protected = true
$webhook_discovery_timeout = 10
$webhook_client_timeout = 120
$webhook_prefix = false
$webhook_prefix_command = '/bin/echo example'
$webhook_enable_ssl = true
$webhook_use_mcollective = true
$webhook_r10k_deploy_arguments = '-pv'

if $::osfamily == Debian {
$functions_path = '/lib/lsb/init-functions'
$start_pidfile_args = '--pidfile=$pidfile'
Expand Down
2 changes: 1 addition & 1 deletion manifests/webhook.pp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
# 3.7 does not place the certificate in peadmin's ~
# This places it there as if it was an upgrade
file { 'peadmin-cert.pem':
path => '/var/lib/peadmin/.mcollective.d/peadmin-cert.pem',
ensure => 'file',
path => '/var/lib/peadmin/.mcollective.d/peadmin-cert.pem',
owner => 'peadmin',
group => 'peadmin',
mode => '0644',
Expand Down
76 changes: 39 additions & 37 deletions manifests/webhook/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,49 @@
#
# Zack Smith <zack@puppetlabs.com>
class r10k::webhook::config (
$hash = 'UNSET',
$certname = $r10k::params::webhook_certname,
$certpath = $r10k::params::webhook_certpath,
$user = $r10k::params::webhook_user,
$pass = $r10k::params::webhook_pass,
$bind_address = $r10k::params::webhook_bind_address,
$port = $r10k::params::webhook_port,
$access_logfile = $r10k::params::webhook_access_logfile,
$mco_logfile = $r10k::params::webhook_mco_logfile,
$client_cfg = $r10k::params::webhook_client_cfg,
$use_mco_ruby = $r10k::params::webhook_use_mco_ruby,
$protected = $r10k::params::webhook_protected,
$discovery_timeout = $r10k::params::webhook_discovery_timeout,
$client_timeout = $r10k::params::webhook_client_timeout,
$prefix = $r10k::params::webhook_prefix,
$prefix_command = $r10k::params::webhook_prefix_command,
$enable_ssl = $r10k::params::webhook_enable_ssl,
$use_mcollective = $r10k::params::webhook_use_mcollective,
$configfile = '/etc/webhook.yaml',
$hash = 'UNSET',
$certname = $r10k::params::webhook_certname,
$certpath = $r10k::params::webhook_certpath,
$user = $r10k::params::webhook_user,
$pass = $r10k::params::webhook_pass,
$bind_address = $r10k::params::webhook_bind_address,
$port = $r10k::params::webhook_port,
$access_logfile = $r10k::params::webhook_access_logfile,
$mco_logfile = $r10k::params::webhook_mco_logfile,
$client_cfg = $r10k::params::webhook_client_cfg,
$use_mco_ruby = $r10k::params::webhook_use_mco_ruby,
$protected = $r10k::params::webhook_protected,
$discovery_timeout = $r10k::params::webhook_discovery_timeout,
$client_timeout = $r10k::params::webhook_client_timeout,
$prefix = $r10k::params::webhook_prefix,
$prefix_command = $r10k::params::webhook_prefix_command,
$enable_ssl = $r10k::params::webhook_enable_ssl,
$use_mcollective = $r10k::params::webhook_use_mcollective,
$r10k_deploy_arguments = $r10k::params::webhook_r10k_deploy_arguments,
$configfile = '/etc/webhook.yaml',
) inherits r10k::params {

if $hash == 'UNSET' {
$webhook_hash = {
'user' => $user,
'pass' => $pass,
'bind_address' => $bind_address,
'port' => $port,
'certname' => $certname,
'client_timeout' => $client_timeout,
'discovery_timeout' => $discovery_timeout,
'certpath' => $certpath,
'client_cfg' => $client_cfg,
'certpath' => $certpath,
'use_mco_ruby' => $use_mco_ruby,
'access_logfile' => $access_logfile,
'mco_logfile' => $mco_logfile,
'protected' => $protected,
'prefix' => $prefix,
'prefix_command' => $prefix_command,
'enable_ssl' => $enable_ssl,
'use_mcollective' => $use_mcollective,
'user' => $user,
'pass' => $pass,
'bind_address' => $bind_address,
'port' => $port,
'certname' => $certname,
'client_timeout' => $client_timeout,
'discovery_timeout' => $discovery_timeout,
'certpath' => $certpath,
'client_cfg' => $client_cfg,
'certpath' => $certpath,
'use_mco_ruby' => $use_mco_ruby,
'access_logfile' => $access_logfile,
'mco_logfile' => $mco_logfile,
'protected' => $protected,
'prefix' => $prefix,
'prefix_command' => $prefix_command,
'enable_ssl' => $enable_ssl,
'use_mcollective' => $use_mcollective,
'r10k_deploy_arguments' => $r10k_deploy_arguments,
}
} else {
validate_hash($hash)
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"source": "https://github.com/acidprime/r10k",
"summary": "Module for setting up dynamic environments using r10k",
"tags": ["git", "pe", "environment", "mcollective"],
"version": "2.6.0",
"version": "2.6.1",
"dependencies": [
{
"name": "puppetlabs/stdlib",
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
it { should contain_r10k__params }

it "Should not contain any resources" do
subject.resources.size.should == 4
expect(subject.resources.size).to eq(5)
end
end
end