-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
install and use the certbot nginx plugin
- Loading branch information
1 parent
42f4ba8
commit 7761142
Showing
9 changed files
with
148 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
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--- | ||
letsencrypt::plugin::dns_rfc2136::package_name: 'python2-certbot-dns-rfc2136' | ||
letsencrypt::plugin::dns_route53::package_name: 'python2-certbot-dns-route53' | ||
letsencrypt::plugin::nginx::package_name: 'python2-certbot-nginx' |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--- | ||
letsencrypt::plugin::dns_rfc2136::package_name: 'python2-certbot-dns-rfc2136' | ||
letsencrypt::plugin::dns_route53::package_name: 'python2-certbot-dns-route53' | ||
letsencrypt::plugin::nginx::package_name: 'python2-certbot-nginx' |
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
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 @@ | ||
# @summary install and configure the Let's Encrypt nginx plugin | ||
# | ||
# @param manage_package Manage the plugin package. | ||
# @param package_name The name of the package to install when $manage_package is true. | ||
class letsencrypt::plugin::nginx ( | ||
Boolean $manage_package = true, | ||
String $package_name = 'python3-certbot-nginx', | ||
) { | ||
if $manage_package { | ||
package { $package_name: | ||
ensure => installed, | ||
} | ||
} | ||
} |
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,23 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'letsencrypt::plugin::nginx' do | ||
context 'with default values' do | ||
pp = <<-PUPPET | ||
class { 'letsencrypt' : | ||
email => '[email protected]', | ||
config => { | ||
'server' => 'https://acme-staging.api.letsencrypt.org/directory', | ||
}, | ||
} | ||
class { 'letsencrypt::plugin::nginx': | ||
} | ||
PUPPET | ||
|
||
it 'installs letsencrypt and nginx plugin without error' do | ||
apply_manifest(pp, catch_failures: true) | ||
end | ||
it 'installs letsencrypt and nginx idempotently' do | ||
apply_manifest(pp, catch_changes: true) | ||
end | ||
end | ||
end |
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,38 @@ | ||
require 'spec_helper' | ||
|
||
describe 'letsencrypt::plugin::nginx' do | ||
on_supported_os.each do |os, facts| | ||
context "on #{os} based operating systems" do | ||
let(:facts) { facts } | ||
let(:params) { {} } | ||
let(:pre_condition) do | ||
<<-PUPPET | ||
class { 'letsencrypt': | ||
email => '[email protected]', | ||
} | ||
PUPPET | ||
end | ||
|
||
context 'with default parameters' do | ||
it { is_expected.to compile.with_all_deps } | ||
|
||
package_name = | ||
if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' | ||
'python2-certbot-nginx' | ||
else | ||
'python3-certbot-nginx' | ||
end | ||
it 'installs the certbot nginx plugin' do | ||
is_expected.to contain_class('letsencrypt::plugin::nginx') | ||
is_expected.to contain_package(package_name).with_ensure('installed') | ||
end | ||
|
||
describe 'with manage_package => false' do | ||
let(:params) { super().merge(manage_package: false, package_name: 'nginx-package') } | ||
|
||
it { is_expected.not_to contain_package('nginx-package') } | ||
end | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
|
@@ -153,6 +153,26 @@ class { 'letsencrypt::plugin::dns_route53': | |
it { is_expected.to contain_exec('letsencrypt certonly foo.example.com').with_command "letsencrypt --text --agree-tos --non-interactive certonly --rsa-key-size 4096 -a dns-route53 --cert-name 'foo.example.com' -d 'foo.example.com' --dns-route53-propagation-seconds 10" } | ||
end | ||
|
||
context 'with nginx plugin' do | ||
let(:title) { 'foo.example.com' } | ||
let(:params) { { plugin: 'nginx', letsencrypt_command: 'letsencrypt' } } | ||
let(:pre_condition) do | ||
<<-PUPPET | ||
class { 'letsencrypt': | ||
email => '[email protected]', | ||
config_dir => '/etc/letsencrypt', | ||
} | ||
class { 'letsencrypt::plugin::nginx': | ||
package_name => 'irrelevant', | ||
} | ||
PUPPET | ||
end | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to contain_class('letsencrypt::plugin::nginx') } | ||
it { is_expected.to contain_exec('letsencrypt certonly foo.example.com').with_command "letsencrypt --text --agree-tos --non-interactive certonly --rsa-key-size 4096 -a nginx --cert-name 'foo.example.com' -d 'foo.example.com'" } | ||
end | ||
|
||
context 'with custom plugin' do | ||
let(:title) { 'foo.example.com' } | ||
let(:params) { { plugin: 'apache' } } | ||
|