Showing with 189 additions and 41 deletions.
  1. +31 −21 CHANGELOG.md
  2. +28 −1 README.md
  3. +3 −0 manifests/params.pp
  4. +6 −0 manifests/webhook/config.pp
  5. +3 −3 manifests/webhook/package.pp
  6. +1 −1 metadata.json
  7. +45 −0 spec/classes/webhook/config_spec.rb
  8. +4 −1 templates/r10k.yaml.erb
  9. +68 −14 templates/webhook.bin.erb
52 changes: 31 additions & 21 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ 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.

## [v6.5.0](https://github.com/voxpupuli/puppet-r10k/tree/v6.5.0) (2018-04-25)

[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v6.4.0...v6.5.0)

**Fixed bugs:**

- Restart webhook service after package update/installation [\#419](https://github.com/voxpupuli/puppet-r10k/pull/419) ([tuxmea](https://github.com/tuxmea))

**Closed issues:**

- undefined method `to\_h' in r10k.yaml.erb [\#421](https://github.com/voxpupuli/puppet-r10k/issues/421)

**Merged pull requests:**

- Remove Open3 and move process forks [\#425](https://github.com/voxpupuli/puppet-r10k/pull/425) ([dhollinger](https://github.com/dhollinger))
- Fixing compatibility with puppetserver/jruby. [\#424](https://github.com/voxpupuli/puppet-r10k/pull/424) ([dforste](https://github.com/dforste))
- Minor syntax update for deploying individual environment. [\#423](https://github.com/voxpupuli/puppet-r10k/pull/423) ([bschonec](https://github.com/bschonec))
- Add supports for rocketchat [\#413](https://github.com/voxpupuli/puppet-r10k/pull/413) ([amateo](https://github.com/amateo))

## [v6.4.0](https://github.com/voxpupuli/puppet-r10k/tree/v6.4.0) (2018-03-28)

[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v6.3.2...v6.4.0)
Expand Down Expand Up @@ -207,14 +226,14 @@ These should not affect the functionality of the module.

[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v4.0.1...v4.0.2)

**Merged pull requests:**

- Changelog for 4.0.1 [\#304](https://github.com/voxpupuli/puppet-r10k/pull/304) ([rnelson0](https://github.com/rnelson0))

## [v4.0.1](https://github.com/voxpupuli/puppet-r10k/tree/v4.0.1) (2016-11-20)

[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v4.0.0...v4.0.1)

**Merged pull requests:**

- Changelog for 4.0.1 [\#304](https://github.com/voxpupuli/puppet-r10k/pull/304) ([rnelson0](https://github.com/rnelson0))

## [v4.0.0](https://github.com/voxpupuli/puppet-r10k/tree/v4.0.0) (2016-11-20)

[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v3.2.0...v4.0.0)
Expand Down Expand Up @@ -290,15 +309,12 @@ These should not affect the functionality of the module.
- Automatically calculate some prefixes [\#236](https://github.com/voxpupuli/puppet-r10k/pull/236) ([binford2k](https://github.com/binford2k))
- Add the ability to respond only to certain events [\#235](https://github.com/voxpupuli/puppet-r10k/pull/235) ([binford2k](https://github.com/binford2k))
- Let rb scripts resolve what ruby to use themselves [\#233](https://github.com/voxpupuli/puppet-r10k/pull/233) ([attachmentgenie](https://github.com/attachmentgenie))
- Making r10k webhook 2015.x compatible [\#229](https://github.com/voxpupuli/puppet-r10k/pull/229) ([WhatsARanjit](https://github.com/WhatsARanjit))

## [v2.8.4](https://github.com/voxpupuli/puppet-r10k/tree/v2.8.4) (2015-08-03)

[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v3.0.0...v2.8.4)

**Merged pull requests:**

- Making r10k webhook 2015.x compatible [\#229](https://github.com/voxpupuli/puppet-r10k/pull/229) ([WhatsARanjit](https://github.com/WhatsARanjit))

## [v3.0.0](https://github.com/voxpupuli/puppet-r10k/tree/v3.0.0) (2015-07-31)

[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v2.8.3...v3.0.0)
Expand Down Expand Up @@ -467,6 +483,9 @@ These should not affect the functionality of the module.
**Merged pull requests:**

- 3.x [\#148](https://github.com/voxpupuli/puppet-r10k/pull/148) ([acidprime](https://github.com/acidprime))
- fix for /var/run being mounted on tmpfs in ubuntu 14.04 [\#147](https://github.com/voxpupuli/puppet-r10k/pull/147) ([spidersddd](https://github.com/spidersddd))
- Add commas in README example [\#143](https://github.com/voxpupuli/puppet-r10k/pull/143) ([cmurphy](https://github.com/cmurphy))
- support for 'user' argument to su to another user when executing git and R10K [\#142](https://github.com/voxpupuli/puppet-r10k/pull/142) ([GeoffWilliams](https://github.com/GeoffWilliams))

## [v2.6.5](https://github.com/voxpupuli/puppet-r10k/tree/v2.6.5) (2015-03-18)

Expand All @@ -480,12 +499,6 @@ These should not affect the functionality of the module.

- Add Gitlab support \(or add Gitlab documentation\) [\#145](https://github.com/voxpupuli/puppet-r10k/issues/145)

**Merged pull requests:**

- fix for /var/run being mounted on tmpfs in ubuntu 14.04 [\#147](https://github.com/voxpupuli/puppet-r10k/pull/147) ([spidersddd](https://github.com/spidersddd))
- Add commas in README example [\#143](https://github.com/voxpupuli/puppet-r10k/pull/143) ([cmurphy](https://github.com/cmurphy))
- support for 'user' argument to su to another user when executing git and R10K [\#142](https://github.com/voxpupuli/puppet-r10k/pull/142) ([GeoffWilliams](https://github.com/GeoffWilliams))

## [v2.6.4](https://github.com/voxpupuli/puppet-r10k/tree/v2.6.4) (2015-02-26)

[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v2.6.3...v2.6.4)
Expand Down Expand Up @@ -626,14 +639,14 @@ These should not affect the functionality of the module.

[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v2.4.0...v2.4.1)

**Closed issues:**

- r10k 1.3.5 has been released [\#98](https://github.com/voxpupuli/puppet-r10k/issues/98)

## [v2.4.0](https://github.com/voxpupuli/puppet-r10k/tree/v2.4.0) (2014-11-21)

[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v2.3.4...v2.4.0)

**Closed issues:**

- r10k 1.3.5 has been released [\#98](https://github.com/voxpupuli/puppet-r10k/issues/98)

## [v2.3.4](https://github.com/voxpupuli/puppet-r10k/tree/v2.3.4) (2014-11-20)

[Full Changelog](https://github.com/voxpupuli/puppet-r10k/compare/v2.3.3...v2.3.4)
Expand Down Expand Up @@ -835,11 +848,8 @@ These should not affect the functionality of the module.

**Merged pull requests:**

- Update config tests [\#33](https://github.com/voxpupuli/puppet-r10k/pull/33) ([xaque208](https://github.com/xaque208))
- Update config.pp [\#32](https://github.com/voxpupuli/puppet-r10k/pull/32) ([xaque208](https://github.com/xaque208))
- add ability to include mcollective agent through main class [\#30](https://github.com/voxpupuli/puppet-r10k/pull/30) ([jlambert121](https://github.com/jlambert121))
- update travis config, minor lint fixes [\#29](https://github.com/voxpupuli/puppet-r10k/pull/29) ([jlambert121](https://github.com/jlambert121))
- fixes for open-source puppet edition [\#28](https://github.com/voxpupuli/puppet-r10k/pull/28) ([attilabogar](https://github.com/attilabogar))
- The gem is called 'bundler' [\#27](https://github.com/voxpupuli/puppet-r10k/pull/27) ([glarizza](https://github.com/glarizza))
- Bump to 0.0.10 [\#26](https://github.com/voxpupuli/puppet-r10k/pull/26) ([glarizza](https://github.com/glarizza))
- Ability to pass package\_name [\#24](https://github.com/voxpupuli/puppet-r10k/pull/24) ([tampakrap](https://github.com/tampakrap))
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ mco r10k synchronize
You can sync an individual environment using:

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

Expand Down Expand Up @@ -556,6 +556,33 @@ class { 'r10k::webhook::config':
}
```

### Webhook Rocket.Chat notifications

You can enable Rocket.Chat notifications for the webhook. You will need a
Rocket.Chat incoming webhook URL and the `rocket-chat-notifier` gem installed.

To get the Rocket.Chat incoming webhook URL you need to:

1. Go to your Rocket.Chat and then select `Administration-Integrations`.
2. Choose `New integration`.
3. Choose `Incoming WebHook`. In the webhook form configure:
* `Enabled`: `True`.
* `Name`: A name for your webhook.
* `Post to Channel`: The channel to post to by default.
4. Save changes with `Save Changes` bottom.

Then configure the webhook to add your Rocket.Chat Webhook URL.

```puppet
class { 'r10k::webhook::config':
. . .
rocketchat_webhook => <your incoming webhook URL>, # mandatory for usage
rocketchat_username => 'username', # defaults to r10k
rocketchat_channel => '#channel', # defaults to #r10k
}
```


### Webhook Default Branch

The default branch of the controlrepo is commonly called `production`. This value can be overridden if you use another default branch name, such as `master`.
Expand Down
3 changes: 3 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@
$webhook_slack_channel = undef
$webhook_slack_username = undef
$webhook_slack_proxy_url = undef
$webhook_rocketchat_webhook = undef
$webhook_rocketchat_channel = undef
$webhook_rocketchat_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 @@ -38,6 +38,9 @@
$slack_channel = $r10k::params::webhook_slack_channel,
$slack_username = $r10k::params::webhook_slack_username,
$slack_proxy_url = $r10k::params::webhook_slack_proxy_url,
$rocketchat_webhook = $r10k::params::webhook_rocketchat_webhook,
$rocketchat_channel = $r10k::params::webhook_rocketchat_channel,
$rocketchat_username = $r10k::params::webhook_rocketchat_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 @@ -82,6 +85,9 @@
'slack_channel' => $slack_channel,
'slack_username' => $slack_username,
'slack_proxy_url' => $slack_proxy_url,
'rocketchat_webhook' => $rocketchat_webhook,
'rocketchat_channel' => $rocketchat_channel,
'rocketchat_username' => $rocketchat_username,
'ignore_environments' => $ignore_environments,
'mco_arguments' => $mco_arguments,
'generate_types' => $generate_types,
Expand Down
6 changes: 3 additions & 3 deletions manifests/webhook/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
package { 'sinatra':
ensure => $sinatra_version,
provider => $provider,
before => Service['webhook'],
notify => Service['webhook'],
}
}
if (! $is_pe_server) {
if !defined(Package['webrick']) {
package { 'webrick':
ensure => $webrick_version,
provider => $provider,
before => Service['webhook'],
notify => Service['webhook'],
}
}

if !defined(Package['json']) {
package { 'json':
ensure => installed,
provider => $provider,
before => Service['webhook'],
notify => Service['webhook'],
}
}
}
Expand Down
2 changes: 1 addition & 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": "6.4.0",
"version": "6.5.0",
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
Expand Down
45 changes: 45 additions & 0 deletions spec/classes/webhook/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,51 @@
it { is_expected.to contain_file('webhook.yaml').with_content(content) }
end

