Skip to content

Commit 25f2e23

Browse files
authored
Merge pull request #981 from tylerjl/download-tool-cert-verification
Set download tool to verify certificates by default
2 parents 1846176 + 840f7d4 commit 25f2e23

File tree

7 files changed

+42
-8
lines changed

7 files changed

+42
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#### Fixes
44
* Update puppetlabs-stdlib dependency to < 6.0.0
5+
* By default, package files downloaded with tools like wget or curl (i.e., the `$elasticsearch::download_tool parameter`) now verify certificates by default and a new boolean parameter has been added to indicate whether to ignore certificates (`$elasticsearch::download_tool_verify_certificates`).
56

67
#### Features
78

data/common.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ elasticsearch::datadir_instance_directories: true
1717
elasticsearch::default_logging_level: 'INFO'
1818
elasticsearch::defaults_location: ~
1919
elasticsearch::download_tool: ~
20+
elasticsearch::download_tool_insecure: ~
21+
elasticsearch::download_tool_verify_certificates: true
2022
elasticsearch::file_rolling_type: dailyRollingFile
2123
elasticsearch::indices: {}
2224
elasticsearch::init_defaults: {}

data/kernel/Darwin.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2-
elasticsearch::download_tool: 'curl --insecure -o'
2+
elasticsearch::download_tool: curl -o
3+
elasticsearch::download_tool_insecure: curl --insecure -o
34
elasticsearch::elasticsearch_user: elasticsearch
45
elasticsearch::elasticsearch_group: elasticsearch

data/kernel/Linux.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
elasticsearch::datadir: /var/lib/elasticsearch
3-
elasticsearch::download_tool: 'wget --no-check-certificate -O'
3+
elasticsearch::download_tool: wget -O
4+
elasticsearch::download_tool_insecure: wget --no-check-certificate -O
45
elasticsearch::elasticsearch_user: elasticsearch
56
elasticsearch::elasticsearch_group: elasticsearch
67
elasticsearch::homedir: /usr/share/elasticsearch

manifests/init.pp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@
8484
# @param download_tool
8585
# Command-line invocation with which to retrieve an optional package_url.
8686
#
87+
# @param download_tool_insecure
88+
# Command-line invocation with which to retrieve an optional package_url when
89+
# certificate verification should be ignored.
90+
#
91+
# @param download_tool_verify_certificates
92+
# Whether or not to verify SSL/TLS certificates when retrieving package files
93+
# using a download tool instead of a package management provider.
94+
#
8795
# @param elasticsearch_group
8896
# The group Elasticsearch should run as. This also sets file group
8997
# permissions.
@@ -307,6 +315,8 @@
307315
String $default_logging_level,
308316
Optional[Stdlib::Absolutepath] $defaults_location,
309317
Optional[String] $download_tool,
318+
Optional[String] $download_tool_insecure,
319+
Boolean $download_tool_verify_certificates,
310320
String $elasticsearch_group,
311321
String $elasticsearch_user,
312322
Enum['dailyRollingFile', 'rollingFile', 'file'] $file_rolling_type,

manifests/package.pp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,14 @@
105105

106106
case $elasticsearch::download_tool {
107107
String: {
108+
$_download_command = if $elasticsearch::download_tool_verify_certificates {
109+
$elasticsearch::download_tool
110+
} else {
111+
$elasticsearch::download_tool_insecure
112+
}
113+
108114
exec { 'download_package_elasticsearch':
109-
command => "${elasticsearch::download_tool} ${pkg_source} ${elasticsearch::package_url} 2> /dev/null",
115+
command => "${_download_command} ${pkg_source} ${elasticsearch::package_url} 2> /dev/null",
110116
creates => $pkg_source,
111117
environment => $exec_environment,
112118
timeout => $elasticsearch::package_dl_timeout,

spec/classes/000_elasticsearch_init_spec.rb

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,24 @@
158158
:backup => false
159159
) }
160160
else
161-
it { should contain_exec('download_package_elasticsearch')
162-
.with(
163-
:command => "wget --no-check-certificate -O /opt/elasticsearch/swdl/pkg.#{pkg_ext} #{schema}domain-or-path/pkg.#{pkg_ext} 2> /dev/null",
164-
:require => 'File[/opt/elasticsearch/swdl]'
165-
) }
161+
[true, false].each do |verify_certificates|
162+
context "with download_tool_verify_certificates '#{verify_certificates}'" do
163+
let(:params) do
164+
default_params.merge(
165+
:package_url => "#{schema}domain-or-path/pkg.#{pkg_ext}",
166+
:download_tool_verify_certificates => verify_certificates
167+
)
168+
end
169+
170+
flag = (not verify_certificates) ? ' --no-check-certificate' : ''
171+
172+
it { should contain_exec('download_package_elasticsearch')
173+
.with(
174+
:command => "wget#{flag} -O /opt/elasticsearch/swdl/pkg.#{pkg_ext} #{schema}domain-or-path/pkg.#{pkg_ext} 2> /dev/null",
175+
:require => 'File[/opt/elasticsearch/swdl]'
176+
) }
177+
end
178+
end
166179
end
167180

168181
it { should contain_package('elasticsearch')

0 commit comments

Comments
 (0)