Showing with 211 additions and 11 deletions.
  1. +2 −0 CHANGELOG
  2. +1 −1 Modulefile
  3. +198 −5 README.md
  4. +10 −5 files/prefix_command.rb
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.4.1 - Zack Smith
* Documentation Updates
2.4.0 - Zack Smith
* Bump r10k version
2.3.4 - Eli Young
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.4.0'
version '2.4.1'
source 'https://github.com/acidprime/r10k'
author 'zack'
license 'Apache License, Version 2.0'
Expand Down
203 changes: 198 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ class { 'r10k':
}
```

Installing into the puppet enterprise ruby stack
```puppet
class { 'r10k':
remote => 'git@github.com:someuser/puppet.git',
provider => 'pe_gem',
}
```

## Version chart

| Module Version | r10k Version |
Expand All @@ -23,11 +31,37 @@ class { 'r10k':


This will configure `/etc/r10k.yaml` and install the r10k gem after installing
ruby using the [puppetlabs/ruby](http://forge.puppetlabs.com/puppetlabs/ruby) module. It also has a few helper classes that do
some useful things. The following entry in Hiera will add a `prerun_command` to puppet.conf.
ruby using the [puppetlabs/ruby](http://forge.puppetlabs.com/puppetlabs/ruby) module.

Here is an example of deploying the ssh keys needed for r10k to connect to a repo called puppet/control on a gitlab server.
```puppet
#https://docs.puppetlabs.com/references/latest/type.html#sshkey
sshkey { "your.internal.gitlab.server.com":
ensure => present,
type => "ssh-rsa",
target => "/root/.ssh/known_hosts",
key => "...+dffsfHQ=="
}
# https://github.com/abrader/abrader-gms
git_deploy_key { 'add_deploy_key_to_puppet_control':
ensure => present,
name => $::fqdn,
path => '/root/.ssh/id_dsa.pub',
token => hiera('gitlab_api_token'),
project_name => 'puppet/control',
server_url => 'http://your.internal.gitlab.server.com',
provider => 'gitlab.com',
}
```
r10k::include_prerun_command: true


## Helper classes
It also has a few helper classes that do
some useful things. The following entry in Hiera will add a `postrun_command` to puppet.conf.

```
r10k::include_postrun_command: true
```

The concept here is that this is declared on the puppet master(s) that have
Expand Down Expand Up @@ -60,9 +94,102 @@ r10k::manage_configfile_symlink: true
r10k::configfile_symlink: /etc/r10k.yaml
```

### Mcollective Support
## Alternative install



Installing using a proxy server

```puppet
# Create a global gemrc for Puppet Enterprise to add the local gem source
# See http://projects.puppetlabs.com/issues/18053#note-12 for more information.
![alt tag](https://gist.github.com/acidprime/7013041/raw/6748f6173b406c03067884199174ce1df313ad58/post_recieve_overview.png)
file { '/opt/puppet/etc':
ensure => 'directory',
owner => 'root',
group => '0',
mode => '0755',
}
file { 'gemrc':
ensure => 'file',
path => '/opt/puppet/etc/gemrc',
owner => 'root',
group => '0',
mode => '0644',
content => "---\ngem: --http-proxy=http://your.proxy.server:8080\n",
}
class { 'r10k':
remote => 'git@github.com:someuser/puppet.git',
provider => 'pe_gem',
require => File['gemrc'],
}
# The following will allow r10k to use Puppetfile via the proxy
file { '/root/.gitconfig':
ensure => 'file',
owner => 'root',
group => '0',
mode => '0600',
}
# https://forge.puppetlabs.com/puppetlabs/inifile
Ini_setting {
ensure => present,
path => '/root/.gitconfig',
value => 'http://proxy.your.company.com:8080',
}
file { '/root/.gitconfig':
ensure => 'file',
owner => 'root',
group => '0',
mode => '0600',
}
ini_setting { 'git http proxy setting':
section => 'http',
setting => 'proxy',
}
ini_setting { 'git https proxy setting':
section => 'https',
setting => 'proxy',
}
```

