Skip to content

Commit

Permalink
Remove VCS install method
Browse files Browse the repository at this point in the history
This has been stuck on an old version and so far nobody has updated it
to a recent version that actually works. Distribution packages just
work.
  • Loading branch information
ekohl committed Jun 25, 2021
1 parent 4fad787 commit ee77abc
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 240 deletions.
1 change: 0 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ fixtures:
epel: 'https://github.com/voxpupuli/puppet-epel.git'
inifile: 'https://github.com/puppetlabs/puppetlabs-inifile.git'
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
vcsrepo: 'https://github.com/puppetlabs/puppetlabs-vcsrepo.git'
yumrepo_core:
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
puppet_version: ">= 6.0.0"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class { 'letsencrypt':
}
```

If using Ubuntu16.04 with `install_method` to default `package`, you can enforce upgrade of package from 0.4 to 0.7 with :
You can enforce upgrade of package to the latest available version (in your repositories):

```puppet
class { 'letsencrypt':
Expand Down
7 changes: 3 additions & 4 deletions manifests/certonly.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# `webroot_paths` are not the same length, the last `webroot_paths`
# element will be used for all subsequent domains.
# @param letsencrypt_command Command to run letsencrypt
# @param additional_args An array of additional command line arguments to pass to the `letsencrypt-auto` command.
# @param environment An optional array of environment variables (in addition to VENV_PATH).
# @param additional_args An array of additional command line arguments to pass to the `letsencrypt` command.
# @param environment An optional array of environment variables
# @param key_size Size for the RSA public key
# @param manage_cron
# Indicating whether or not to schedule cron job for renewal.
Expand Down Expand Up @@ -157,7 +157,6 @@
]).filter | $arg | { $arg =~ NotUndef and $arg != [] }
$command = join($_command, ' ')

$execution_environment = ["VENV_PATH=${letsencrypt::venv_path}",] + $environment
$verify_domains = join(unique($domains), '\' \'')

if $ensure == 'present' {
Expand All @@ -170,7 +169,7 @@
command => $command,
* => $exec_ensure,
path => $facts['path'],
environment => $execution_environment,
environment => $environment,
provider => 'shell',
require => [
Class['letsencrypt'],
Expand Down
26 changes: 4 additions & 22 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
# @param email
# The email address to use to register with Let's Encrypt. This takes
# precedence over an 'email' setting defined in $config.
# @param path The path to the letsencrypt installation.
# @param venv_path virtualenv path for vcs-installed Certbot
# @param environment An optional array of environment variables (in addition to VENV_PATH)
# @param repo A Git URL to install the Let's encrypt client from.
# @param version The Git ref (tag, sha, branch) to check out when installing the client with the `vcs` method.
# @param environment An optional array of environment variables
# @param package_name Name of package and command to use when installing the client with the `package` method.
# @param package_ensure The value passed to `ensure` when installing the client with the `package` method.
# @param package_command Path or name for letsencrypt executable when installing the client with the `package` method.
Expand All @@ -29,7 +25,6 @@
# @param manage_install A feature flag to toggle the management of the letsencrypt client installation.
# @param manage_dependencies A feature flag to toggle the management of the letsencrypt dependencies.
# @param configure_epel A feature flag to include the 'epel' class and depend on it for package installation.
# @param install_method Method to install the letsencrypt client, either package or vcs.
# @param agree_tos A flag to agree to the Let's Encrypt Terms of Service.
# @param unsafe_registration A flag to allow using the 'register-unsafely-without-email' flag.
# @param config_dir The path to the configuration directory.
Expand Down Expand Up @@ -59,11 +54,7 @@
class letsencrypt (
Boolean $configure_epel,
Optional[String] $email = undef,
String $path = '/opt/letsencrypt',
$venv_path = '/opt/letsencrypt/.venv',
Array $environment = [],
String $repo = 'https://github.com/certbot/certbot.git',
String $version = 'v0.39.0',
String $package_name = 'certbot',
$package_ensure = 'installed',
String $package_command = 'certbot',
Expand All @@ -75,7 +66,6 @@
Boolean $manage_config = true,
Boolean $manage_install = true,
Boolean $manage_dependencies = true,
Enum['package', 'vcs'] $install_method = 'package',
Boolean $agree_tos = true,
Boolean $unsafe_registration = false,
Integer[2048] $key_size = 4096,
Expand All @@ -95,15 +85,7 @@
Class['letsencrypt::install'] -> Class['letsencrypt::renew']
}

$command = $install_method ? {
'package' => $package_command,
'vcs' => "${venv_path}/bin/letsencrypt",
}

$command_init = $install_method ? {
'package' => $package_command,
'vcs' => "${path}/letsencrypt-auto",
}
$command = $package_command

if $manage_config {
contain letsencrypt::config # lint:ignore:relative_classname_inclusion
Expand All @@ -114,9 +96,9 @@

# TODO: do we need this command when installing from package?
exec { 'initialize letsencrypt':
command => "${command_init} -h",
command => "${package_command} -h",
path => $facts['path'],
environment => concat(["VENV_PATH=${venv_path}"], $environment),
environment => $environment,
refreshonly => true,
}

Expand Down
41 changes: 7 additions & 34 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,48 +1,21 @@
# @summary Installs the Let's Encrypt client.
#
# @param manage_install A feature flag to toggle the management of the letsencrypt client installation.
# @param manage_dependencies A feature flag to toggle the management of the letsencrypt dependencies.
# @param configure_epel A feature flag to include the 'epel' class and depend on it for package installation.
# @param install_method Method to install the letsencrypt client
# @param path The path to the letsencrypt installation.
# @param repo A Git URL to install the Let's encrypt client from.
# @param version The Git ref (tag, sha, branch) to check out when installing the client with the `vcs` method.
# @param package_ensure The value passed to `ensure` when installing the client with the `package` method.
# @param package_name Name of package to use when installing the client with the `package` method.
#
class letsencrypt::install (
Boolean $manage_install = $letsencrypt::manage_install,
Boolean $manage_dependencies = $letsencrypt::manage_dependencies,
Boolean $configure_epel = $letsencrypt::configure_epel,
Enum['package', 'vcs'] $install_method = $letsencrypt::install_method,
String $package_name = $letsencrypt::package_name,
String $package_ensure = $letsencrypt::package_ensure,
String $path = $letsencrypt::path,
String $repo = $letsencrypt::repo,
String $version = $letsencrypt::version,
) {
if $install_method == 'vcs' {
if $manage_dependencies {
$dependencies = ['python', 'git']
ensure_packages($dependencies)
Package[$dependencies] -> Vcsrepo[$path]
}

vcsrepo { $path:
ensure => present,
provider => git,
source => $repo,
revision => $version,
}
} else {
package { 'letsencrypt':
ensure => $package_ensure,
name => $package_name,
}
package { 'letsencrypt':
ensure => $package_ensure,
name => $package_name,
}

if $configure_epel {
include epel
Class['epel'] -> Package['letsencrypt']
}
if $configure_epel {
include epel
Class['epel'] -> Package['letsencrypt']
}
}
4 changes: 0 additions & 4 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@
"name": "puppetlabs/inifile",
"version_requirement": ">= 2.0.0 < 5.0.0"
},
{
"name": "puppetlabs/vcsrepo",
"version_requirement": ">= 2.0.0 < 4.0.0"
},
{
"name": "puppet/epel",
"version_requirement": ">= 3.0.1 < 4.0.0"
Expand Down
35 changes: 0 additions & 35 deletions spec/acceptance/letsencrypt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,4 @@ class { 'letsencrypt' :
its(:content) { is_expected.to match %r{email = letsregister@example.com} }
end
end

context 'with install_method => vcs' do
pp = %(
class { 'letsencrypt' :
install_method => 'vcs',
email => 'letsregister@example.com',
config => {
'server' => 'https://acme-staging-v02.api.letsencrypt.org/directory',
},
}
)

it 'installs letsencrypt without error' do
apply_manifest(pp, catch_failures: true)
end
it 'installs letsencrypt idempotently' do
apply_manifest(pp, catch_changes: true)
end

describe file('/etc/letsencrypt/cli.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 644 }
its(:content) { is_expected.to match %r{server = https://acme-staging-v02.api.letsencrypt.org/directory} }
its(:content) { is_expected.to match %r{email = letsregister@example.com} }
end

describe file('/opt/letsencrypt/.venv/bin/certbot') 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 755 }
end
end
end
87 changes: 16 additions & 71 deletions spec/classes/letsencrypt_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
{
configure_epel: false,
package_ensure: 'installed',
manage_install: true,
manage_dependencies: true,
path: '/opt/letsencrypt',
repo: 'https://github.com/certbot/certbot.git',
version: 'v0.30.2',
package_name: 'letsencrypt'
}
end
Expand All @@ -22,79 +17,29 @@
facts
end

describe 'with install_method => package' do
let(:additional_params) { { install_method: 'package' } }
it { is_expected.to compile.with_all_deps }

it { is_expected.to compile }

it 'contains the correct resources' do
is_expected.not_to contain_vcsrepo('/opt/letsencrypt')
is_expected.not_to contain_package('python')
is_expected.not_to contain_package('git')

is_expected.to contain_package('letsencrypt').with_ensure('installed')
end

describe 'with package_ensure => 0.3.0-1.el7' do
let(:additional_params) { { install_method: 'package', package_ensure: '0.3.0-1.el7' } }

it { is_expected.to compile }
it { is_expected.to contain_package('letsencrypt').with_ensure('0.3.0-1.el7') }
end

case facts[:osfamily]
when 'RedHat'
describe 'with configure_epel => true' do
let(:additional_params) { { install_method: 'package', configure_epel: true } }

it { is_expected.to compile }

it 'contains the correct resources' do
is_expected.to contain_class('epel')
is_expected.to contain_package('letsencrypt').that_requires('Class[epel]')
end
end
end
it 'contains the correct resources' do
is_expected.to contain_package('letsencrypt').with_ensure('installed')
end

describe 'with install_method => vcs' do
let(:additional_params) { { install_method: 'vcs' } }

it { is_expected.to compile }
describe 'with package_ensure => 0.3.0-1.el7' do
let(:additional_params) { { package_ensure: '0.3.0-1.el7' } }

it 'contains the correct resources' do
is_expected.to contain_vcsrepo('/opt/letsencrypt').with(source: 'https://github.com/certbot/certbot.git',
revision: 'v0.30.2')
is_expected.to contain_package('python')
is_expected.to contain_package('git')

is_expected.not_to contain_package('letsencrypt')
end

describe 'with custom path' do
let(:additional_params) { { install_method: 'vcs', path: '/usr/lib/letsencrypt' } }

it { is_expected.to contain_vcsrepo('/usr/lib/letsencrypt') }
end

describe 'with custom repo' do
let(:additional_params) { { install_method: 'vcs', repo: 'git://foo.com/letsencrypt.git' } }

it { is_expected.to contain_vcsrepo('/opt/letsencrypt').with_source('git://foo.com/letsencrypt.git') }
end

describe 'with custom version' do
let(:additional_params) { { install_method: 'vcs', version: 'foo' } }
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_package('letsencrypt').with_ensure('0.3.0-1.el7') }
end

it { is_expected.to contain_vcsrepo('/opt/letsencrypt').with_revision('foo') }
end
case facts[:osfamily]
when 'RedHat'
describe 'with configure_epel => true' do
let(:additional_params) { { configure_epel: true } }

describe 'with manage_dependencies set to false' do
let(:additional_params) { { install_method: 'vcs', manage_dependencies: false } }
it { is_expected.to compile.with_all_deps }

it 'does not contain the dependencies' do
is_expected.not_to contain_package('git')
is_expected.not_to contain_package('python')
it 'contains the correct resources' do
is_expected.to contain_class('epel')
is_expected.to contain_package('letsencrypt').that_requires('Class[epel]')
end
end
end
Expand Down
Loading

0 comments on commit ee77abc

Please sign in to comment.