DevOps Classroom notes 11/Aug/2025

Ansible contd..

Tomcat10 on ubuntu

  • Remaining manual steps are
  • create a service file with the following contents at /etc/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat 10 Web Application Container
After=network.target

[Service]
Type=forking

User=tomcat
Group=tomcat

Environment="JAVA_HOME=/usr/lib/jvm/java-17-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

[Install]
WantedBy=multi-user.target
  • Now enable and start tomcat
sudo systemctl daemon-reload
sudo systemctl start tomcat
sudo systemctl enable tomcat
  • Refer Here for the changes done to create a tomcat service by copying a static file.

Problems to be fixed

  • Re-execution of playbook ideally shouldn’t change anything if there are no changes.
  • But in our case it does
  • To fix this lets understand
  • Handler is a special kind of task that runs only when notified. Primary purposed is to trigger an action only on change.
  • To understand conditionals we need to know about ansible facts.

Ansible facts

  • Refer Here for official docs
  • Facts are information of remote nodes
  • By default facts are gather at the beginning of every playbook execution
  • There is a module called as setup which gathers the facts
  • Refer Here for a simple changes to view facts
  • Refer Here for sample output
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

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

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%