11 changes: 11 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fixtures:
repositories:
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
ruby: "git://github.com/puppetlabs/puppetlabs-ruby.git"
gcc: "git://github.com/puppetlabs/puppetlabs-gcc.git"
pe_gem: "git://github.com/puppetlabs/puppetlabs-pe_gem.git"
make: "git://github.com/mhuffnagle/puppet-make.git"
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"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
pkg
spec/fixtures/
spec/fixtures/manifests/site.pp
.DS_Store
35 changes: 35 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
branches:
only:
- master
language: ruby
bundler_args: --without development
script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
after_success:
- git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-releng
- .forge-releng/publish
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
env:
matrix:
- PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
- PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0"
- PUPPET_GEM_VERSION="~> 3.0"
global:
- PUBLISHER_LOGIN=acidprime
matrix:
exclude:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.2.0"
notifications:
email: false
26 changes: 26 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
source 'https://rubygems.org'

group :development, :test do
gem 'rake', :require => false
gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'serverspec', :require => false
gem 'rspec-system', :require => false
gem 'rspec-system-puppet', :require => false
gem 'rspec-system-serverspec', :require => false
gem 'puppet-lint', :require => false
end

if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion, :require => false
else
gem 'facter', :require => false
end

if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end

# vim:ft=ruby
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
r10k
# r10k Configuration Module

