4 changes: 3 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ fixtures:
inifile: "git://github.com/puppetlabs/puppetlabs-inifile.git"
vcsrepo: "git://github.com/puppetlabs/puppetlabs-vcsrepo.git"
git: "git://github.com/puppetlabs/puppetlabs-git.git"
portage: "git://github.com/gentoo/puppet-portage.git"
portage:
repo: "git://github.com/gentoo/puppet-portage.git"
ref: "2.3.0"
symlinks:
r10k: "#{source_dir}"
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
modulesync_config_version: '0.16.7'
modulesync_config_version: '0.16.11'
8 changes: 6 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Style/WhileUntilModifier:
Lint/AmbiguousRegexpLiteral:
Enabled: True

Lint/Eval:
Security/Eval:
Enabled: True

Lint/BlockAlignment:
Expand Down Expand Up @@ -302,7 +302,7 @@ Style/EmptyLiteral:
Metrics/LineLength:
Enabled: False

Style/MethodCallParentheses:
Style/MethodCallWithoutArgsParentheses:
Enabled: True

Style/MethodDefParentheses:
Expand Down Expand Up @@ -518,3 +518,7 @@ RSpec/RepeatedDescription:

RSpec/NestedGroups:
Enabled: False

# disable Yaml safe_load. This is needed to support ruby2.0.0 development envs
Security/YAMLLoad:
Enabled: false
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ before_install:
- bundle -v
- rm Gemfile.lock || true
- gem update --system
- gem update bundler
- gem install bundler -v '~>1.13.0'
- gem --version
- bundle -v
script:
Expand Down
25 changes: 22 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not impact the functionality of the module.

## [v4.2.0](https://github.com/voxpupuli/puppet-r10k/tree/v4.2.0) (2017-02-11)

This is the last release with Puppet3 support!
[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v4.1.0...v4.2.0)

**Closed issues:**

