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

(maint) Add allow_insecure to tomcat::war #246

Merged
merged 1 commit into from
Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This major release drops puppet 3, changes dependencies from staging to archive,
- `tomcat::install` attributes `proxy_server` and `proxy_type` for installing behind a proxy.
- `tomcat::install` attribute `allow_insecure` for disabling https verification.
- `tomcat::war` ability to use context paths and versions with `war_name` attribute.
- `tomcat::war` ability to ignore HTTPS errors with `allow_insecure` attribute.

### Fixed
- Corrected documentation for all `attributes_to_remove` attributes.
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,14 @@ Default value: `true`.

#### `tomcat::war`

##### `allow_insecure`

Specifies if HTTPS errors should be ignored when downloading the war tarball.

Default value: `false`,

Valid options: `true` and `false`.

##### `app_base`

Specifies where to deploy the WAR. Cannot be used in combination with `deployment_path`.
Expand Down
11 changes: 8 additions & 3 deletions manifests/war.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
# @param war_source is the source to deploy the WAR from. Currently supports
# http(s)://, puppet://, and ftp:// paths. $war_source must be specified
# unless $war_ensure is set to 'false' or 'absent'.
# @param allow_insecure Specifies if HTTPS errors should be ignored when
# downloading the war tarball. Valid options: `true` and `false`.
# Defaults to `false`.
define tomcat::war(
$catalina_base = undef,
$app_base = undef,
Expand All @@ -26,6 +29,7 @@
$war_name = undef,
Boolean $war_purge = true,
$war_source = undef,
Boolean $allow_insecure = false,
) {
include ::tomcat
$_catalina_base = pick($catalina_base, $::tomcat::catalina_home)
Expand Down Expand Up @@ -75,9 +79,10 @@
fail('$war_source must be specified if you aren\'t removing the WAR')
}
archive { "tomcat::war ${name}":
extract => false,
source => $war_source,
path => "${_deployment_path}/${_war_name}",
extract => false,
source => $war_source,
path => "${_deployment_path}/${_war_name}",
allow_insecure => $allow_insecure,
}
}
}
5 changes: 3 additions & 2 deletions spec/acceptance/acceptance_1b_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ class jsvc {
port => '8309',
}
tomcat::war { 'war_one.war':
catalina_base => '/opt/apache-tomcat/tomcat8-jsvc',
war_source => '#{SAMPLE_WAR}',
catalina_base => '/opt/apache-tomcat/tomcat8-jsvc',
war_source => '#{SAMPLE_WAR}',
allow_insecure => true,
}
tomcat::setenv::entry { 'JAVA_HOME':
user => 'tomcat8',
Expand Down
46 changes: 26 additions & 20 deletions spec/acceptance/acceptance_2b_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ class { 'java':}
},
}
tomcat::war { 'first tomcat7-sample.war':
catalina_base => '/opt/tomcat7-first',
war_source => '#{SAMPLE_WAR}',
war_name => 'tomcat7#sample.war',
catalina_base => '/opt/tomcat7-first',
war_source => '#{SAMPLE_WAR}',
war_name => 'tomcat7#sample.war',
allow_insecure => true,
}
tomcat::war { 'second tomcat7-sample.war':
catalina_base => '/opt/tomcat7-second',
war_source => '#{SAMPLE_WAR}',
war_name => 'tomcat7#sample.war',
catalina_base => '/opt/tomcat7-second',
war_source => '#{SAMPLE_WAR}',
war_name => 'tomcat7#sample.war',
allow_insecure => true,
}