[![Build Status](https://travis-ci.org/acidprime/r10k.png?branch=master)](https://travis-ci.org/acidprime/r10k)

This is the r10k setup module. It has a base class to configure r10k to
synchronize dynamic environments. You can be simply used by declaring it:
Expand All @@ -21,6 +23,10 @@ The concept here is that this is declared on the puppet master(s) that have
been configured with r10k. This will cause r10k to synchronize before each
puppet run. Any errors synchronizing will be logged to the standard puppet run.

### Mcollective Support

![alt tag](https://gist.github.com/acidprime/7013041/raw/6748f6173b406c03067884199174ce1df313ad58/post_recieve_overview.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
installed on all masters using the following class
Expand All @@ -39,7 +45,34 @@ An example post-recieve hook is included in the files directory.
This hook can automatically cause code to synchronize on your
servers at time of push in git.


###Install mcollective support for post recieve hooks
Install the `mco` command from the puppet enterprise installation directory i.e.
```shell
cd ~/puppet-enterprise-3.0.1-el-6-x86_64/packages/el-6-x86_64
sudo rpm -i pe-mcollective-client-2.2.4-2.pe.el6.noarch.rpm
```
Copy the peadmin mcollective configuration and private keys from the certificate authority (puppet master)
~~~
/var/lib/peadmin/.mcollective
/var/lib/peadmin/.mcollective.d/mcollective-public.pem
/var/lib/peadmin/.mcollective.d/peadmin-cacert.pem
/var/lib/peadmin/.mcollective.d/peadmin-cert.pem
/var/lib/peadmin/.mcollective.d/peadmin-private.pem
/var/lib/peadmin/.mcollective.d/peadmin-public.pem
~~~
Ensure you update the paths in _~/.mcollective_ when copying to new users whose name is not peadmin.
Ideally mcollective will be used with more then just the peadmin user's certificate
in the future. That said, if your git user does not have a home diretory, you can rename .mcollective as /etc/client.cfg
and copy the certs to somewhere that is readable by the respective user.
~~~
/home/gitolite/.mcollective
/home/gitolite/.mcollective.d/mcollective-public.pem
/home/gitolite/.mcollective.d/peadmin-cacert.pem
/home/gitolite/.mcollective.d/peadmin-cert.pem
/home/gitolite/.mcollective.d/peadmin-private.pem
/home/gitolite/.mcollective.d/peadmin-public.pem
~~~
_Note: PE2 only requires the .mcollective file as the default auth was psk_
##Support

Please log tickets and issues at our [Projects site](https://github.com/acidprime/r10k/issues)
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'puppetlabs_spec_helper/rake_tasks'
3 changes: 2 additions & 1 deletion files/agent/r10k.ddl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata :name => "r10k",
:license => "MIT",
:version => "1.0",
:url => "http://puppetlabs.com",
:timeout => 120
:timeout => 900

['push',
'pull',
Expand Down Expand Up @@ -35,6 +35,7 @@ metadata :name => "r10k",
'environment',
'module',
'synchronize',
'deploy_all',
'sync'].each do |act|
action act, :description => "#{act.capitalize} " do
output :output,
Expand Down
15 changes: 5 additions & 10 deletions files/agent/r10k.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
module MCollective
module Agent
class R10k<RPC::Agent
metadata :name => 'r10k',
:description => 'Triggers git pulls on multi-master',
:author => 'Zack Smith',
:license => 'MIT',
:version => '1.0',
:url => 'http://puppetlabs.com',
:timeout => 120
['push',
'pull',
'status'].each do |act|
Expand All @@ -24,6 +17,7 @@ class R10k<RPC::Agent
'environment',
'module',
'synchronize',
'deploy_all',
'sync'].each do |act|
action act do
run_cmd act
Expand All @@ -33,21 +27,22 @@ class R10k<RPC::Agent

def run_cmd(action,path=nil)
output = ''
git = ['/usr/bin/git']
r10k = ['/usr/bin/r10k']
git = ['/usr/bin/env', 'git']
r10k = ['/usr/bin/env', 'r10k']
case action
when 'push','pull','status'
cmd = git
cmd << 'push' if action == 'push'
cmd << 'pull' if action == 'pull'
cmd << 'status' if action == 'status'
reply[:status] = run(cmd, :stderr => :error, :stdout => :output, :chomp => true, :cwd => path )
when 'cache','environment','module','synchronize','sync'
when 'cache','environment','module','synchronize','sync', 'deploy_all'
cmd = r10k
cmd << 'cache' if action == 'cache'
cmd << 'synchronize' if action == 'synchronize' or action == 'sync'
cmd << 'environment' if action == 'environment'
cmd << 'module' if action == 'module'
cmd << 'deploy' << 'environment' << '-p' if action == 'deploy_all'
reply[:status] = run(cmd, :stderr => :error, :stdout => :output, :chomp => true)
end
end
Expand Down
2 changes: 2 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
$r10k_basedir = $r10k::params::r10k_basedir,
) inherits r10k::params {

validate_bool($manage_modulepath)

if $sources == 'UNSET' {
$r10k_sources = {
Expand All @@ -71,6 +72,7 @@
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
path => $configfile,
content => template("${module_name}/${configfile}.erb"),
}
Expand Down
9 changes: 8 additions & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
$provider,
$keywords,
) {
require git

# There are currently bugs in r10k 1.x which make using 0.x desireable in
# certain circumstances. However, 0.x requires make and gcc. Conditionally
# include those classes if necessary due to 0.x r10k version usage. When
Expand All @@ -15,7 +17,9 @@
}

case $provider {
'bundle': { include r10k::install::bundle }
'bundle': {
include r10k::install::bundle
}
'portage': {
class { 'r10k::install::portage':
keywords => $keywords,
Expand All @@ -26,6 +30,9 @@
if $provider == 'gem' {
class { 'r10k::install::gem': version => $version; }
}
elsif $provider == 'pe_gem' {
include r10k::install::pe_gem
}
package { 'r10k':
ensure => $version,
provider => $provider,
Expand Down
20 changes: 12 additions & 8 deletions manifests/install/bundle.pp
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
class r10k::install::bundle {
class r10k::install::bundle(
$revision = 'master',
$source = 'https://github.com/adrienthebo/r10k.git',
){

require git

# The bundle install has prefix support as of writing this, I want bleeding edge.
class { 'git': }
package { "${module_name}-bundle":
ensure => installed,
name => 'bundle',
provider => gem,
provider => 'gem',
}
vcsrepo { "${module_name}-r10k-github":
ensure => latest,
provider => git,
provider => 'git',
path => '/tmp/r10k',
source => 'https://github.com/adrienthebo/r10k.git',
revision => 'master',
require => Class['git'],
source => $source,
revision => $revision,
}
exec { "${module_name}-install-via-bundle":
command => 'bundle && bundle install --path /opt/ --binstubs /usr/local/bin/',
cwd => '/tmp/r10k',
require => [ Package["${module_name}-bundle"] , Vcsrepo["${module_name}-r10k-github"] ],
unless => 'bundle list | grep -q " r10k "',
path => '/usr/bin:/usr/local/bin:/usr/sbin:/usr/local/sbin:/sbin:/bin',
path => $::path,
}
}
25 changes: 16 additions & 9 deletions manifests/install/gem.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,32 @@
$version,
) {

# rubygems_update => false
# https://projects.puppetlabs.com/issues/19741
class { '::ruby':
rubygems_update => false,
}
class { 'ruby::dev':
tag => 'amineeded',
# Ideally we would be singleton here but due to the bug we need the param.
# If we are newer then the failure state, we do the right thing with include
if versioncmp($::puppetversion,'3.2.2') < 0 {
# https://projects.puppetlabs.com/issues/19663
class { '::ruby':
rubygems_update => false,
}
} else {
include ruby
}

include ruby::dev

# Explicit dependency chaining to make sure the system is ready to compile
# native extentions for dependent rubygems by the time r10k installation
# begins
if versioncmp('1.0.0', $version) > 0 {
# I am not sure all of this is required as I assumed the
# ruby::dev class would have taken care of some of it
include make
include gcc

Class['::ruby'] ->
Class['ruby::dev'] ->
Package['gcc'] ->
Package['make'] ->
Class['gcc'] ->
Class['make'] ->
Package['r10k']
}

Expand Down
7 changes: 7 additions & 0 deletions manifests/install/pe_gem.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class r10k::install::pe_gem {
file { '/usr/bin/r10k':
ensure => link,
target => '/opt/puppet/bin/r10k',
require => Package['r10k'],
}
}
25 changes: 25 additions & 0 deletions manifests/mcollective/application.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Install the r10k mcollective application to a client
class r10k::mcollective::application(
$agent_name = $r10k::params::mc_agent_name,
$app_name = $r10k::params::mc_app_name,
$agent_ddl = $r10k::params::mc_agent_ddl_name,
$agent_path = $r10k::params::mc_agent_path,
$app_path = $r10k::params::mc_application_path,
$mc_service = $r10k::params::mc_service_name,
) inherits r10k::params {
File {
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
}
# Install the agent and its ddl file
file { "${app_path}/${app_name}" :
source => "puppet:///modules/${module_name}/application/${agent_name}",
}

file { "${agent_path}/${agent_ddl}" :
source => "puppet:///modules/${module_name}/agent/${agent_ddl}",
}

}
15 changes: 11 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
# prerun_command in puppet.conf
$prerun_command = 'r10k deploy environment -p'

# Installation package manager provider
$provider = 'gem'

# Gentoo specific values
$gentoo_keywords = ''

Expand All @@ -35,12 +32,22 @@
$modulepath = "${r10k_basedir}/\$environment/modules:${pe_module_path}"
$provider = 'pe_gem'
} else {
# Installation package manager provider
$provider = 'gem'

# Getting ready for FOSS support in this module
$puppetconf_path = '/etc/puppet'

# Mcollective configuration dynamic
$mc_service_name = 'mcollective'
$plugins_dir = '/usr/libexec/mcollective/mcollective'
case $::osfamily {
'debian': {
$plugins_dir = '/usr/share/mcollective/plugins/mcollective'
}
default: {
$plugins_dir = '/usr/libexec/mcollective/mcollective'
}
}
$modulepath = "${r10k_basedir}/\$environment/modules"
}

Expand Down
Loading