-
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
Open
cible
wants to merge
30
commits into
voxpupuli:master
Choose a base branch
from
IMIO:feature/plugins/dns-gandi
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
de30daa
Adding feature support for the Certbot plugin Gandi
cible bf81b49
Use pip to install certbot-plugin-gandi by default but use package if…
cible 863985a
Merge #296
smortex 471c64e
Make the provideroptional
cible 37200dc
Merge branch 'master' into feature/plugins/dns-gandi
cible f062f57
Remove package_name if non existent
cible 2d89536
Merge branch 'master' into feature/plugins/dns-gandi
cible b51de96
Only test on debian-11 & ubuntu 20.04
cible d62ea76
Add function to check if platform is supported by gandi plugin
cible 09ba2f7
Apply suggestions from code review
cible e010968
Add support for ubuntu 22.04
cible 9323fb2
Remove now useless $package_provider
cible 0287c8b
Merge branch 'master' into feature/plugins/dns-gandi
cible b2fe5ce
Better tests for handling unsupported platforms
cible 6c82c1a
Syntax fix
cible ed0cfca
Fix variable name
cible f8457b7
Update spec/classes/plugin/dns_gandi_spec.rb
cible 17c1b61
Fix alignment
cible 47824f6
Remove now useless code
cible ef0d4f5
Fix regexps
cible a513b57
Fix tests
cible 1e65a10
Fix indent
cible 3996f08
Merge branch 'master' into feature/plugins/dns-gandi
cible cfdbfc5
Rebase
cible 136b8d3
Add Gandi personnal access token support
cible 8b98489
Fix REFERENCE.md
cible e7a77d7
Spelling correction
cible efcf2e3
Update reference
cible 40205cd
Merge branch 'voxpupuli:master' into feature/plugins/dns-gandi
cible 7576d3f
Add 24.04 support for dns gandi plugin
cible File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,2 @@ | ||
| --- | ||
| letsencrypt::plugin::dns_gandi::package_name: python3-certbot-dns-gandi |
This file contains hidden or 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,2 @@ | ||
| --- | ||
| letsencrypt::plugin::dns_gandi::package_name: python3-certbot-dns-gandi |
This file contains hidden or 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,2 @@ | ||
| --- | ||
| letsencrypt::plugin::dns_gandi::package_name: python3-certbot-dns-gandi |
This file contains hidden or 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,2 @@ | ||
| --- | ||
| letsencrypt::plugin::dns_gandi::package_name: python3-certbot-dns-gandi |
This file contains hidden or 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 hidden or 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,49 @@ | ||
| # @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 your security tab of your account | ||
| # @param personal_access_token Gandi personal access token(PAT). You can get it in your 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] $package_name, | ||
| Optional[String[1]] $api_key = undef, | ||
| Optional[String[1]] $personal_access_token = undef, | ||
| Stdlib::Absolutepath $config_file = "${letsencrypt::config_dir}/dns-gandi.ini", | ||
| Boolean $manage_package = true, | ||
| ) { | ||
| require letsencrypt | ||
|
|
||
| if $manage_package { | ||
| package { $package_name: | ||
| ensure => installed, | ||
| before => File[$config_file], | ||
| } | ||
| } | ||
|
|
||
| if $api_key != undef { | ||
| $ini_vars = { | ||
| 'dns_gandi_api_key' => $api_key, | ||
| } | ||
| } elsif $personal_access_token != undef { | ||
| $ini_vars = { | ||
| 'dns_gandi_token' => $personal_access_token, | ||
| } | ||
| } else { | ||
| fail("expects a value for parameter 'api_key' or 'personal_access_token'") | ||
| } | ||
|
|
||
| file { $config_file: | ||
| ensure => file, | ||
| owner => 'root', | ||
| group => 'root', | ||
| mode => '0400', | ||
| content => epp('letsencrypt/ini.epp', { | ||
| vars => { '' => $ini_vars }, | ||
| }), | ||
| } | ||
| } |
This file contains hidden or 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 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'spec_helper_acceptance' | ||
|
|
||
| describe 'letsencrypt::plugin::dns_gandi', if: supported_os_gandi(fact('os')) 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 |
This file contains hidden or 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,45 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'spec_helper' | ||
|
|
||
| describe 'letsencrypt::plugin::dns_gandi' do | ||
| on_supported_os.each do |os, facts| | ||
| next unless supported_os_gandi(os) | ||
|
|
||
| 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 | ||
| 'python3-certbot-dns-gandi' | ||
| end | ||
|
|
||
| context 'with required parameters' do | ||
| it do | ||
| is_expected.to compile.with_all_deps | ||
| end | ||
|
|
||
| describe 'with manage_package => true' do | ||
| let(:params) { super().merge(manage_package: true) } | ||
|
|
||
| it do | ||
| is_expected.to contain_class('letsencrypt::plugin::dns_gandi').with_package_name(package_name) | ||
| is_expected.to contain_package(package_name).with_ensure('installed') | ||
| end | ||
| end | ||
|
|
||
| describe 'with manage_package => false' do | ||
| let(:params) { super().merge(manage_package: false, package_name: 'dns-gandi-package') } | ||
|
|
||
| it { is_expected.not_to contain_package('dns-gandi-package') } | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -227,6 +227,66 @@ class { 'letsencrypt::plugin::dns_linode': | |
| 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-linode --cert-name 'foo.example.com' -d 'foo.example.com' --dns-linode --dns-linode-credentials /etc/letsencrypt/dns-linode.ini --dns-linode-propagation-seconds 120" } | ||
| end | ||
|
|
||
| context 'with dns-gandi plugin with api_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', | ||
| 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' --dns-gandi-credentials /etc/letsencrypt/dns-gandi.ini" } | ||
| end | ||
|
|
||
| context 'with dns-gandi plugin with personal_access_token' 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', | ||
| personal_access_token => 'dummy-pat', | ||
| } | ||
| 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' --dns-gandi-credentials /etc/letsencrypt/dns-gandi.ini" } | ||
| end | ||
|
|
||
| context 'with dns-gandi plugin without api_key or personal_access_token' 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.to compile.and_raise_error(%r{expects a value for parameter 'api_key' or 'personal_access_token'}) } | ||
| end | ||
|
|
||
| context 'with custom plugin' do | ||
| let(:title) { 'foo.example.com' } | ||
| let(:params) { { plugin: 'apache' } } | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,6 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| def supported_os_gandi(os) | ||
| # Gandi plugin is only supported on debian 11 and ubuntu 20.04 and superiors | ||
| (os['name'] == 'Debian' && os['release']['major'].to_i >= 11) || (os['name'] == 'Ubuntu' && os['release']['major'].to_i >= 20) | ||
| end |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -10,5 +10,6 @@ | |
| 'dns-cloudflare', | ||
| 'dns-linode', | ||
| 'dns-rfc2136', | ||
| 'dns-gandi', | ||
| 'manual', | ||
| ] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.