Expand Down Expand Up @@ -136,14 +138,16 @@ class { 'java':}
},
}
tomcat::war { 'first tomcat7078-sample.war':
catalina_base => '/opt/tomcat7078-first',
war_source => '#{SAMPLE_WAR}',
war_name => 'tomcat7078-sample.war',
catalina_base => '/opt/tomcat7078-first',
war_source => '#{SAMPLE_WAR}',
war_name => 'tomcat7078-sample.war',
allow_insecure => true,
}
tomcat::war { 'second tomcat7078-sample.war':
catalina_base => '/opt/tomcat7078-second',
war_source => '#{SAMPLE_WAR}',
war_name => 'tomcat7078-sample.war',
catalina_base => '/opt/tomcat7078-second',
war_source => '#{SAMPLE_WAR}',
war_name => 'tomcat7078-sample.war',
allow_insecure => true,
}
EOS
apply_manifest(pp, :catch_failures => true)
Expand Down Expand Up @@ -256,21 +260,23 @@ class { 'java':}
it 'Should apply the manifest without error' do
pp = <<-EOS
tomcat::war { 'tomcat7-sample.war':
catalina_base => '/opt/tomcat7-first',
war_source => '#{SAMPLE_WAR}',
war_name => 'tomcat7-sample.war',
war_ensure => 'present',
catalina_base => '/opt/tomcat7-first',
war_source => '#{SAMPLE_WAR}',
war_name => 'tomcat7-sample.war',
war_ensure => 'present',
allow_insecure => true,
} ~>
tomcat::service { 'tomcat7-first':
catalina_home => '/opt/apache-tomcat7',
catalina_base => '/opt/tomcat7-first',
service_ensure => 'running',
}
tomcat::war { 'tomcat7078-sample.war':
catalina_base => '/opt/tomcat7078-first',
war_source => '#{SAMPLE_WAR}',
war_name => 'tomcat7078-sample.war',
war_ensure => 'present',
catalina_base => '/opt/tomcat7078-first',
war_source => '#{SAMPLE_WAR}',
war_name => 'tomcat7078-sample.war',
war_ensure => 'present',
allow_insecure => true,
} ~>
tomcat::service { 'tomcat7078-first':
catalina_home => '/opt/apache-tomcat7078',
Expand Down
7 changes: 4 additions & 3 deletions spec/acceptance/acceptance_3b_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ class { 'tomcat':
},
}
tomcat::war { 'tomcat8-sample.war':
catalina_base => '/opt/apache-tomcat8/tomcat8',
war_source => '/tmp/sample.war',
war_name => 'tomcat8-sample.war',
catalina_base => '/opt/apache-tomcat8/tomcat8',
war_source => '/tmp/sample.war',
war_name => 'tomcat8-sample.war',
allow_insecure => true,
}
EOS
apply_manifest(pp, :catch_failures => true)
Expand Down
7 changes: 4 additions & 3 deletions spec/acceptance/acceptance_4b_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ class { 'tomcat': catalina_home => '/opt/apache-tomcat40', }
},
}
tomcat::war { 'tomcat40-sample.war':
catalina_base => '/opt/apache-tomcat40',
war_source => '/tmp/sample.war',
war_name => 'tomcat40-sample.war',
catalina_base => '/opt/apache-tomcat40',
war_source => '/tmp/sample.war',
war_name => 'tomcat40-sample.war',
allow_insecure => true,
}
tomcat::config::server::realm { 'org.apache.catalina.realm.CombinedRealm':
catalina_base => '/opt/apache-tomcat40',
Expand Down
34 changes: 34 additions & 0 deletions spec/defines/install_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require 'spec_helper'

describe 'tomcat::install', :type => :define do
let :pre_condition do
'class { "tomcat": }'
end
let :default_facts do
{
:osfamily => 'Debian',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
let :title do
'default'
end
context 'install from source, allow_insecure' do
let :facts do default_facts end
let :params do
{
:catalina_home => '/opt/apache-tomcat/test-tomcat',
:source_url => 'http://mirror.nexcess.net/apache/tomcat/tomcat-8/v8.0.8/bin/apache-tomcat-8.0.8.tar.gz',
:allow_insecure => true,
}
end
it { is_expected.to contain_archive('default-/opt/apache-tomcat/test-tomcat/apache-tomcat-8.0.8.tar.gz').with(
'extract_path' => '/opt/apache-tomcat/test-tomcat',
'user' => 'tomcat',
'group' => 'tomcat',
'extract_flags' => '--strip 1 -xf',
'allow_insecure' => true,
)
}
end
end
16 changes: 9 additions & 7 deletions spec/defines/war_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@
context 'set everything' do
let :params do
{
:catalina_base => '/opt/apache-tomcat/test',
:app_base => 'webapps2',
:war_ensure => 'present',
:war_name => 'sample2.war',
:war_source => '/tmp/sample.war',
:catalina_base => '/opt/apache-tomcat/test',
:app_base => 'webapps2',
:war_ensure => 'present',
:war_name => 'sample2.war',
:war_source => '/tmp/sample.war',
:allow_insecure => true,
}
end
it { is_expected.to contain_archive('tomcat::war sample.war').with(
'source' => '/tmp/sample.war',
'path' => '/opt/apache-tomcat/test/webapps2/sample2.war',
'source' => '/tmp/sample.war',
'path' => '/opt/apache-tomcat/test/webapps2/sample2.war',
'allow_insecure' => true,
)
}
end
Expand Down