Activity 5: Install tomcat 10 server contd
sudo yum install java-11-openjdk -y
sudo useradd -m -U -d /opt/tomcat -s /bin/false tomcat
# create user with following information
# username = tomcat
# group = tomcat
# homedir = /opt/tomcat
# shell = /bin/false
MAJOR_VERSION="10"
VERSION="10.1.14"
wget "https://dlcdn.apache.org/tomcat/tomcat-${MAJOR_VERSION}/v${VERSION}/bin/apache-tomcat-${VERSION}.tar.gz" -P /tmp
# download tomcat tar to /tmp
# file path: /tmp/apache-tomcat-10.1.14.tar.gz
sudo tar -xf /tmp/apache-tomcat-${VERSION}.tar.gz -C /opt/tomcat/
# extract tar file to /opt/tomcat
sudo ln -s /opt/tomcat/apache-tomcat-${VERSION} /opt/tomcat/latest
# Create a link for /opt/tomcat/apache-tomcat-10.1.14 to /opt/tomcat/latest
sudo chown -R tomcat: /opt/tomcat
# transfer of ownership to tomcat user
sudo sh -c 'chmod +x /opt/tomcat/latest/bin/*.sh'
# Add execute permissions to all scripts in bin directory
-
apart for java installation rest of steps are same, Refer Here for the changes done to make this playbook work with redhat
-
Now we need to create a service file for ubuntu with the following contents in the file
/etc/systemd/system/tomcat.service
[Unit]
Description=Tomcat 10 servlet container
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom -Djava.awt.headless=true"
Environment="CATALINA_BASE=/opt/tomcat/latest"
Environment="CATALINA_HOME=/opt/tomcat/latest"
Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/opt/tomcat/latest/bin/startup.sh
ExecStop=/opt/tomcat/latest/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
- We have multiple values in the service which are dynamic so copying static file is not an option
- Refer Here for jinja templates
- Refer Here for jinja template and service file added into ubuntu
- Refer Here for the changes done to accomodate the same service file for both redhat and ubuntu
- Refer Here for handlers
Like this:
Like Loading...