DevOps Classroom Series – 27/Jan/2021

Automating tomcat contd..

  • Now we need to create a file in the location /etc/systemd/system/tomcat.service with the following contents
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64
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'

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target
  • This file has variable data (username, group, JAVA_HOME), so this is dynamic file. If this file is static we would have use (chef generate file) and used cookbook_file resource to copy the file
  • To create dynamic files in chef we have templates Refer Here for templates guide and Refer Here for template resources
  • Now lets generate a template
  • Refer Here for the changeset and perform kitchen converge
  • Lets look at service file
  • Now lets browse to tomcat web page
  • Now lets create a template for tomcat-users.xml and also create context.xml file and do the convergence. Refer Here for the changeset
  • Now verify if the host manager and manager app are accessible by providing username and passwords
  • Now as a last step lets deploy a sample java application from Refer Here into /opt/tomcat/webapps/gameoflife.war
  • Refer Here for the changeset
  • Exercise: Make this cookbook work on redhat or centos

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Network Integration by Acurax Social Media Branding Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%