DevOps Classroom notes 15/Mar/2025

Templates

Lets try to configure the tomcat manager app

Manual Steps

Configuring the Tomcat 10 Manager App on Ubuntu 22.04 involves several steps, including setting up user roles and modifying configuration files to allow access to the Manager and Host Manager interfaces. Here’s a step-by-step guide:

Step 1: Install Java and Tomcat

First, ensure you have Java installed. Tomcat 10 requires JDK 11 or later.

sudo apt update
sudo apt install default-jdk

Next, download and install Tomcat 10:

wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.10/bin/apache-tomcat-10.1.10.tar.gz
sudo tar xzvf apache-tomcat-10.1.10.tar.gz -C /opt/
sudo mv /opt/apache-tomcat-10.1.10 /opt/tomcat

Step 2: Create a Tomcat User

Create a user for Tomcat to run under:

sudo useradd -m -d /opt/tomcat -U -s /bin/false tomcat

Step 3: Set Permissions

Set the ownership and permissions for the Tomcat directory:

sudo chown -RH tomcat:tomcat /opt/tomcat
sudo sh -c 'chmod +x /opt/tomcat/bin/*.sh'

Step 4: Configure Tomcat Service

Create a systemd service file for Tomcat:

sudo nano /etc/systemd/system/tomcat.service

Paste the following configuration:

[Unit]
Description=Apache Tomcat 10 Web Application Server
After=network.target

[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

Save and close the file.

Step 5: Reload and Start Tomcat Service

Reload the systemd daemon and start the Tomcat service:

sudo systemctl daemon-reload
sudo systemctl start tomcat
sudo systemctl enable tomcat

Step 6: Configure Tomcat Manager App

To access the Tomcat Manager App, you need to configure user roles. Edit the tomcat-users.xml file:

sudo nano /opt/tomcat/conf/tomcat-users.xml

Add the following lines before the closing “ tag:




Replace your_password with a strong password.

Step 7: Allow Remote Access

By default, Tomcat restricts access to the Manager and Host Manager. To allow remote access, edit the context.xml files for both:

  1. Manager App:
    bash
    sudo nano /opt/tomcat/webapps/manager/META-INF/context.xml
  2. Host Manager:
    bash
    sudo nano /opt/tomcat/webapps/host-manager/META-INF/context.xml

In both files, comment out the line that restricts access to the server’s IP:

xml
-->

Step 8: Restart Tomcat

Restart the Tomcat service to apply the changes:

sudo systemctl restart tomcat

Step 9: Access Tomcat Manager App

Now, you can access the Tomcat Manager App by navigating to http://your_server_ip:8080/manager in your web browser. Use the username and password you configured in tomcat-users.xml.

Citations:
[1] https://www.atlantic.net/dedicated-server-hosting/how-to-install-tomcat-10-on-ubuntu-22-04/
[2] https://tecadmin.net/how-to-install-tomcat-on-ubuntu-22-04/
[3] https://phoenixnap.com/kb/install-tomcat-ubuntu
[4] https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-10-on-ubuntu-20-04
[5] https://www.rosehosting.com/blog/how-to-install-tomcat-on-ubuntu-22-04/
[6] https://www.youtube.com/watch?v=m_9QNRHnL0E
[7] https://linuxize.com/post/how-to-install-tomcat-10-on-ubuntu-22-04/
[8] https://utho.com/docs/linux/ubuntu/how-to-install-tomcat-on-ubuntu/

In Ansible

Preview

  • Adopting the playbook to run on redhat Refer Here for the changes
  • deploying applications into tomcat. Any java application which has a war file, As an example lets use jenkins Refer Here for the steps

Reusability in Ansible

  • On a broader note we have two types of reusability possible
    • reusable yaml files:
      • roles
      • collections
    • reusable modules: This requires you to develop modules in python language
  • There are lot of community roles and collections hosted on Ansible Galaxy

Exercise:

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

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

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

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

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube