-
Notifications
You must be signed in to change notification settings - Fork 115
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
Missing dep for Red Hat source installation. Hostmanager and manager support. Handling of tomcat-users.xml #152
base: master
Are you sure you want to change the base?
Changes from all commits
d593255
a4de706
fba1836
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,10 @@ | |
# server.xml | ||
# - *catalina_logrotate*: install an UNMANAGED logrotate configuration file, | ||
# to handle the catalina.out file of the instance. Default to true. | ||
# - *hostmanager*: if "true" it will enable deploy of hostmanager webapp. | ||
# - *manager*: if "true" it will enable deploy of manager webapp. | ||
# - *users*: Array of hashes containing structure like [ {username => "user", password => "secret", roles="manager-gui,admin"} ], needed for hostmanager webapp. | ||
# - *roles*: Array of string containing roles to be placed in tomcat-users.xml, needed for hostmanager webapp. | ||
# | ||
# Requires: | ||
# - one of the tomcat classes which installs tomcat binaries. | ||
|
@@ -93,6 +97,21 @@ | |
# ], | ||
# } | ||
# | ||
# tomcat::instance { "bar": | ||
# ensure => present, | ||
# server_port => 8006, | ||
# http_port => 8081, | ||
# ajp_port => 8010, | ||
# users => [ | ||
# { | ||
# username => "myuser" | ||
# password => "mypassword" | ||
# roles => "manager-gui,admin" | ||
# } | ||
# ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing comma |
||
# roles => [ manager-gui, admin ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing comma |
||
# } | ||
# | ||
define tomcat::instance( | ||
$ensure = present, | ||
$owner = 'tomcat', | ||
|
@@ -123,6 +142,10 @@ | |
$tomcat_version = $tomcat::version, | ||
$catalina_logrotate = true, | ||
$java_opts = undef, | ||
$hostmanager = false, | ||
$manager = false, | ||
$users = [], | ||
$roles = [], | ||
) { | ||
|
||
Class['tomcat::install'] -> Tomcat::Instance[$title] | ||
|
@@ -156,6 +179,8 @@ | |
owner => $owner, | ||
sample => $sample, | ||
webapp_mode => $webapp_mode, | ||
hostmanager => $hostmanager, | ||
manager => $manager, | ||
} | ||
|
||
tomcat::instance::config { $title: | ||
|
@@ -184,6 +209,10 @@ | |
version => $version, | ||
web_xml_file => $web_xml_file, | ||
java_opts => $java_opts, | ||
hostmanager => $hostmanager, | ||
manager => $manager, | ||
users => $users, | ||
roles => $roles, | ||
} | ||
|
||
tomcat::instance::service { $title: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,10 @@ | |
$server_xml_file = undef, | ||
$web_xml_file = undef, | ||
$java_opts = undef, | ||
$hostmanager = false, | ||
$manager = false, | ||
$users = [], | ||
$roles = [], | ||
) { | ||
# lint:ignore:only_variable_string | ||
validate_re("${server_port}", '^[0-9]+$') | ||
|
@@ -34,6 +38,9 @@ | |
validate_array($setenv) | ||
validate_array($connector) | ||
validate_array($executor) | ||
validate_array($users) | ||
validate_array($roles) | ||
|
||
|
||
### | ||
# Configure connectors | ||
|
@@ -207,6 +214,64 @@ | |
mode => '0574', | ||
} | ||
|
||
### | ||
# Configure hostmanager & manager webapps | ||
# | ||
|
||
if !$tomcat::sources { | ||
$webapps_base = $::osfamily ? { | ||
'RedHat' => $::operatingsystemmajrelease ? { | ||
'7' => '/var/lib/tomcat/server/webapps', | ||
default => "/var/lib/tomcat${tomcat::version}/server/webapps", | ||
}, | ||
'Debian' => "/usr/share/tomcat${tomcat::version}-admin", | ||
} | ||
}else { | ||
$webapps_base = '/opt/apache-tomcat/webapps' | ||
} | ||
|
||
|
||
if $manager { | ||
file { "${catalina_base}/webapps/manager": | ||
ensure => link, | ||
target => "${webapps_base}/manager", | ||
} | ||
}elsif ($manage){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing spaces |
||
file { "${catalina_base}/webapps/manager": | ||
ensure => absent, | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather declare this file in one place only, and change the |
||
|
||
if $hostmanager { | ||
file { "${catalina_base}/webapps/host-manager": | ||
ensure => link, | ||
target => "${webapps_base}/host-manager", | ||
} | ||
}elsif ($manage){ | ||
file { "${catalina_base}/webapps/host-manager": | ||
ensure => absent, | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here as l.243 |
||
|
||
### | ||
# Configure users auth | ||
# | ||
if ($users or $roles){ | ||
file { "${catalina_base}/conf/tomcat-users.xml": | ||
ensure => file, | ||
owner => $owner, | ||
group => $group, | ||
mode => '0664', | ||
source => undef, | ||
content => template("${module_name}/tomcat-users.xml.erb"), | ||
replace => $manage, | ||
} | ||
}elsif (!$users and !$roles and $manage){ | ||
file { "${catalina_base}/conf/tomcat-users.xml": | ||
ensure => absent, | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and same here again |
||
|
||
### | ||
# Configure Init script | ||
# | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<!-- file created and managed by puppet --> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<tomcat-users> | ||
<!-- | ||
NOTE: By default, no user is included in the "manager-gui" role required | ||
to operate the "/manager/html" web application. If you wish to use this app, | ||
you must define such a user - the username and password are arbitrary. | ||
--> | ||
<!-- | ||
NOTE: The sample user and role entries below are wrapped in a comment | ||
and thus are ignored when reading this file. Do not forget to remove | ||
<!.. ..> that surrounds them. | ||
--> | ||
|
||
<% @roles.each do |role| -%> | ||
<role rolename="<%= role %>"/> | ||
<% end -%> | ||
|
||
<% @users.each do |userhash| -%> | ||
<user username="<%= userhash['username'] %>" password="<%= userhash['password'] %>" roles="<%= userhash['roles'] %>"/> | ||
<% end -%> | ||
|
||
</tomcat-users> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comma