Using a internal gem server
```puppet
# Create a global gemrc for Puppet Enterprise to add the local gem source
# See http://projects.puppetlabs.com/issues/18053#note-12 for more information.
file { '/opt/puppet/etc':
ensure => 'directory',
owner => 'root',
group => '0',
mode => '0755',
}
file { 'gemrc':
ensure => 'file',
path => '/opt/puppet/etc/gemrc',
owner => 'root',
group => '0',
mode => '0644',
content => "---\nupdate_sources: true\n:sources:\n- http://your.internal.gem.server.com/rubygems/\n",
}
class { 'r10k':
remote => 'git@github.com:someuser/puppet.git',
provider => 'pe_gem',
require => File['gemrc'],
}
```

### Mcollective Support
![alt tag](http://imageshack.com/a/img674/3070/NWvnSn.png)

An mcollective agent is included in this module which can be used to do
on demand synchronization. This mcollective application and agent can be
Expand Down Expand Up @@ -120,8 +247,74 @@ _Note: PE2 only requires the .mcollective file as the default auth was psk_

# Webhook Support

![alt tag](http://imageshack.com/a/img661/6302/qQwIrw.gif)
For version control systems that use web driven post-receive processes you can use the example webhook included in this module.
This webhook currently only runs on Puppet Enterprise and uses mcollective to automatically synchronize your environment across multiple masters.
The webhook must be configured on the respective "control" repository a master that has mco installed and can contact the other masters in your fleet.

Currently this is a feature Puppet Enterprise only.

### Webhook Prefix Example

The following is an example of declaring the webhook when r10k prefixing is enabled

```puppet
file {'/usr/local/bin/prefix_command.rb':
ensure => file,
mode => '0755',
owner => 'root',
group => '0',
source => 'puppet:///modules/r10k/prefix_command.rb',
}
class {'r10k::webhook::config':
prefix => true,
prefix_command => '/usr/local/bin/prefix_command.rb',
notify => Service['webhook'],
require => File['/usr/local/bin/prefix_command.rb'],
}
class {'r10k::webhook':
require => Class['r10k::webhook::config'],
}
# https://github.com/abrader/abrader-gms
git_webhook { 'web_post_receive_webhook' :
ensure => present,
webhook_url => 'https://puppet:puppet@master.of.masters:8088/payload',
token => hiera('gitlab_api_token'),
project_name => 'puppet/controle',
server_url => 'http://github.com',
provider => 'gitlab',
}
```

### Webhook Non authenticated example
```puppet
class {'r10k::webhook::config':
enable_ssl => false,
protected => false,
notify => Service['webhook'],
}
class {'r10k::webhook':
require => Class['r10k::webhook::config'],
}
# https://github.com/abrader/abrader-gms
git_webhook { 'web_post_receive_webhook' :
ensure => present,
webhook_url => 'http://master.of.masters:8088/payload',
token => hiera('github_api_token'),
project_name => 'puppet/controle',
server_url => 'http://github.com',
provider => 'github',
}
```




Please log tickets and issues at our [Projects site](https://github.com/acidprime/r10k/issues)
15 changes: 10 additions & 5 deletions files/prefix_command.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/opt/puppet/bin/ruby
require 'json'
require 'yaml'

if STDIN.tty?
puts 'invalid'
puts 'This command is meant be launched by webhook'
else
data = JSON.parse(STDIN.read)
description = data['repository']['description']
parsed = description.scan(/^.*\[prefix:['"]?(\w+)['"]?\].*$/)
prefix = parsed[0]
prefixes = YAML.load_file('/etc/r10k.yaml')

json_data = JSON.parse(STDIN.read)
url = json_data['repository']['url']

prefix = prefixes[:sources].each.map do |key,value|
key if url == value['remote']
end.compact

puts prefix
end