我的任务是通过Chef安装tomcat。唯一的问题是,我的systemd_file(tomcat.service
)是通过厨师资源systemd_unit
实现的。但是,一旦收敛,日志就会警告我,密钥Environment
被复制并因此被覆盖。
在我的旧版本中,我只是通过厨师的tomcat.service
资源来实现cookbook_file
文件,并且运行良好。
问题出在哪里? 如何如何在Envrionment
资源中实现多个systemd_unit
变量?
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
答案 0 :(得分:0)
阅读docs有帮助。
repeatable options can be implemented with an array.
那意味着我需要写
Environment: ['JAVA_HOME=/path/to/java', 'CATALINA_HOME=some/path', 'and so on']