Skip to content
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

modulesync 2.5.0 and drop Puppet4 support #156

Merged
merged 11 commits into from
Jan 13, 2019
10 changes: 5 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Thank you for contributing to this project!
-->
#### Pull Request (PR) description
<!--
Replace this comment with a description of your pull request.
Replace this comment with a description of your pull request.
-->

#### This Pull Request (PR) fixes the following issues
<!--
Replace this comment with the list of issues or n/a.
Use format:
Fixes #123
Fixes #124
Replace this comment with the list of issues or n/a.
Use format:
Fixes #123
Fixes #124
-->
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
modulesync_config_version: '2.4.0'
modulesync_config_version: '2.5.0'
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
---
sudo: false
dist: xenial
language: ruby
cache: bundler
before_install:
- rm -f Gemfile.lock
- sh ./.travis/setup.sh
script:
- 'bundle exec rake $CHECK'
matrix:
fast_finish: true
include:
- rvm: 2.1.9
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=12
- rvm: 2.4.4
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 5.0" CHECK=test
- rvm: 2.5.1
- rvm: 2.5.3
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 6.0" CHECK=test_with_coveralls
- rvm: 2.5.1
- rvm: 2.5.3
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 6.0" CHECK=rubocop
- rvm: 2.4.4
Expand Down
12 changes: 12 additions & 0 deletions .travis/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

# THIS FILE IS MANAGED BY MODULESYNC

rm -f Gemfile.lock
if [ "${PUPPET_VERSION}" = '~> 4.0' ]; then
gem install bundler -v '< 2' --no-rdoc --no-ri;
else
gem update --system;
gem update bundler;
bundle --version;
fi
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ This module installs the Let's Encrypt client from source and allows you to requ

## Support

This module requires Puppet >= 4.7.0. and is currently only written to work on
Debian and RedHat based operating systems, although it may work on others.
This module is currently only written to work on Debian and RedHat based
operating systems, although it may work on others. The supported Puppet
versions are defined in the [metadata.json](metadata.json)

## Dependencies

Expand Down
20 changes: 10 additions & 10 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,43 @@
$path = '/opt/letsencrypt'
$venv_path = '/opt/letsencrypt/.venv' # virtualenv path for vcs-installed letsencrypt
$repo = 'https://github.com/certbot/certbot.git'
$cron_scripts_path = "${::puppet_vardir}/letsencrypt" # path for renewal scripts called by cron
$cron_scripts_path = "${facts['puppet_vardir']}/letsencrypt" # path for renewal scripts called by cron
$version = 'v0.9.3'
$config = {
'server' => 'https://acme-v01.api.letsencrypt.org/directory',
}

