Skip to content

Commit 2e0a67a

Browse files
authored
Merge pull request #456 from puppetlabs/remove_webapps_files
(MODULES-9520) Allow removal of webapps
2 parents 9975fc7 + e0ef079 commit 2e0a67a

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

manifests/install.pp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
$manage_user = undef,
4949
$manage_group = undef,
5050
$manage_home = undef,
51+
Optional[Array[String]] $remove_default_webapps = undef,
52+
5153

5254
# package options
5355
$package_ensure = undef,
@@ -91,4 +93,20 @@
9193
package_options => $package_options,
9294
}
9395
}
96+
97+
if $remove_default_webapps {
98+
$remove_default_webapps.each |$folder| {
99+
file{"remove ${folder}" :
100+
ensure => absent,
101+
path => "${catalina_home}/webapps/${folder}",
102+
recurse => true,
103+
purge => true,
104+
force => true,
105+
require => $install_from_source ? {
106+
true => Resource['tomcat::install::source', $name],
107+
default => Resource['tomcat::install::package', $package_name]
108+
}
109+
}
110+
}
111+
}
94112
}

spec/acceptance/acceptance_1_readme_spec.rb

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
class { 'java': }
4242
4343
tomcat::install { '/opt/tomcat9':
44-
source_url => '#{TOMCAT9_RECENT_SOURCE}'
44+
source_url => '#{TOMCAT9_RECENT_SOURCE}',
4545
}
4646
tomcat::instance { 'tomcat9-first':
4747
catalina_home => '/opt/tomcat9',
@@ -103,4 +103,29 @@ class { 'java': }
103103
end
104104
end
105105
end
106+
107+
describe 'remove webapps built-in files' do
108+
after :each do
109+
run_shell('pkill -f tomcat', expect_failures: true)
110+
run_shell('rm -rf /opt/tomcat*', expect_failures: true)
111+
run_shell('rm -rf /opt/apache-tomcat*', expect_failures: true)
112+
end
113+
{ '7' => TOMCAT7_RECENT_SOURCE, '8' => TOMCAT8_RECENT_SOURCE, '9' => TOMCAT9_RECENT_SOURCE }.each do |key, value|
114+
context "when tomcat #{key} is installed remove_default_webapps => ['docs', 'examples']" do
115+
install_tomcat = <<-MANIFEST
116+
tomcat::install { '/opt/tomcat#{key}':
117+
source_url => '#{value}',
118+
remove_default_webapps => ['docs', 'examples'],
119+
}
120+
MANIFEST
121+
it 'webapps should not contain the removed folder' do
122+
apply_manifest(install_tomcat, catch_failures: true)
123+
run_shell("ls -l /opt/tomcat#{key}/webapps") do |r|
124+
expect(r.stdout).not_to include('docs')
125+
expect(r.stdout).not_to include('examples')
126+
end
127+
end
128+
end
129+
end
130+
end
106131
end

0 commit comments

Comments
 (0)