context 'FOSS with Rocket.Chat webhook enabled' do
let :params do
{
rocketchat_webhook: 'rocketchat_webhook'
}
end

it do
is_expected.to contain_file('webhook.yaml').with(
path: '/etc/webhook.yaml',
ensure: 'file',
owner: 'root',
group: 'root',
mode: '0644',
notify: 'Service[webhook]'
)
end
content = '---
access_logfile: "/var/log/webhook/access.log"
allow_uppercase: true
bind_address: "0.0.0.0"
client_cfg: "/var/lib/peadmin/.mcollective"
client_timeout: "120"
command_prefix: "umask 0022;"
default_branch: "production"
discovery_timeout: "10"
enable_mutex_lock: false
enable_ssl: true
generate_types: false
ignore_environments: []
pass: "puppet"
port: "8088"
prefix: false
prefix_command: "/bin/echo example"
protected: true
r10k_deploy_arguments: "-pv"
rocketchat_webhook: "rocketchat_webhook"
server_software: "WebHook"
use_mco_ruby: false
use_mcollective: true
user: "puppet"
'
it { is_expected.to contain_file('webhook.yaml').with_content(content) }
end

context 'Puppet Enterprise 2015.3.1 removing Webhook Config' do
let :params do
{
Expand Down
5 changes: 4 additions & 1 deletion templates/r10k.yaml.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<%
def settings_to_yaml(type, settings)
sorted_settings = settings.sort_by { |k,v| k }.to_h
require 'yaml'
hash = {}
settings.sort.map { |k,v| hash[k] = v }
sorted_settings = hash
hash = { type.to_sym => sorted_settings }
hash.to_yaml.gsub(/---\n/, '')
end
Expand Down
Loading