if $::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '8') >= 0 {
if $facts['operatingsystem'] == 'Debian' and versioncmp($facts['operatingsystemrelease'], '8') >= 0 {
$install_method = 'package'
$package_name = 'certbot'
$package_command = 'certbot'
$config_dir = '/etc/letsencrypt'
} elsif $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '16.04') == 0 {
} elsif $facts['operatingsystem'] == 'Ubuntu' and versioncmp($facts['operatingsystemrelease'], '16.04') == 0 {
$install_method = 'package'
$package_name = 'letsencrypt'
$package_command = 'letsencrypt'
$config_dir = '/etc/letsencrypt'
} elsif $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '18.04') >= 0 {
} elsif $facts['operatingsystem'] == 'Ubuntu' and versioncmp($facts['operatingsystemrelease'], '18.04') >= 0 {
$install_method = 'package'
$package_name = 'certbot'
$package_command = 'certbot'
$config_dir = '/etc/letsencrypt'
} elsif $::osfamily == 'RedHat' and versioncmp($::operatingsystemmajrelease, '7') >= 0 {
} elsif $facts['osfamily'] == 'RedHat' and versioncmp($facts['operatingsystemmajrelease'], '7') >= 0 {
$install_method = 'package'
$package_name = 'certbot'
$package_command = 'certbot'
$config_dir = '/etc/letsencrypt'
} elsif $::osfamily == 'Gentoo' {
} elsif $facts['osfamily'] == 'Gentoo' {
$install_method = 'package'
$package_name = 'app-crypt/certbot'
$package_command = 'certbot'
$config_dir = '/etc/letsencrypt'
} elsif $::osfamily == 'OpenBSD' {
} elsif $facts['osfamily'] == 'OpenBSD' {
$install_method = 'package'
$package_name = 'certbot'
$package_command = 'certbot'
$config_dir = '/etc/letsencrypt'
} elsif $::osfamily == 'FreeBSD' {
} elsif $facts['osfamily'] == 'FreeBSD' {
$install_method = 'package'
$package_name = 'py27-certbot'
$package_command = 'certbot'
Expand All @@ -58,13 +58,13 @@

$config_file = "${config_dir}/cli.ini"

if $::osfamily == 'RedHat' {
if $facts['osfamily'] == 'RedHat' {
$configure_epel = true
} else {
$configure_epel = false
}

$cron_owner_group = $::osfamily ? {
$cron_owner_group = $facts['osfamily'] ? {
'OpenBSD' => 'wheel',
'FreeBSD' => 'wheel',
default => 'root',
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 4.10.0 < 7.0.0"
"version_requirement": ">= 5.5.8 < 7.0.0"
bastelfreak marked this conversation as resolved.
Show resolved Hide resolved
}
],
"dependencies": [
Expand Down
139 changes: 74 additions & 65 deletions spec/classes/letsencrypt_install_spec.rb
Original file line number Diff line number Diff line change
@@ -1,92 +1,101 @@
require 'spec_helper'

describe 'letsencrypt::install' do
let(:params) { default_params.merge(additional_params) }
let(:default_params) do
{
configure_epel: false,
package_ensure: 'installed',
manage_install: true,
manage_dependencies: true,
path: '/opt/letsencrypt',
repo: 'https://github.com/certbot/certbot.git',
version: 'v0.9.3',
package_name: 'letsencrypt'
}
end
let(:additional_params) { {} }
on_supported_os.each do |os, facts|
let :facts do
ekohl marked this conversation as resolved.
Show resolved Hide resolved
facts
end
let(:params) { default_params.merge(additional_params) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A pattern I've started to use instead is:

let(:params) do
  {
    # ...
  }
end

Then when you need to override it below:

let(:params) { super().merge(install_method: 'package') }

let(:default_params) do
{
configure_epel: false,
package_ensure: 'installed',
manage_install: true,
manage_dependencies: true,
path: '/opt/letsencrypt',
repo: 'https://github.com/certbot/certbot.git',
version: 'v0.9.3',
package_name: 'letsencrypt'
}
end
let(:additional_params) { {} }

describe 'with install_method => package' do
let(:additional_params) { { install_method: 'package' } }
context "on #{os} based operating systems" do
describe 'with install_method => package' do
let(:additional_params) { { install_method: 'package' } }

it { is_expected.to compile }
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')
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
is_expected.to contain_package('letsencrypt').with_ensure('installed')
end

describe 'with configure_epel => true' do
let(:facts) { { osfamily: 'RedHat', operatingsystem: 'RedHat', operatingsystemrelease: '7.0.1406', operatingsystemmajrelease: '7' } }
let(:additional_params) { { install_method: 'package', configure_epel: true } }
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 compile }
it { is_expected.to contain_package('letsencrypt').with_ensure('0.3.0-1.el7') }
end

it 'contains the correct resources' do
is_expected.to contain_class('epel')
is_expected.to contain_package('letsencrypt').that_requires('Class[epel]')
end
end
case facts[:osfamily]
when 'RedHat'
describe 'with configure_epel => true' do
let(:additional_params) { { install_method: 'package', configure_epel: true } }

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 compile }
it { is_expected.to contain_package('letsencrypt').with_ensure('0.3.0-1.el7') }
end
end
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
end

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

it { is_expected.to compile }
it { is_expected.to compile }

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

is_expected.not_to contain_package('letsencrypt')
end
is_expected.not_to contain_package('letsencrypt')
end

describe 'with custom path' do
let(:additional_params) { { install_method: 'vcs', path: '/usr/lib/letsencrypt' } }
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
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' } }
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
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' } }
describe 'with custom version' do
let(:additional_params) { { install_method: 'vcs', version: 'foo' } }

it { is_expected.to contain_vcsrepo('/opt/letsencrypt').with_revision('foo') }
end
it { is_expected.to contain_vcsrepo('/opt/letsencrypt').with_revision('foo') }
end

describe 'with manage_dependencies set to false' do
let(:additional_params) { { install_method: 'vcs', manage_dependencies: false } }
describe 'with manage_dependencies set to false' do
let(:additional_params) { { install_method: 'vcs', manage_dependencies: false } }

it 'does not contain the dependencies' do
is_expected.not_to contain_package('git')
is_expected.not_to contain_package('python')
it 'does not contain the dependencies' do
is_expected.not_to contain_package('git')
is_expected.not_to contain_package('python')
end
end
end
end
end
Expand Down
Loading