My task is to install a tomcat via chef. The only problem is, that my systemd_file (tomcat.service
) is implemented via the chef resource systemd_unit
. However, once I converge, the log warns me, that the key Environment
is duplicated and therefore overwritten.
In my older version, I simply implemented my tomcat.service
file via the cookbook_file
resource by chef, and it worked perfectly.
Where is the problem? How do I implement multiple Envrionment
-variables in the systemd_unit
resource?
systemd_unit service_file do
content({Unit: {
Description: 'Apache Tomcat Web Application Container',
After: 'syslog.target network.target',
},
Service: {
Type: 'forking',
Environment: 'JAVA_HOME=/usr/lib/jvm/jre',
Environment: 'CATALINA_PID=/opt/tomcat/temp/tomcat.pid',
Environment: 'CATALINA_HOME=/opt/tomcat',
Environment: 'CATALINA_BASE=/opt/tomcat',
Environment: 'CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC',
Environment: 'JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom',
Environment: 'PWM_APPLICATIONPATH=/opt/pwm-data',
ExecStart: '/opt/tomcat/bin/startup.sh',
ExecStop: '/bin/kill -15 $MAINPID',
User:tuser,
Group:tgroup,
UMask:'0007',
RestartSec:'10',
Restart:'always',
},
Install: {
WantedBy: 'multi-user.target',
}})
action :create
end
Reading the docs helps.
repeatable options can be implemented with an array.
That means i need to write
Environment: ['JAVA_HOME=/path/to/java', 'CATALINA_HOME=some/path', 'and so on']