Closed ArturoBenavente closed 7 years ago
Thanks for reporting this @ArturoBenavente.
The behaviour of *_path
variables is a bit confusing at first if you're installing tomcat from packages. Let me explain:
Distro packages come with their own startup script(s) and expect the tomcat configuration to be installed in a specific location. On RedHat / SuSE this location is /etc/sysconfig/tomcat
. This is defined inside /usr/lib/systemd/system/tomcat.service
(RHEL 7) or /etc/init.d/tomcat6
(RHEL 6).
The config_path
class parameter is used to define where the config should be written by Puppet, not to tell tomcat where to find it, which would involve overwriting the scripts that come with the package, and I want to avoid changing the package files as much as I can. I could implement it but most likely the changes would get overwritten the next time you update your tomcat package.
In short, config_path
is only relevant if you install tomcat from the Tomcat archives (see install_from
parameter), or if you deploy custom RPMs that already uses a custom config path.
Besides, on RedHat /etc/tomcat/tomcat.conf
(or /etc/tomcat6/tomcat6.conf
) is already blanked by the module, so this file can not interfere with your own options. Only the file in /etc/sysconfig
matters as described above.
May I have more details about that RPM you are using? Is it the one from your distribution or a custom one? On which distribution? Looking forward to more details from your side on what you are trying to achieve.
ping @ArturoBenavente
Sorry for the delay. I'm using a tomcat RPM from de distribution (SLES12-SP1), Version: 8.0.36-11.4 In this version, the tomcat service (/usr/lib/systemd/system/tomcat.service) uses the start/stop script /usr/lib/tomcat/server, which has declared the environmet file /usr/lib/tomcat/preamble. This file has following code fragment:
if [ -z "${TOMCAT_CFG_LOADED}" ]; then
if [ -z "${TOMCAT_CFG}" ]; then
TOMCAT_CFG="/etc/tomcat/tomcat.conf"
fi
. $TOMCAT_CFG
fi
For this reason, if the environment variable TOMCAT_CFG_LOADED isn't defined ( neither the variable TOMCAT_CFG ), the start of tomcat always uses de environment file /etc/tomcat/tomcat.conf, with the default paths. I've managed to avoid loading this file configuring the environment variable TOMCAT_CFG_LOADED in the /etc/sysconfig/tomcat file. To achieve this, I have used the parameter 'custom_variable's of the define tomcat::instance. Example:
tomcat::instance { $instance[name]:
...
custom_variables => { 'TOMCAT_CFG_LOADED' => '1'},
}
Thank's for all
Thanks for investigating @ArturoBenavente, that's very helpful 👍
I didn't test extensively on SLES lately but here is what the module uses by default:
package_name
=> "tomcat"service_name
=> "${package_name}"config_path
=> "/etc/${service_name}/${service_name}.conf"If you don't set any of these parameters, you configuration will by written to /etc/tomcat/tomcat.conf
, which is what the /usr/lib/tomcat/preamble
script is expecting.
At that point if you really want to use a different config_path
the best thing you can do is:
set config_path
in your class parameters as you already did:
class { 'tomcat':
config_path => "/apps/tomcat/tomcat.conf"
}
override the content of /etc/tomcat/tomcat.conf
as follows:
file { '/etc/tomcat/tomcat.conf':
ensure => present,
content => "TOMCAT_CFG=\"/apps/tomcat/tomcat.conf\"\n"
}
Make sure you don't have a file in /etc/sysconfig/tomcat
!
This way systemd keeps setting the environment from /etc/tomcat/tomcat.conf
, but the preamble
script loads /apps/tomcat/tomcat.conf
before starting tomcat.
I think this does exactly what you're looking for.
ping @ArturoBenavente Feel free to close if this answers your question, or to comment if needed.
Thank you very much for your module. We are using it in our installation. We open this issue because we want to inform you that, we have needed to change the default path defined in the rpm installation. The way we have found to change this has been to create another config_path config_path => "/apps/tomcat/tomcat.conf" but additionally it is needed to erase the file /etc/tomcat/tomcat.conf, because if this file exists the service start only using this file and this file overwrite any other environment configuration.