-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e3e706a
Showing
6 changed files
with
248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2013 Charlie Sharpsteen <[email protected]> | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name 'sharpie-r10k' | ||
version '0.0.1' | ||
author 'Charlie Sharpsteen <[email protected]>' | ||
license 'Apache License, Version 2.0' | ||
|
||
summary 'Install and configure r10k' | ||
description 'A module to install and configure r10k, the killer robot powered Puppet deployment tool.' | ||
|
||
project_page 'https://github.com/Sharpie/puppet-r10k' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
sharpie-r10k | ||
============ | ||
|
||
A [Puppet][puppet] module to install and configure [r10k][r10k], the killer robot powered Puppet deployment tool. | ||
|
||
There are two other r10k modules available on the [module forge][puppet-forge] that pre-date this one: | ||
|
||
- [ploperations/r10k][zack-r10k] | ||
|
||
- [zack/r10k][zack-r10k] | ||
|
||
Both have interesting features such as cron setup or MCollective integration. | ||
Compared to `zack/r10k`, this module aims for a minimal installation footprint with respect to adding system packages. | ||
Compared to `ploperations/r10k`, this module emphasizes configuration through [Hiera data bindings][hiera-bindings] rather than statically served files. | ||
|
||
### Caveats | ||
|
||
This package has no stable releases yet. | ||
Specifically, _there are no tests and all interfaces are subject to change_. | ||
**Use in production at your own risk.** | ||
|
||
This package is hard-wired to manage the system-wide r10k config file `/etc/r10k.yaml` which is owned by `root`. | ||
This restriction may be lifted in future versions. | ||
|
||
[puppet]: https://github.com/puppetlabs/puppet | ||
[r10k]: https://github.com/adrienthebo/r10k | ||
[puppet-forge]: http://forge.puppetlabs.com/ | ||
[ploperations-r10k]: http://forge.puppetlabs.com/ploperations/r10k | ||
[zack-r10k]: http://forge.puppetlabs.com/zack/r10k | ||
[hiera-bindings]: http://docs.puppetlabs.com/hiera/1/puppet.html#automatic-parameter-lookup | ||
|
||
|
||
Dependencies | ||
------------ | ||
|
||
This module should only be used to install and manage r10k versions 1.0.0 or newer. | ||
|
||
This module was designed with Puppet 3.x in mind and makes extensive use of Hiera data bindings. | ||
The module may function on Puppet 2.7.x, but there are currently no tests or guarantees surrounding such functionality. | ||
|
||
For r10k to be fully functional after installation and configuration, a git package should also be included on the managed node. | ||
|
||
|
||
Examples | ||
-------- | ||
|
||
Currently this module provides two classes: `r10k` and `r10k::config` | ||
|
||
The `r10k` class is pretty simple to use and only takes one parameter, `ensure`: | ||
|
||
```puppet | ||
class {'r10k': ensure => '1.0.0'} | ||
``` | ||
|
||
Installation is performed by a `Package` type using the `gem` provider. | ||
Thus, the `ensure` parameter can accept any value that is valid for the `Package` type. | ||
|
||
|
||
The `r10k::config` class manages the contents of `/etc/r10k.yaml` and accepts three parameters: | ||
|
||
* `cachedir`: | ||
Path to a directory to be used by r10k for caching data. | ||
Default: `/var/cache/r10k` | ||
|
||
* `sources`: | ||
Hash containing data sources to be used by r10k to create dynamic Puppet environments. | ||
Default: `{}` | ||
|
||
* `purgedirs`: | ||
An Array of directory paths to purge of any subdirectories that do not correspond to a dynamic environment managed by r10k. | ||
Default: `[]` | ||
|
||
Detailed information on these parameters can be found in the [r10k documentation][r10k-docs]. | ||
|
||
The `r10k::config` class is designed to be used in conjunction with Hiera data: | ||
|
||
```yaml | ||
--- | ||
# In a Hiera datasource | ||
r10k::ensure: '1.0.0' | ||
r10k::config::sources: | ||
somename: | ||
remote: 'ssh://[email protected]/someuser/somerepo.git' | ||
basedir: '%{::settings::confdir}/environments' | ||
someothername: | ||
remote: 'ssh://[email protected]/someuser/someotherrepo.git' | ||
basedir: '/some/other/basedir' | ||
|
||
r10k::config::purgedirs: | ||
- '%{::settings::confdir}/environments' | ||
- '/some/other/basedir/ | ||
``` | ||
```puppet | ||
# In a Puppet manifest | ||
class { 'r10k': } # Ensured to be version 1.0.0 | ||
class { 'r10k::config': } # Magic! | ||
``` | ||
The `r10k::config` class can also be used without Hiera data: | ||
|
||
```puppet | ||
class { 'r10k::config': | ||
sources => { | ||
'somename' => { | ||
'remote' => 'ssh://[email protected]/someuser/somerepo.git', | ||
'basedir' => "${::settings::confdir}/environments" | ||
}, | ||
'someothername' => { | ||
'remote' => 'ssh://[email protected]/someuser/someotherrepo.git', | ||
'basedir' => '/some/other/basedir' | ||
}, | ||
}, | ||
purgedirs => [ | ||
"${::settings::confdir}/environments", | ||
'/some/other/basedir', | ||
], | ||
} | ||
``` | ||
|
||
[r10k-docs]: https://github.com/adrienthebo/r10k/blob/master/README.markdown | ||
|
||
|
||
Support | ||
------- | ||
|
||
Please log tickets and issues at: https://github.com/Sharpie/puppet-r10k/issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# == Class: r10k::config | ||
# | ||
# Set up the root r10k config file (/etc/r10k.yaml). | ||
# | ||
# === Parameters | ||
# | ||
# * [*cachedir*] | ||
# Path to a directory to be used by r10k for caching data. | ||
# Default: /var/cache/r10k | ||
# * [*sources*] | ||
# Hash containing data sources to be used by r10k to create dynamic Puppet | ||
# environments. Default: {} | ||
# * [*purgedirs*] | ||
# An Array of directory paths to purge of any subdirectories that do not | ||
# correspond to a dynamic environment managed by r10k. Default: [] | ||
# | ||
# === Examples | ||
# | ||
# class { 'r10k::config': | ||
# sources => { | ||
# 'somename' => { | ||
# 'remote' => 'ssh://[email protected]/someuser/somerepo.git', | ||
# 'basedir' => "${::settings::confdir}/environments" | ||
# }, | ||
# 'someothername' => { | ||
# 'remote' => 'ssh://[email protected]/someuser/someotherrepo.git', | ||
# 'basedir' => '/some/other/basedir' | ||
# }, | ||
# }, | ||
# purgedirs => [ | ||
# "${::settings::confdir}/environments", | ||
# '/some/other/basedir', | ||
# ], | ||
# } | ||
# | ||
# == Documentation | ||
# | ||
# * https://github.com/adrienthebo/r10k#dynamic-environment-configuration | ||
# | ||
# === Authors | ||
# | ||
# Charlie Sharpsteen <[email protected]> | ||
# | ||
class r10k::config ( | ||
$cachedir = '/var/cache/r10k', | ||
$sources = {}, | ||
$purgedirs = [], | ||
){ | ||
|
||
file { '/etc/r10k.yaml': | ||
ensure => 'file', | ||
owner => 'root', | ||
group => 'root', | ||
content => template('r10k/r10k.yaml.erb'), | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# == Class: r10k | ||
# | ||
# Install r10k. | ||
# | ||
# === Parameters | ||
# | ||
# [*ensure*] | ||
# Version of r10k to install. Accepts any ensure state that is valid for the | ||
# Package type. Default: present | ||
# | ||
# === Examples | ||
# | ||
# class { r10k: ensure => '1.0.0' } | ||
# | ||
# === Authors | ||
# | ||
# Charlie Sharpsteen <[email protected]> | ||
# | ||
class r10k ( | ||
$ensure = 'present', | ||
){ | ||
|
||
package { 'r10k': | ||
ensure => $ensure, | ||
provider => 'gem', | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
:cachedir: <%= @cachedir %> | ||
|
||
<% unless @sources.empty? -%> | ||
:sources: | ||
<%# The splitting/joining monkeybuisness trims the YAML document header: `---` -%> | ||
<%= @sources.to_yaml.split("\n")[1..-1].join("\n") %> | ||
<% end -%> | ||
|
||
<%# The Array boxing/flattening ensures we don't get bitten by bug #15813 -%> | ||
<% unless [@purgedirs].flatten.empty? -%> | ||
:purgedirs: | ||
<%= [@purgedirs].flatten.to_yaml.split("\n")[1..-1].join("\n") %> | ||
<% end -%> |