- Add support for changing deploy settings [\#332](https://github.com/voxpupuli/puppet-r10k/issues/332)
- Document breaking changes in CHANGELOG [\#306](https://github.com/voxpupuli/puppet-r10k/issues/306)
- Status 42, OK, but it doesn't completely work [\#261](https://github.com/voxpupuli/puppet-r10k/issues/261)
- \(enhancement\) pre-commit hook only validates what's on disk [\#234](https://github.com/voxpupuli/puppet-r10k/issues/234)

**Merged pull requests:**

- Added new 'deploy\_settings' information [\#334](https://github.com/voxpupuli/puppet-r10k/pull/334) ([triforce](https://github.com/triforce))
- Add support for changing the 'deploy' settings in the r10k.yaml configuration file [\#333](https://github.com/voxpupuli/puppet-r10k/pull/333) ([triforce](https://github.com/triforce))
- Added Slack webhook [\#331](https://github.com/voxpupuli/puppet-r10k/pull/331) ([jamtur01](https://github.com/jamtur01))
- mcollective plugin dir has changed for foss puppet 4 [\#330](https://github.com/voxpupuli/puppet-r10k/pull/330) ([attachmentgenie](https://github.com/attachmentgenie))
- Better document soft dependency abrader/gms [\#327](https://github.com/voxpupuli/puppet-r10k/pull/327) ([rnelson0](https://github.com/rnelson0))

## [v4.1.0](https://github.com/voxpupuli/puppet-r10k/tree/v4.1.0) (2017-01-06)
[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v4.0.2...v4.1.0)

Expand All @@ -15,11 +35,10 @@ These should not impact the functionality of the module.

**Merged pull requests:**

- Release 4.1.0 [\#325](https://github.com/voxpupuli/puppet-r10k/pull/325) ([rnelson0](https://github.com/rnelson0))
- \(GH323\) Better parameterization of root user/group from \#279 [\#324](https://github.com/voxpupuli/puppet-r10k/pull/324) ([rnelson0](https://github.com/rnelson0))
- Fix rubocop failures from \#268 [\#322](https://github.com/voxpupuli/puppet-r10k/pull/322) ([rnelson0](https://github.com/rnelson0))
- modulesync 0.16.7 [\#320](https://github.com/voxpupuli/puppet-r10k/pull/320) ([bastelfreak](https://github.com/bastelfreak))
- Bump minimum version dependencies \(for Puppet 4\) [\#318](https://github.com/voxpupuli/puppet-r10k/pull/318) ([juniorsysadmin](https://github.com/juniorsysadmin))
- modulesync 0.16.6 [\#317](https://github.com/voxpupuli/puppet-r10k/pull/317) ([bastelfreak](https://github.com/bastelfreak))
- Bump puppet minimum version\_requirement to 3.8.7 [\#315](https://github.com/voxpupuli/puppet-r10k/pull/315) ([juniorsysadmin](https://github.com/juniorsysadmin))
- \[284\] Replace hard-coded version 1.5.1 with installed [\#308](https://github.com/voxpupuli/puppet-r10k/pull/308) ([rnelson0](https://github.com/rnelson0))
- use puppet/make instead of deprecated croddy/make [\#307](https://github.com/voxpupuli/puppet-r10k/pull/307) ([croddy](https://github.com/croddy))
Expand Down Expand Up @@ -693,4 +712,4 @@ These should not impact the functionality of the module.
## [v0.0.1](https://github.com/voxpupuli/puppet-r10k/tree/v0.0.1) (2013-06-12)


\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
7 changes: 3 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ group :test do
gem 'puppet-blacksmith', :require => false
gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem.git'
gem 'puppet-strings', '~> 1.0.0', :require => false
gem 'rubocop-rspec', '~> 1.9.0', :require => false if RUBY_VERSION >= '2.3.0'
gem 'redcarpet', :require => false
gem 'rubocop', '~> 0.47.0', :require => false if RUBY_VERSION >= '2.3.0'
gem 'rubocop-rspec', '~> 1.10.0', :require => false if RUBY_VERSION >= '2.3.0'
gem 'json_pure', '<= 2.0.1', :require => false if RUBY_VERSION < '2.0.0'
gem 'mocha', '>= 1.2.1', :require => false
gem 'coveralls', :require => false if RUBY_VERSION >= '2.0.0'
gem 'simplecov-console', :require => false if RUBY_VERSION >= '2.0.0'
gem 'github_changelog_generator', '~> 1.13.0', :require => false if RUBY_VERSION < '2.2.2'
gem 'github_changelog_generator', :require => false if RUBY_VERSION >= '2.2.2'
gem 'rack', '~> 1.0', :require => false if RUBY_VERSION < '2.2.2'
end

group :development do
Expand Down
54 changes: 49 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ sshkey { "your.internal.gitlab.server.com":
key => "...+dffsfHQ=="
}
# https://github.com/abrader/abrader-gms
# Resource git_webhook is provided by https://forge.puppet.com/abrader/gms
git_deploy_key { 'add_deploy_key_to_puppet_control':
ensure => present,
name => $::fqdn,
Expand Down Expand Up @@ -276,8 +276,9 @@ class {'r10k::webhook':
require => Class['r10k::webhook::config'],
}
# https://github.com/abrader/abrader-gms
# Add webhook to control repository ( the repo where the Puppetfile lives )
#
# Resource git_webhook is provided by https://forge.puppet.com/abrader/gms
git_webhook { 'web_post_receive_webhook' :
ensure => present,
webhook_url => 'http://master.of.masters:8088/payload',
Expand All @@ -294,6 +295,8 @@ git_webhook { 'web_post_receive_webhook' :
# :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->
#
# Resource git_webhook is provided by https://forge.puppet.com/abrader/gms
git_webhook { 'web_post_receive_webhook_for_module' :
ensure => present,
webhook_url => 'http://master.of.masters:8088/module',
Expand Down Expand Up @@ -325,9 +328,9 @@ class {'r10k::webhook':
require => Class['r10k::webhook::config'],
}
# https://github.com/abrader/abrader-gms
# Add webhook to control repository ( the repo where the Puppetfile lives )
# Requires gms 0.0.6+ for disable_ssl_verify param
#
# Resource git_webhook is provided by https://forge.puppet.com/abrader/gms
git_webhook { 'web_post_receive_webhook' :
ensure => present,
webhook_url => 'https://puppet:puppet@hole.in.firewall:8088/payload',
Expand All @@ -344,6 +347,8 @@ git_webhook { 'web_post_receive_webhook' :
# :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->
#
# Resource git_webhook is provided by https://forge.puppet.com/abrader/gms
git_webhook { 'web_post_receive_webhook_for_module' :
ensure => present,
webhook_url => 'https://puppet:puppet@hole.in.firewall:8088/module',
Expand Down Expand Up @@ -439,7 +444,8 @@ class {'r10k::webhook':
require => Class['r10k::webhook::config'],
}
# Deploy this webhook to your local gitlab server for the puppet/control repo.
# https://github.com/abrader/abrader-gms
#
# Resource git_webhook is provided by https://forge.puppet.com/abrader/gms
git_webhook { 'web_post_receive_webhook' :
ensure => present,
webhook_url => 'https://puppet:puppet@master.of.masters:8088/payload',
Expand Down Expand Up @@ -474,6 +480,30 @@ class { '::r10k::webhook':
}
```

### Webhook Slack notifications

You can enable Slack notifications for the webhook. You will need a
Slack webhook URL and the `slack-notifier` gem installed.

To get the Slack webhook URL you need to:

1. Go to
[https://slack.com/apps/A0F7XDUAZ-incoming-webhooks](https://slack.com/apps/A0F7XDUAZ-incoming-webhooks).
2. Choose your team, press `Configure`.
3. In configurations press `Add configuration`.
4. Choose channel, press `Add Incoming WebHooks integration`.

Then configure the webhook to add your Slack Webhook URL.

```puppet
class { '::r10k::webhook::config':
. . .
slack_webhook => 'http://slack.webhook/webhook', # mandatory for usage
slack_channel => '#channel', # defaults to #default
slack_username => 'r10k', # the username to use
}
```

### Triggering the webhook from curl

To aid in debugging, or to give you some hints as to how to trigger the webhook by unsupported systems, here's a curl command to trigger the webhook to deploy the 'production' environment:
Expand Down Expand Up @@ -593,6 +623,20 @@ This is the `forge:` key in r10k, it accepts a hash that contains settings for d
}
```

##### `deploy_settings`
This is the `deploy:` key in r10k, it accepts a hash that contains setting that control how r10k code deployments behave. Documentation for the settings can be found [here](https://docs.puppet.com/pe/latest/r10k_custom.html#deploy).

```puppet
$deploy_settings = {
'purge_levels' => ['puppetfile'],
}
class {'r10k':
remote => 'git@github.com:voxpupuli/puppet.git',
deploy_settings => $deploy_settings,
}
```

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

Expand Down
8 changes: 0 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet_blacksmith/rake_tasks'
require 'voxpupuli/release/rake_tasks'
require 'puppet-strings/tasks'
require 'github_changelog_generator/task'

PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}'
PuppetLint.configuration.fail_on_warnings = true
Expand Down Expand Up @@ -31,11 +30,4 @@ task test: [
:metadata_lint,
:release_checks,
]

GitHubChangelogGenerator::RakeTask.new :changelog do |config|
version = (Blacksmith::Modulefile.new).version
config.future_release = "v#{version}"
config.header = "# Change log\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not impact the functionality of the module."
config.exclude_labels = %w{duplicate question invalid wontfix modulesync}
end
# vim: syntax=ruby
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
$r10k_yaml_template = 'r10k/r10k.yaml.erb',
$git_settings = {},
$forge_settings = {},
$deploy_settings = {},
) inherits r10k::params {

validate_bool($manage_modulepath)
Expand Down
4 changes: 3 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
$configfile_symlink = $r10k::params::configfile_symlink,
$git_settings = $r10k::params::git_settings,
$forge_settings = $r10k::params::forge_settings,
$deploy_settings = $r10k::params::deploy_settings,
$root_user = $r10k::params::root_user,
$root_group = $r10k::params::root_group,
$postrun = undef,
Expand All @@ -37,7 +38,7 @@

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

# TODO: Clean this up when 4.0 to require a boolean
if $include_prerun_command == true or $include_prerun_command == 'true'{
Expand Down Expand Up @@ -72,6 +73,7 @@
configfile_symlink => $configfile_symlink,
git_settings => $git_settings,
forge_settings => $forge_settings,
deploy_settings => $deploy_settings,
postrun => $postrun,
root_user => $root_user,
root_group => $root_group,
Expand Down
6 changes: 5 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
$configfile_symlink = '/etc/r10k.yaml'
$git_settings = {}
$forge_settings = {}
$deploy_settings = {}
# Git configuration
$git_server = $::settings::ca_server
$repo_path = '/var/repos'
Expand Down Expand Up @@ -118,7 +119,7 @@

# Mcollective configuration dynamic
$mc_service_name = 'mcollective'
$plugins_dir = '/opt/puppetlabs/mcollective/plugins/mcollective'
$plugins_dir = '/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/mcollective'
$modulepath = undef
$provider = 'puppet_gem'
$r10k_binary = 'r10k'
Expand Down Expand Up @@ -237,6 +238,9 @@
$webhook_repository_events = undef
$webhook_enable_mutex_lock = false
$webhook_allow_uppercase = true # for backwards compatibility. Default to off on a major semver update.
$webhook_slack_webhook = undef
$webhook_slack_channel = undef
$webhook_slack_username = undef
$webhook_configfile_owner = 'root'
$webhook_configfile_group = $root_group
$webhook_configfile_mode = '0644'
Expand Down
6 changes: 6 additions & 0 deletions manifests/webhook/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
$command_prefix = $r10k::params::webhook_r10k_command_prefix,
$repository_events = $r10k::params::webhook_repository_events,
$allow_uppercase = $r10k::params::webhook_allow_uppercase,
$slack_webhook = $r10k::params::webhook_slack_webhook,
$slack_channel = $r10k::params::webhook_slack_channel,
$slack_username = $r10k::params::webhook_slack_username,
$configfile_owner = $r10k::params::webhook_configfile_owner,
$configfile_group = $r10k::params::webhook_configfile_group,
$configfile_mode = $r10k::params::webhook_configfile_mode,
Expand Down Expand Up @@ -69,6 +72,9 @@
'repository_events' => $repository_events,
'enable_mutex_lock' => $enable_mutex_lock,
'allow_uppercase' => $allow_uppercase,
'slack_webhook' => $slack_webhook,
'slack_channel' => $slack_channel,
'slack_username' => $slack_username,
}
} else {
validate_hash($hash)
Expand Down
10 changes: 5 additions & 5 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"mcollective",
"r10k"
],
"version": "4.1.0",
"version": "4.2.0",
"dependencies": [
{
"name": "puppetlabs/stdlib",
Expand All @@ -77,25 +77,25 @@
},
{
"name": "puppetlabs/inifile",
"version_requirement": ">=1.4.1 < 2.0.0"
"version_requirement": ">= 1.4.1 < 2.0.0"
},
{
"name": "puppetlabs/vcsrepo",
"version_requirement": ">=1.3.1 < 2.0.0"
"version_requirement": ">= 1.3.1 < 2.0.0"
},
{
"name": "puppetlabs/git",
"version_requirement": ">= 0.5.0 < 2.0.0"
},
{
"name": "gentoo/portage",
"version_requirement": ">= 2.3.0 < 3.0.0"
"version_requirement": "2.3.0"
}
],
"requirements": [
{
"name": "puppet",
"version_requirement": ">=3.8.7 < 5.0.0"
"version_requirement": ">= 3.8.7 < 5.0.0"
}
]
}
4 changes: 4 additions & 0 deletions spec/acceptance/basic_webhook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class {'r10k::webhook':
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

# rubocop:disable RSpec/RepeatedExample
shell('/usr/bin/curl -d \'{ "repository": { "name": "puppetlabs-stdlib" } }\' -H "Accept: application/json" "http://localhost:8088/module" -k -q') do |r|
it { expect(r.stdout).to match(%r{^.*success.*$}) }
it { expect(r.exit_code).to eq(0) }
Expand All @@ -49,6 +51,8 @@ class {'r10k::webhook':
it { expect(r.stdout).to match(%r{^.*success.*$}) }
it { expect(r.exit_code).to eq(0) }
end
# rubocop:enable RSpec/RepeatedExample

# rubocop:disable RSpec/MultipleExpectations
it 'successfully locks when hammered with multiple requests' do
4.times do
Expand Down
3 changes: 3 additions & 0 deletions spec/acceptance/prefix_webhook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class {'r10k::webhook':
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

# rubocop:disable RSpec/RepeatedExample
shell('/usr/bin/curl -d \'{ "ref": "refs/heads/production", "repository": { "name": "puppet-control" , "url": "https://github.com/webteam/somerepo.git"} }\' -H "Accept: application/json" "http://localhost:8088/payload" -k -q') do |r|
it { expect(r.stdout).to match(%r{^.*webteam_production.*$}) }
it { expect(r.exit_code).to eq(0) }
Expand All @@ -74,5 +76,6 @@ class {'r10k::webhook':
it { expect(r.stdout).to match(%r{^.* production.*$}) }
it { expect(r.exit_code).to eq(0) }
end
# rubocop:enable RSpec/RepeatedExample
end
end
Loading