-
Notifications
You must be signed in to change notification settings - Fork 141
Add support for the Certbot Gandi plugin #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
de30daa
bf81b49
863985a
471c64e
37200dc
f062f57
2d89536
b51de96
d62ea76
09ba2f7
e010968
9323fb2
0287c8b
b2fe5ce
6c82c1a
ed0cfca
f8457b7
17c1b61
47824f6
ef0d4f5
a513b57
1e65a10
3996f08
cfdbfc5
136b8d3
8b98489
e7a77d7
efcf2e3
40205cd
7576d3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| --- | ||
| letsencrypt::plugin::dns_gandi::package_provider: apt | ||
cible marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| letsencrypt::plugin::dns_gandi::package_name: python3-certbot-dns-gandi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| --- | ||
| letsencrypt::plugin::dns_gandi::package_name: python3-certbot-dns-gandi | ||
| letsencrypt::plugin::dns_gandi::package_provider: apt |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,48 @@ | ||||||||||||||||||||||
| # @summary Installs and configures the dns-gandi plugin | ||||||||||||||||||||||
| # | ||||||||||||||||||||||
| # This class installs and configures the Let's Encrypt dns-gandi plugin. | ||||||||||||||||||||||
| # https://pypi.org/project/certbot-plugin-gandi/ | ||||||||||||||||||||||
| # | ||||||||||||||||||||||
| # @param api_key Gandi production api key secret. You can get it in you security tab of your account | ||||||||||||||||||||||
| # @param package_name The name of the package to install when $manage_package is true. | ||||||||||||||||||||||
| # @param config_file The path to the configuration file. | ||||||||||||||||||||||
| # @param manage_package Manage the plugin package. | ||||||||||||||||||||||
| # | ||||||||||||||||||||||
| class letsencrypt::plugin::dns_gandi ( | ||||||||||||||||||||||
| String[1] $api_key, | ||||||||||||||||||||||
| String[1] $package_provider = 'pip', | ||||||||||||||||||||||
| Optional[String[1]] $package_name = undef, | ||||||||||||||||||||||
| Stdlib::Absolutepath $config_file = "${letsencrypt::config_dir}/dns-gandi.ini", | ||||||||||||||||||||||
| Boolean $manage_package = true, | ||||||||||||||||||||||
| ) { | ||||||||||||||||||||||
| require letsencrypt | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if $manage_package { | ||||||||||||||||||||||
| if ! $package_name { | ||||||||||||||||||||||
| fail('No package name provided for certbot dns gandi plugin.') | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
cible marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||
| package { $package_name: | ||||||||||||||||||||||
| ensure => installed, | ||||||||||||||||||||||
cible marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||
| provider => $package_provider, | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if $api_key { | ||||||||||||||||||||||
| $ini_vars = { | ||||||||||||||||||||||
| 'certbot_plugin_gandi:dns_api_key' => $api_key, | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| fail('api_key not provided for certbot dns gandi plugin.') | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
||||||||||||||||||||||
| if $api_key { | |
| $ini_vars = { | |
| 'certbot_plugin_gandi:dns_api_key' => $api_key, | |
| } | |
| } else { | |
| fail('api_key not provided for certbot dns gandi plugin.') | |
| } | |
| $ini_vars = { | |
| 'certbot_plugin_gandi:dns_api_key' => $api_key, | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'spec_helper_acceptance' | ||
|
|
||
| describe 'letsencrypt::plugin::dns_gandi' do | ||
| it_behaves_like 'an idempotent resource' do | ||
| let(:manifest) do | ||
| <<-PUPPET | ||
| include letsencrypt | ||
| class { 'letsencrypt::plugin::dns_gandi': | ||
| api_key => 'dummy-gandi-api-token', | ||
| } | ||
| PUPPET | ||
| end | ||
| end | ||
|
|
||
| describe file('/etc/letsencrypt/dns-gandi.ini') do | ||
| it { is_expected.to be_file } | ||
| it { is_expected.to be_owned_by 'root' } | ||
| it { is_expected.to be_grouped_into 'root' } | ||
| it { is_expected.to be_mode 400 } | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,59 @@ | ||||||
| # frozen_string_literal: true | ||||||
|
|
||||||
| require 'spec_helper' | ||||||
|
|
||||||
| describe 'letsencrypt::plugin::dns_gandi' do | ||||||
| on_supported_os.each do |os, facts| | ||||||
| context "on #{os} based operating systems" do | ||||||
| let(:facts) { facts } | ||||||
| let(:params) { { 'api_key' => 'dummy-gandi-api-token' } } | ||||||
| let(:pre_condition) do | ||||||
| <<-PUPPET | ||||||
| class { 'letsencrypt': | ||||||
| email => '[email protected]', | ||||||
| } | ||||||
| PUPPET | ||||||
| end | ||||||
| let(:package_name) do | ||||||
| osname = facts[:os]['name'] | ||||||
| osrelease = facts[:os]['release']['major'] | ||||||
| osfull = "#{osname}-#{osrelease}" | ||||||
| case osfull | ||||||
| when 'Debian-10', 'AlmaLinux-8', 'RedHat-8', 'Ubuntu-18.04', 'Fedora-32', 'RedHat-7', 'CentOS-7', 'FreeBSD-12', 'FreeBSD-13' | ||||||
| 'certbot-plugin-gandi' | ||||||
| when 'Debian-11', 'Ubuntu-20.04' | ||||||
| 'python3-certbot-dns-gandi' | ||||||
| end | ||||||
| end | ||||||
|
|
||||||
| context 'with required parameters' do | ||||||
| it do | ||||||
| if package_name.nil? | ||||||
| is_expected.not_to compile | ||||||
cible marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| else | ||||||
| is_expected.to compile.with_all_deps | ||||||
| end | ||||||
| end | ||||||
|
|
||||||
| describe 'with manage_package => true' do | ||||||
| let(:params) { super().merge(manage_package: true) } | ||||||
|
|
||||||
| it do | ||||||
| if package_name.nil? | ||||||
| is_expected.not_to compile | ||||||
|
||||||
| is_expected.not_to compile | |
| is_expected.to compile.and_raise_error(/A Matcher For The Error/) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,6 +207,45 @@ class { 'letsencrypt::plugin::dns_cloudflare': | |
| 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-cloudflare --cert-name 'foo.example.com' -d 'foo.example.com' --dns-cloudflare --dns-cloudflare-credentials /etc/letsencrypt/dns-cloudflare.ini --dns-cloudflare-propagation-seconds 10" } | ||
| end | ||
|
|
||
| context 'with dns-gandi plugin' do | ||
| let(:title) { 'foo.example.com' } | ||
| let(:params) { { plugin: 'dns-gandi', letsencrypt_command: 'letsencrypt' } } | ||
| let(:pre_condition) do | ||
| <<-PUPPET | ||
| class { 'letsencrypt': | ||
| email => '[email protected]', | ||
| config_dir => '/etc/letsencrypt', | ||
| } | ||
| class { 'letsencrypt::plugin::dns_gandi': | ||
| package_name => 'irrelevant', | ||
| api_key => 'dummy-gandi-api-token', | ||
| } | ||
| PUPPET | ||
| end | ||
|
|
||
| it { is_expected.to compile.with_all_deps } | ||
| it { is_expected.to contain_class('letsencrypt::plugin::dns_gandi') } | ||
| 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-gandi --cert-name 'foo.example.com' -d 'foo.example.com' -a certbot-plugin-gandi:dns --certbot-plugin-gandi:dns-credentials /etc/letsencrypt/dns-gandi.ini" } | ||
| end | ||
|
|
||
| context 'with dns-gandi plugin without apy_key' do | ||
| let(:title) { 'foo.example.com' } | ||
| let(:params) { { plugin: 'dns-gandi', letsencrypt_command: 'letsencrypt' } } | ||
| let(:pre_condition) do | ||
| <<-PUPPET | ||
| class { 'letsencrypt': | ||
| email => '[email protected]', | ||
| config_dir => '/etc/letsencrypt', | ||
| } | ||
| class { 'letsencrypt::plugin::dns_gandi': | ||
| package_name => 'irrelevant', | ||
| } | ||
| PUPPET | ||
| end | ||
|
|
||
| it { is_expected.not_to compile.with_all_deps } | ||
|
||
| end | ||
|
|
||
| context 'with custom plugin' do | ||
| let(:title) { 'foo.example.com' } | ||
| let(:params) { { plugin: 'apache' } } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,5 @@ | |
| 'dns-google', | ||
| 'dns-cloudflare', | ||
| 'dns-rfc2136', | ||
| 'dns-gandi', | ||
| ] | ||
Uh oh!
There was an error while loading. Please reload this page.