Showing with 248 additions and 36 deletions.
  1. +3 −0 CHANGELOG
  2. +0 −19 Modulefile
  3. +54 −4 README.md
  4. +32 −0 files/agent/r10k.ddl
  5. +17 −2 files/agent/r10k.rb
  6. +8 −4 manifests/install.pp
  7. +8 −4 manifests/install/pe_gem.pp
  8. +1 −1 manifests/params.pp
  9. +52 −2 metadata.json
  10. +66 −0 spec/classes/install_spec.rb
  11. +7 −0 templates/webhook.init.erb
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.7.0 - Zack Smith
* Updates for Puppet Enterprise 3.8 and its embeded r10k
* Update default r10k version with that which will ship in PE 3.8
2.6.5 - spidersddd
* Fix #147 for Ubuntu 14.0.4
2.6.4 - Zack Smith & Corey Osman
Expand Down
19 changes: 0 additions & 19 deletions Modulefile

This file was deleted.

58 changes: 54 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# r10k Configuration Module
[![Puppet Forge](http://img.shields.io/puppetforge/v/zack/r10k.svg)](https://forge.puppetlabs.com/zack/r10k)
[![Github Tag](https://img.shields.io/github/tag/acidprime/r10k.svg)](https://github.com/acidprime/r10k)
[![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
Expand All @@ -18,19 +19,22 @@ class { 'r10k':
provider => 'pe_gem',
}
```
Note: On Puppet Enterprise 3.8 and higher the package is not declared as 3.8
ships with an embdedded r10k gem installed via the PE packages

### Prefixes
Installing using prefixes for multiple control repos.
```puppet
class { 'r10k':
sources => {
'webteam' => {
'remote' => 'ssh://git@github.com/webteam/somerepo.git',
'basedir' => "${::settings::confdir}/environments"
'basedir' => "${::settings::confdir}/environments",
'prefix' => true,
},
'secteam' => {
'remote' => 'ssh://git@github.com/secteam/someotherrepo.git',
'basedir' => '/some/other/basedir'
'basedir' => '/some/other/basedir',
'prefix' => true,
},
},
Expand All @@ -42,15 +46,16 @@ class { 'r10k':

| Module Version | r10k Version |
| -------------- | ------------ |
| v2.6.x | 1.4.1 |
| Next Release | [![Latest Version](https://img.shields.io/gem/v/r10k.svg?style=flat-square)](https://rubygems.org/gems/r10k) |
| v2.7.x | 1.5.0 |
| v2.6.5 | 1.4.1 |
| v2.5.4 | 1.4.0 |
| v2.4.4 | 1.3.5 |
| v2.3.1 | 1.3.4 |
| v2.3.0 | 1.3.2 |
| v2.2.8 | 1.3.1 |
| v2.2.x | 1.1.0 |


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.

Expand Down Expand Up @@ -232,6 +237,19 @@ You can sync an individual module using:
mco r10k deploy_module <module>
```

If you are required to run `r10k` as a specific user, you can do so by passing
the `user` parameter:

```shell
mco r10k synchronize user=r10k
```

Too obtain the output of running the shell command, run the agent like this:

```shell
mco rpc r10k synchronize -v
```

An example post-receive hook is included in the files directory.
This hook can automatically cause code to synchronize on your
servers at time of push in git. More modern git systems use webhooks, for those see below.
Expand Down Expand Up @@ -435,3 +453,35 @@ git_webhook { 'web_post_receive_webhook' :
##Support

Please log tickets and issues at our [Projects site](https://github.com/acidprime/r10k/issues)

##Development

###Contributing

Modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve.

We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.

Read the complete module [contribution guide](https://docs.puppetlabs.com/forge/contributing.html)

###Running tests

This project contains tests for both [rspec-puppet](http://rspec-puppet.com/) and [beaker-rspec](https://github.com/puppetlabs/beaker-rspec) to verify functionality. For in-depth information please see their respective documentation.

Quickstart:

####Ruby > 1.8.7

```
gem install bundler
bundle install
bundle exec rake spec
```

####Ruby = 1.8.7

```
gem install bundler
bundle install --without system_tests
bundle exec rake spec
```
32 changes: 32 additions & 0 deletions files/agent/r10k.ddl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ metadata :name => "r10k",
:optional => false,
:maxlength => 256

input :user,
:prompt => "User",
:description => "User to run as",
:type => :string,
:validation => '\w+',
:optional => true,
:maxlength => 32

output :path,
:description => "Operating on #{act}",
:display_as => "Path"
Expand All @@ -36,6 +44,14 @@ end
'synchronize',
'sync'].each do |act|
action act, :description => "#{act.capitalize} " do
input :user,
:prompt => "User",
:description => "User to run as",
:type => :string,
:validation => '\w+',
:optional => true,
:maxlength => 32

output :output,
:description => "Output from git",
:display_as => "Output"
Expand All @@ -56,6 +72,14 @@ action 'deploy', :description => "Deploy a specific environment, and its Puppetf
:optional => true,
:maxlength => 256

input :user,
:prompt => "User",
:description => "User to run as",
:type => :string,
:validation => '\w+',
:optional => true,
:maxlength => 32

output :environment,
:description => "Deploy a particular environment",
:display_as => "Specific environment"
Expand All @@ -80,6 +104,14 @@ action 'deploy_module', :description => "Deploy a specific module" do
:optional => true,
:maxlength => 256

input :user,
:prompt => "User",
:description => "User to run as",
:type => :string,
:validation => '\w+',
:optional => true,
:maxlength => 32

output :module_name,
:description => "Deploy a particular module",
:display_as => "Specific module"
Expand Down
19 changes: 17 additions & 2 deletions files/agent/r10k.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ class R10k<RPC::Agent
end
private

def cmd_as_user(cmd, cwd = nil)
if /^\w+$/.match(request[:user])
cmd_as_user = ['su', '-', request[:user], '-c', '\'']
if cwd
cmd_as_user += ['cd', cwd, '&&']
end
cmd_as_user += cmd + ["'"]

# doesn't seem to execute when passed as an array
cmd_as_user.join(' ')
else
cmd
end
end

def run_cmd(action,arg=nil)
output = ''
git = ['/usr/bin/env', 'git']
Expand All @@ -48,7 +63,7 @@ def run_cmd(action,arg=nil)
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 => arg, :environment => environment )
reply[:status] = run(cmd_as_user(cmd, arg), :stderr => :error, :stdout => :output, :chomp => true, :cwd => arg, :environment => environment )
when 'cache','synchronize','sync', 'deploy', 'deploy_module'
cmd = r10k
cmd << 'cache' if action == 'cache'
Expand All @@ -58,7 +73,7 @@ def run_cmd(action,arg=nil)
elsif action == 'deploy_module'
cmd << 'deploy' << 'module' << arg
end
reply[:status] = run(cmd, :stderr => :error, :stdout => :output, :chomp => true, :environment => environment)
reply[:status] = run(cmd_as_user(cmd), :stderr => :error, :stdout => :output, :chomp => true, :environment => environment)
end
end
end
Expand Down
12 changes: 8 additions & 4 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@
elsif $provider == 'pe_gem' {
include r10k::install::pe_gem
}
package { $real_package_name:
ensure => $version,
provider => $provider,
install_options => $install_options,
# Puppet Enterprise 3.8 and ships an embedded r10k so thats all thats supported
# This conditional should not effect FOSS customers based on the fact
unless versioncmp($::pe_version, '3.8.0') >= 0 {
package { $real_package_name:
ensure => $version,
provider => $provider,
install_options => $install_options,
}
}
}
default: { fail("${provider} is not supported. Valid values are: 'gem', 'pe_gem', 'bundle', 'portage', 'yum', 'zypper'") }
Expand Down
12 changes: 8 additions & 4 deletions manifests/install/pe_gem.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@

require git

file { '/usr/bin/r10k':
ensure => link,
target => '/opt/puppet/bin/r10k',
require => Package['r10k'],
# Puppet Enterprise 3.8 ships code to manage this symlink on install
# This conditional should not effect FOSS customers based on the fact
unless versioncmp($::pe_version, '3.8.0') >= 0 {
file { '/usr/bin/r10k':
ensure => link,
target => '/opt/puppet/bin/r10k',
require => Package['r10k'],
}
}
}
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class r10k::params
{
$package_name = ''
$version = '1.4.1'
$version = '1.5.0'
$manage_modulepath = false
$manage_ruby_dependency = 'declare'
$install_options = []
Expand Down
54 changes: 52 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,51 @@
"name": "zack-r10k",
"operatingsystem_support": [],
"project_page": "https://github.com/acidprime/r10k",
"requirements": [],
"issues_url": "https://github.com/acidprime/r10k/issues",
"source": "https://github.com/acidprime/r10k",
"summary": "Module for setting up dynamic environments using r10k",
"tags": ["git", "pe", "environment", "mcollective"],
"version": "2.6.5",
"version": "2.7.0",
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04",
"14.04"
]
}
],
"dependencies": [
{
"name": "puppetlabs/stdlib",
Expand Down Expand Up @@ -46,5 +86,15 @@
"name": "gentoo/portage",
"version_requirement": ">= 2.0.0"
}
],
"requirements": [
{
"name": "pe",
"version_requirement": "3.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
]
}
Loading