Showing with 431 additions and 281 deletions.
  1. +0 −1 .fixtures.yml
  2. +4 −0 .github/workflows/ci.yml
  3. +1 −1 .msync.yml
  4. +3 −1 .puppet-lint.rc
  5. +21 −0 CHANGELOG.md
  6. +2 −2 Gemfile
  7. +11 −1 README.md
  8. +1 −1 Rakefile
  9. +2 −0 lib/facter/r10k_environment.rb
  10. +2 −0 lib/facter/r10k_path.rb
  11. +2 −2 manifests/install.pp
  12. +1 −1 manifests/install/bundle.pp
  13. +1 −1 manifests/install/puppet_gem.pp
  14. +2 −0 manifests/mcollective.pp
  15. +2 −1 manifests/params.pp
  16. +1 −1 manifests/webhook.pp
  17. +4 −1 metadata.json
  18. +10 −1 spec/acceptance/basic_webhook_spec.rb
  19. +6 −1 spec/acceptance/gitlab_token_webhook_spec.rb
  20. +10 −1 spec/acceptance/prefix_webhook_spec.rb
  21. +10 −5 spec/acceptance/signature_webhook_bitbucket_spec.rb
  22. +10 −5 spec/acceptance/signature_webhook_github_spec.rb
  23. +25 −20 spec/classes/config_spec.rb
  24. +3 −1 spec/classes/init_spec.rb
  25. +28 −22 spec/classes/install/bundle_spec.rb
  26. +7 −5 spec/classes/install/gem_spec.rb
  27. +6 −4 spec/classes/install/puppet_gem_spec.rb
  28. +71 −64 spec/classes/install_spec.rb
  29. +8 −4 spec/classes/mcollective_spec.rb
  30. +3 −1 spec/classes/params_spec.rb
  31. +27 −20 spec/classes/postrun_command_spec.rb
  32. +32 −24 spec/classes/prerun_command_spec.rb
  33. +4 −2 spec/classes/r10k_spec.rb
  34. +78 −67 spec/classes/webhook/config_spec.rb
  35. +9 −3 spec/classes/webhook/package_spec.rb
  36. +3 −1 spec/classes/webhook_spec.rb
  37. +5 −5 spec/spec_helper.rb
  38. +2 −0 spec/spec_helper_acceptance.rb
  39. +2 −0 spec/unit/facter/r10k_path_spec.rb
  40. +12 −11 tasks/deploy.rb
1 change: 0 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ fixtures:
repositories:
stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git
ruby: https://github.com/puppetlabs/puppetlabs-ruby.git
pe_gem: https://github.com/puppetlabs/puppetlabs-pe_gem.git
inifile: https://github.com/puppetlabs/puppetlabs-inifile.git
vcsrepo: https://github.com/puppetlabs/puppetlabs-vcsrepo.git
git: https://github.com/puppetlabs/puppetlabs-git.git
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ name: CI

on: pull_request

concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true

jobs:
setup_matrix:
name: 'Setup Test Matrix'
Expand Down
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '4.2.0'
modulesync_config_version: '5.1.0'
4 changes: 3 additions & 1 deletion .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
--no-quoted_booleans-check
--fail-on-warnings
--no-parameter_documentation-check
--no-parameter_types-check
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ 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 affect the functionality of the module.

## [v10.2.0](https://github.com/voxpupuli/puppet-r10k/tree/v10.2.0) (2022-06-20)

[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v10.1.1...v10.2.0)

**Implemented enhancements:**

