From 6aacefa85c9f12a4a1cc01fe156747852902693c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Mon, 5 Dec 2016 18:29:10 +0100 Subject: [PATCH] rename environment parameter to unbreak hiera This is a fix for #63. We rename the `environment` to `venv_vars` in order to ensure that hiera calls do *not* break, as soon as a puppet execution flow enters our module. For consistency's sake, we change `environment` not only in the main class (where it's definitely needed: https://github.com/rodjek/puppet-lint/issues/574), but also in the `certonly` define. --- manifests/certonly.pp | 6 +++--- manifests/init.pp | 8 ++++---- spec/classes/letsencrypt_spec.rb | 3 +-- spec/defines/letsencrypt_certonly_spec.rb | 5 ++--- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/manifests/certonly.pp b/manifests/certonly.pp index ab571bf8..54bca3bc 100644 --- a/manifests/certonly.pp +++ b/manifests/certonly.pp @@ -21,7 +21,7 @@ # [*additional_args*] # An array of additional command line arguments to pass to the # `letsencrypt-auto` command. -# [*environment*] +# [*venv_vars*] # An optional array of environment variables (in addition to VENV_PATH). # [*manage_cron*] # Boolean indicating whether or not to schedule cron job for renewal. @@ -39,7 +39,7 @@ Array[Stdlib::Unixpath] $webroot_paths = [], String[1] $letsencrypt_command = $letsencrypt::command, Array[String[1]] $additional_args = [], - Array[String[1]] $environment = [], + Array[String[1]] $venv_vars = [], Boolean $manage_cron = false, Boolean $suppress_cron_output = false, Optional[String[1]] $cron_before_command = undef, @@ -82,7 +82,7 @@ $command = "${command_start}${command_domains}${command_end}" $live_path = "${config_dir}/live/${domains[0]}/cert.pem" - $execution_environment = [ "VENV_PATH=${letsencrypt::venv_path}", ] + $environment + $execution_environment = [ "VENV_PATH=${letsencrypt::venv_path}", ] + $venv_vars $verify_domains = join($domains, ' -d ') exec { "letsencrypt certonly ${title}": command => $command, diff --git a/manifests/init.pp b/manifests/init.pp index 75dd27c1..7a0cc21d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -9,7 +9,7 @@ # precedence over an 'email' setting defined in $config. # [*path*] # The path to the letsencrypt installation. -# [*environment*] +# [*venv_vars*] # An optional array of environment variables (in addition to VENV_PATH) # [*repo*] # A Git URL to install the Let's encrypt client from. @@ -54,8 +54,8 @@ class letsencrypt ( Optional[String] $email = undef, String $path = $letsencrypt::params::path, - $venv_path = $letsencrypt::params::venv_path, - Array $environment = [], + $venv_path = [], + Array $venv_vars = $letsencrypt::params::venv_vars, String $repo = $letsencrypt::params::repo, String $version = $letsencrypt::params::version, String $package_name = $letsencrypt::params::package_name, @@ -98,7 +98,7 @@ exec { 'initialize letsencrypt': command => "${command_init} -h", path => $::path, - environment => concat([ "VENV_PATH=${venv_path}" ], $environment), + environment => concat([ "VENV_PATH=${venv_path}" ], $venv_vars), refreshonly => true, } } diff --git a/spec/classes/letsencrypt_spec.rb b/spec/classes/letsencrypt_spec.rb index eb20be4d..1d2b2840 100644 --- a/spec/classes/letsencrypt_spec.rb +++ b/spec/classes/letsencrypt_spec.rb @@ -41,8 +41,7 @@ end describe 'with custom environment variables' do - let(:additional_params) { { environment: ['FOO=bar', 'FIZZ=buzz'] } } - + let(:additional_params) { { venv_vars: ['FOO=bar', 'FIZZ=buzz'] } } it { is_expected.to contain_exec('initialize letsencrypt').with_environment(['VENV_PATH=/opt/letsencrypt/.venv', 'FOO=bar', 'FIZZ=buzz']) } end diff --git a/spec/defines/letsencrypt_certonly_spec.rb b/spec/defines/letsencrypt_certonly_spec.rb index e78709be..addd6bc3 100644 --- a/spec/defines/letsencrypt_certonly_spec.rb +++ b/spec/defines/letsencrypt_certonly_spec.rb @@ -137,14 +137,13 @@ describe 'when specifying custom environment variables' do let(:title) { 'foo.example.com' } - let(:params) { { environment: ['FOO=bar', 'FIZZ=buzz'] } } - + let(:params) { { venv_vars: ['FOO=bar', 'FIZZ=buzz'] } } it { is_expected.to contain_exec('letsencrypt certonly foo.example.com').with_environment(['VENV_PATH=/opt/letsencrypt/.venv', 'FOO=bar', 'FIZZ=buzz']) } end context 'with custom environment variables and manage cron' do let(:title) { 'foo.example.com' } - let(:params) { { environment: ['FOO=bar', 'FIZZ=buzz'], manage_cron: true } } + let(:params) { { venv_vars: ['FOO=bar', 'FIZZ=buzz'], manage_cron: true } } it { is_expected.to contain_file('/var/lib/puppet/letsencrypt/renew-foo.example.com.sh').with_content "#!/bin/sh\nexport VENV_PATH=/opt/letsencrypt/.venv\nexport FOO=bar\nexport FIZZ=buzz\nletsencrypt --text --agree-tos --non-interactive certonly -a standalone --keep-until-expiring --cert-name foo.example.com -d foo.example.com\n" } end