Showing with 86 additions and 43 deletions.
  1. +15 −0 CHANGELOG.md
  2. +1 −0 Gemfile
  3. +9 −0 Gemfile.lock
  4. +12 −0 README.md
  5. +1 −41 Rakefile
  6. +19 −1 manifests/certonly.pp
  7. +22 −0 manifests/init.pp
  8. +1 −1 metadata.json
  9. +6 −0 spec/defines/letsencrypt_certonly_spec.rb
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Change log
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased][unreleased]

## [0.2.0] - 2015-12-03
### Added
- Added `additional_args` parameter to `letsencrypt::certonly`

## [0.1.0] - 2015-12-03
Initial Release

[unreleased]: https://github.com/danzilio/puppet-letsencrypt/compare/v0.2.0...HEAD
[0.2.0]: https://github.com/danzilio/puppet-letsencrypt/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/danzilio/puppet-letsencrypt/tree/v0.1.0
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ group :test do
gem 'puppet-syntax'
gem 'puppetlabs_spec_helper'
gem 'metadata-json-lint'
gem 'puppet-strings', git: 'git://github.com/puppetlabs/puppetlabs-strings.git'
end

group :development do
Expand Down
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
GIT
remote: git://github.com/puppetlabs/puppetlabs-strings.git
revision: eaddebbdc97e916cf12331c1ab98bb70fff86d7c
specs:
puppet-strings (0.3.1)
puppet (>= 3.7.0)
yard (~> 0.8)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -372,6 +380,7 @@ DEPENDENCIES
puppet (~> 4.3.0)
puppet-blacksmith
puppet-lint
puppet-strings!
puppet-syntax
puppetlabs_spec_helper
rake
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ letsencrypt::certonly { 'foo':
}
```

If you need to pass a command line flag to the `letsencrypt-auto` command that
is not supported natively by this module, you can use the `additional_args`
parameter to pass those arguments:

```puppet
letsencrypt::certonly { 'foo':
domains => ['foo.example.com', 'bar.example.com'],
plugin => 'apache',
additional_args => ['--foo bar', '--baz quuz']
}
```

## Development

1. Fork it
Expand Down
42 changes: 1 addition & 41 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
require 'puppet-strings/rake_tasks'

# These two gems aren't always present, for instance
# on Travis with --without development
Expand Down Expand Up @@ -45,44 +46,3 @@ task :test => [
:spec,
]

namespace :strings do
doc_dir = File.dirname(__FILE__) + '/doc'
git_uri = `git config --get remote.origin.url`.strip
vendor_mods = File.dirname(__FILE__) + '/.modules'

desc "Checkout the gh-pages branch for doc generation."
task :checkout do
unless Dir.exist?(doc_dir)
Dir.mkdir(doc_dir)
Dir.chdir(doc_dir) do
system 'git init'
system "git remote add origin #{git_uri}"
system 'git pull'
system 'git checkout gh-pages'
end
end
end

desc "Generate documentation with the puppet strings command."
task :generate do
Dir.mkdir(vendor_mods) unless Dir.exist?(vendor_mods)
system "bundle exec puppet module install puppetlabs/strings --modulepath #{vendor_mods}"
system "bundle exec puppet strings --modulepath #{vendor_mods}"
end

desc "Push new docs to GitHub."
task :push do
Dir.chdir(doc_dir) do
system 'git add .'
system "git commit -m 'Updating docs for latest build.'"
system 'git push origin gh-pages'
end
end

desc "Run checkout, generate, and push tasks."
task :update => [
:checkout,
:generate,
:push,
]
end
20 changes: 19 additions & 1 deletion manifests/certonly.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
# == Defined Type: letsencrypt::certonly
#
# This type can be used to request a certificate using the `certonly`
# installer.
#
# === Parameters:
#
# [*domains*]
# Namevar. An array of domains to include in the CSR.
# [*plugin*]
# The authenticator plugin to use when requesting the certificate.
# [*letsencrypt_path*]
# The path to the letsencrypt installation.
# [*additional_args*]
# An array of additional command line arguments to pass to the
# `letsencrypt-auto` command.
#
define letsencrypt::certonly (
Array[String] $domains = [$title],
Enum['apache', 'standalone', 'webroot'] $plugin = 'standalone',
String $letsencrypt_path = $letsencrypt::path,
Optional[Array[String]] $additional_args = undef,
) {

$command = inline_template('<%= @letsencrypt_path %>/letsencrypt-auto certonly --<%= @plugin %> -d <%= @domains.join(" -d ")%>')
$command = inline_template('<%= @letsencrypt_path %>/letsencrypt-auto certonly --<%= @plugin %> -d <%= @domains.join(" -d ")%><% if @additional_args %> <%= @additional_args.join(" ") %><%end%>')
$live_path = inline_template('/etc/letsencrypt/live/<%= @domains.first %>/cert.pem')

exec { "letsencrypt certonly ${title}":
Expand Down
22 changes: 22 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# == Class: letsencrypt
#
# This class installs and configures the Let's Encrypt client.
#
# === Parameters:
#
# [*path*]
# The path to the letsencrypt installation.
# [*repo*]
# A Git URL to install the Let's encrypt client from.
# [*version*]
# The Git ref (tag, sha, branch) to check out when installing the client.
# [*config_file*]
# The path to the configuration file for the letsencrypt cli.
# [*config*]
# A hash representation of the letsencrypt configuration file.
# [*manage_config*]
# A feature flag to toggle the management of the letsencrypt configuration
# file.
# [*manage_dependencies*]
# A feature flag to toggle the management of the letsencrypt dependencies.
#
class letsencrypt (
String $path = $letsencrypt::params::path,
String $repo = $letsencrypt::params::repo,
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "danzilio-letsencrypt",
"version": "0.1.0",
"version": "0.2.0",
"author": "David Danzilio",
"summary": "A module to install the Letsencrypt client and request certs.",
"license": "Apache-2.0",
Expand Down
6 changes: 6 additions & 0 deletions spec/defines/letsencrypt_certonly_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@
let(:params) {{ plugin: 'bad' }}
it { is_expected.to raise_error Puppet::Error }
end

context 'when specifying additional arguments' do
let(:title) { 'foo.example.com' }
let(:params) {{ additional_args: ['--foo bar', '--baz quux'] }}
it { is_expected.to contain_exec('letsencrypt certonly foo.example.com').with_command '/opt/letsencrypt/letsencrypt-auto certonly --standalone -d foo.example.com --foo bar --baz quux' }
end
end