- Add Gentoo support [\#576](https://github.com/voxpupuli/puppet-r10k/pull/576) ([bastelfreak](https://github.com/bastelfreak))
- Allow defining mcollective policies on the r10k agent [\#572](https://github.com/voxpupuli/puppet-r10k/pull/572) ([optiz0r](https://github.com/optiz0r))

**Closed issues:**

- Docs wrong for mcollective "deploy" command? [\#573](https://github.com/voxpupuli/puppet-r10k/issues/573)
- Enhancement Request: Support ignore\_branch\_prefixes in config hash / seperate [\#556](https://github.com/voxpupuli/puppet-r10k/issues/556)

**Merged pull requests:**

- Arch Linux: Disable acceptance tests for webhook [\#577](https://github.com/voxpupuli/puppet-r10k/pull/577) ([bastelfreak](https://github.com/bastelfreak))
- Fix mco r10k deploy command in docs to match actual behaviour [\#574](https://github.com/voxpupuli/puppet-r10k/pull/574) ([optiz0r](https://github.com/optiz0r))
- puppet-lint: fix top\_scope\_facts warnings [\#569](https://github.com/voxpupuli/puppet-r10k/pull/569) ([bastelfreak](https://github.com/bastelfreak))
- Add additional curl example for environment prefixes [\#508](https://github.com/voxpupuli/puppet-r10k/pull/508) ([DLeich](https://github.com/DLeich))

## [v10.1.1](https://github.com/voxpupuli/puppet-r10k/tree/v10.1.1) (2021-08-27)

[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v10.1.0...v10.1.1)
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :test do
gem 'voxpupuli-test', '~> 2.5', :require => false
gem 'voxpupuli-test', '~> 5.0', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'puppet_metadata', '~> 1.0', :require => false
Expand All @@ -21,7 +21,7 @@ end

group :release do
gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5'
gem 'voxpupuli-release', '>= 1.0.2', :require => false
gem 'voxpupuli-release', '>= 1.2.0', :require => false
gem 'puppet-strings', '>= 2.2', :require => false
end

Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ mco r10k synchronize
You can sync an individual environment using:

```shell
mco r10k deploy environment <environment>
mco r10k deploy <environment>
```
Note: This implies `-p`

Expand Down Expand Up @@ -697,6 +697,16 @@ curl -d '
}' http://puppet-master.example:8088/payload
```

If you are utilizing environment prefixes, you'll need to specify the full environment title (including the prefix) in the 'ref' parameter:

```bash
curl -d '
{
"repository": {"name": "bar", "owner": {"login": "foo"}},
"ref": "bar_production"
}' http://puppet-master.example:8088/payload
```

### Troubleshooting

If you're not sure whether your webhook setup works:
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

# Attempt to load voxupuli-test (which pulls in puppetlabs_spec_helper),
# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper),
# otherwise attempt to load it directly.
begin
require 'voxpupuli/test/rake'
Expand Down
2 changes: 2 additions & 0 deletions lib/facter/r10k_environment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'puppet'
Facter.add('r10k_environment') do
setcode do
Expand Down
2 changes: 2 additions & 0 deletions lib/facter/r10k_path.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Facter.add(:r10k_path) do
confine :kernel => :linux # rubocop:disable Style/HashSyntax
setcode do
Expand Down
4 changes: 2 additions & 2 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if $package_name == '' {
case $provider {
'openbsd': {
if (versioncmp("${::kernelversion}", '5.8') < 0) { #lint:ignore:only_variable_string
if (versioncmp("${facts['kernelversion']}", '5.8') < 0) { #lint:ignore:only_variable_string
$real_package_name = 'ruby21-r10k'
} else {
$real_package_name = 'ruby22-r10k'
Expand All @@ -29,7 +29,7 @@
'bundle': {
include r10k::install::bundle
}
'puppet_gem', 'gem', 'openbsd', 'pkgng', 'pacman': {
'puppet_gem', 'gem', 'openbsd', 'pkgng', 'pacman', 'portage': {
if $provider == 'gem' {
class { 'r10k::install::gem':
manage_ruby_dependency => $manage_ruby_dependency,
Expand Down
2 changes: 1 addition & 1 deletion manifests/install/bundle.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
cwd => '/tmp/r10k',
require => [Package["${module_name}-bundle"], Vcsrepo["${module_name}-r10k-github"]],
unless => 'bundle list | grep -q " r10k "',
path => $::path,
path => $::facts['path'],
}
}
2 changes: 1 addition & 1 deletion manifests/install/puppet_gem.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This class links the r10k binary for Puppet FOSS 4.2 and up
class r10k::install::puppet_gem {
if versioncmp("${::puppetversion}", '4.2.0') >= 0 { #lint:ignore:only_variable_string
if versioncmp("${::facts['puppetversion']}", '4.2.0') >= 0 { #lint:ignore:only_variable_string
file { '/usr/bin/r10k':
ensure => link,
target => '/opt/puppetlabs/puppet/bin/r10k',
Expand Down
2 changes: 2 additions & 0 deletions manifests/mcollective.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$server = true,
$client = true,
$http_proxy = '',
$policies = [],
) inherits r10k::params {
include mcollective
mcollective::module_plugin { 'mcollective_agent_r10k':
Expand All @@ -24,5 +25,6 @@
client_files => [
'application/r10k.rb',
],
policies => $policies,
}
}
3 changes: 2 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

$provider = $facts['os']['name'] ? {
'Archlinux' => 'pacman',
'Gentoo' => 'portage',
default => 'puppet_gem',
}

Expand All @@ -32,7 +33,7 @@
$forge_settings = {}
$deploy_settings = {}
# Git configuration
$git_server = $::settings::ca_server
$git_server = $::settings::ca_server #lint:ignore:top_scope_facts
$repo_path = '/var/repos'
$remote = "ssh://${git_server}${repo_path}/modules.git"

Expand Down
2 changes: 1 addition & 1 deletion manifests/webhook.pp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
# Only managed this file if you are using mcollective mode
# We don't remove it as its part of PE and this is legacy
if $use_mcollective {
if $is_pe_server and versioncmp("${::puppetversion}", '3.7.0') >= 0 { #lint:ignore:only_variable_string
if $is_pe_server and versioncmp("${facts['puppetversion']}", '3.7.0') >= 0 { #lint:ignore:only_variable_string
# 3.7 does not place the certificate in peadmin's ~
# This places it there as if it was an upgrade
file { 'peadmin-cert.pem':
Expand Down
5 changes: 4 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Vox Pupuli",
"license": "Apache-2.0",
"name": "puppet-r10k",
"version": "10.1.1",
"version": "10.2.0",
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
Expand Down Expand Up @@ -37,6 +37,9 @@
},
{
"operatingsystem": "Archlinux"
},
{
"operatingsystem": "Gentoo"
}
],
"project_page": "https://github.com/voxpupuli/puppet-r10k",
Expand Down
11 changes: 10 additions & 1 deletion spec/acceptance/basic_webhook_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'System Ruby with No SSL, Not protected, No mcollective' do
describe 'System Ruby with No SSL, Not protected, No mcollective', unless: default[:platform] =~ %r{archlinux} do
context 'with basics parameters' do
hosts_as('agent').each do |agent|
it 'applies with no errors and idempotently' do
Expand Down Expand Up @@ -28,22 +30,28 @@ class {'r10k::webhook':
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

# rubocop:disable RSpec/RepeatedExampleGroupBody
describe command('/usr/bin/curl -d \'{ "repository": { "name": "puppetlabs-stdlib" } }\' -H "Accept: application/json" "http://localhost:8088/module" -k -q') do
its(:stdout) { is_expected.not_to match %r{.*You shall not pass.*} }
its(:exit_status) { is_expected.to eq 0 }
end

describe command('/usr/bin/curl -X POST -d \'{ "repository": { "full_name": "puppetlabs/puppetlabs-stdlib", "name": "PuppetLabs : StdLib" } }\' "http://localhost:8088/module" -k -q') do
its(:stdout) { is_expected.not_to match %r{.*You shall not pass.*} }
its(:exit_status) { is_expected.to eq 0 }
end

describe command('/usr/bin/curl -d \'{ "ref": "refs/heads/production" }\' -H "Accept: application/json" "http://localhost:8088/payload" -k -q') do
its(:stdout) { is_expected.not_to match %r{.*You shall not pass.*} }
its(:exit_status) { is_expected.to eq 0 }
end

describe command('/usr/bin/curl -X POST -d \'%7b%22ref%22%3a%22maste%r22%7d\' "http://localhost:8088/payload" -q') do
its(:stdout) { is_expected.not_to match %r{.*You shall not pass.*} }
its(:exit_status) { is_expected.to eq 0 }
end

describe command('/usr/bin/curl -X POST -d \'{ "push": { "changes": [ { "new": { "name": "production" } } ] } }\' "http://localhost:8088/payload" -q') do
its(:stdout) { is_expected.not_to match %r{.*You shall not pass.*} }
its(:exit_status) { is_expected.to eq 0 }
Expand All @@ -61,5 +69,6 @@ class {'r10k::webhook':
# end
# end
end
# rubocop:enable RSpec/RepeatedExampleGroupBody
end
end
7 changes: 6 additions & 1 deletion spec/acceptance/gitlab_token_webhook_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'
require 'openssl'

describe 'GitLab Secret Token Enabled, System Ruby with No SSL, Not protected, No mcollective' do
describe 'GitLab Secret Token Enabled, System Ruby with No SSL, Not protected, No mcollective', unless: default[:platform] =~ %r{archlinux} do
context 'default parameters' do
pp = %(
class { 'r10k':
Expand All @@ -22,9 +24,11 @@ class {'r10k::webhook':
it 'applies with no errors' do
apply_manifest(pp, catch_failures: true)
end

it 'is idempotent' do
apply_manifest(pp, catch_changes: true)
end

describe service('webhook') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
Expand All @@ -38,6 +42,7 @@ class {'r10k::webhook':
its(:exit_status) { is_expected.to eq 0 }
end
end

context 'supports Gitlab style payloads via payload end point with token in header' do
token = 'secret'

Expand Down
11 changes: 10 additions & 1 deletion spec/acceptance/prefix_webhook_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'Prefix Enabled,System Ruby with No SSL, Not protected, No mcollective' do
describe 'Prefix Enabled,System Ruby with No SSL, Not protected, No mcollective', unless: default[:platform] =~ %r{archlinux} do
context 'default parameters' do
pp = %(
file {'/usr/local/bin/prefix_command.rb':
Expand Down Expand Up @@ -50,29 +52,36 @@ class {'r10k::webhook':
it 'applies with no errors' do
apply_manifest(pp, catch_failures: true)
end

it 'is idempotent' do
apply_manifest(pp, catch_changes: true)
end

describe service('webhook') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

# rubocop:disable RSpec/RepeatedExampleGroupBody
describe command('/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
its(:stdout) { is_expected.not_to match %r{.*You shall not pass.*} }
its(:exit_status) { is_expected.to eq 0 }
end

describe command('/usr/bin/curl -d \'{ "ref": "refs/heads/production", "repository": { "name": "puppet-control" , "url": "https://github.com/secteam/someotherrepo.git"} }\' -H "Accept: application/json" "http://localhost:8088/payload" -k -q') do
its(:stdout) { is_expected.not_to match %r{.*You shall not pass.*} }
its(:exit_status) { is_expected.to eq 0 }
end

describe command('/usr/bin/curl -d \'{ "ref": "refs/heads/production", "repository": { "name": "puppet-control" , "url": "https://github.com/customprefix/repo.git"} }\' -H "Accept: application/json" "http://localhost:8088/payload" -k -q') do
its(:stdout) { is_expected.not_to match %r{.*You shall not pass.*} }
its(:exit_status) { is_expected.to eq 0 }
end

describe command('/usr/bin/curl -d \'{ "ref": "refs/heads/production", "repository": { "name": "puppet-control" , "url": "https://github.com/noprefix/repo.git"} }\' -H "Accept: application/json" "http://localhost:8088/payload" -k -q') do
its(:stdout) { is_expected.not_to match %r{.*You shall not pass.*} }
its(:exit_status) { is_expected.to eq 0 }
end
# rubocop:enable RSpec/RepeatedExampleGroupBody
end
end
15 changes: 10 additions & 5 deletions spec/acceptance/signature_webhook_bitbucket_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'
require 'openssl'

describe 'BitBucket Secret Enabled, System Ruby with No SSL, Not protected, No mcollective' do
describe 'BitBucket Secret Enabled, System Ruby with No SSL, Not protected, No mcollective', unless: default[:platform] =~ %r{archlinux} do
context 'default parameters' do
pp = %(
class { 'r10k':
Expand All @@ -22,26 +24,29 @@ class {'r10k::webhook':
it 'applies with no errors' do
apply_manifest(pp, catch_failures: true)
end

it 'is idempotent' do
apply_manifest(pp, catch_changes: true)
end

describe service('webhook') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

context 'supports style BitBucket payloads via module end point with signature in header' do
HMAC_DIGEST = OpenSSL::Digest.new('sha256')
signature = 'sha1=' + OpenSSL::HMAC.hexdigest(HMAC_DIGEST, 'secret', '{ "repository": { "name": "puppetlabs-stdlib" } }')
hmac_digest = OpenSSL::Digest.new('sha256')
signature = "sha1=#{OpenSSL::HMAC.hexdigest(hmac_digest, 'secret', '{ "repository": { "name": "puppetlabs-stdlib" } }')}"

describe command("/usr/bin/curl -d '{ \"repository\": { \"name\": \"puppetlabs-stdlib\" } }' -H \"Accept: application/json\" \"http://localhost:8088/module\" -H \"X-Hub-Signature: #{signature}\" -k -q") do
its(:stdout) { is_expected.not_to match %r{.*You shall not pass.*} }
its(:exit_status) { is_expected.to eq 0 }
end
end

context 'supports style BitBucket payloads via payload end point with signature in header' do
HMAC_DIGEST = OpenSSL::Digest.new('sha256')
signature = 'sha1=' + OpenSSL::HMAC.hexdigest(HMAC_DIGEST, 'secret', '{ "ref": "refs/heads/production" }')
hmac_digest = OpenSSL::Digest.new('sha256')
signature = "sha1=#{OpenSSL::HMAC.hexdigest(hmac_digest, 'secret', '{ "ref": "refs/heads/production" }')}"

describe command("/usr/bin/curl -d '{ \"ref\": \"refs/heads/production\" }' -H \"Accept: application/json\" -H \"X-Hub-Signature: #{signature}\" \"http://localhost:8088/payload\" -k -q") do
its(:stdout) { is_expected.not_to match %r{.*You shall not pass.*} }
Expand Down
Loading