{"id":1217,"date":"2020-12-25T02:41:36","date_gmt":"2020-12-25T02:41:36","guid":{"rendered":"https:\/\/www.nicktailor.com\/?p=1217"},"modified":"2022-10-21T11:22:32","modified_gmt":"2022-10-21T11:22:32","slug":"how-to-add-your-custom-tomcat-installation-to-systemd-with-ansible","status":"publish","type":"post","link":"https:\/\/nicktailor.com\/tech-blog\/how-to-add-your-custom-tomcat-installation-to-systemd-with-ansible\/","title":{"rendered":"How to add a custom tomcat installation to SystemD with ansible."},"content":{"rendered":"<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\">Okay so say you have a custom install of tomcat and java, which is what a lot of people do because java update and tomcat updates can bring things down. So things need to be tested before updates and standard patch cycles can end up affecting the environment.<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\">But you want to handle the startup and stopping via systemd to be able to get status outputs and let system handle the service on reboots. This is how to do it slick.<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><strong>Ansible Setup:<\/strong><\/p>\n<div class=\"ul\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3; margin-left: 36pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt;\"><span style=\"position: absolute; top: -0.34em; left: 0; font-size: 2em;\">\u2022<\/span>&nbsp;<\/span>This post assumes you have ansible setup and running. If you don\u2019t search through my blog and you should find a post on how to setup.<\/div>\n<\/div>\n<\/div>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><strong>Role: <\/strong><\/p>\n<div class=\"ul\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3; margin-left: 36pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt;\"><span style=\"position: absolute; top: -0.34em; left: 0; font-size: 2em;\">\u2022<\/span>&nbsp;<\/span>We are going to setup a custom role to add your custom tomcat install system<\/div>\n<\/div>\n<\/div>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><strong>Setup the new role:<\/strong><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<div class=\"ul\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0; padding-bottom: 0; line-height: 1.3; margin-left: 36pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt;\"><span style=\"position: absolute; top: -0.34em; left: 0; font-size: 2em;\">\u2022<\/span>&nbsp;<\/span>Create a new directory in \/etc\/ansible\/role for your new role<\/div>\n<div class=\"ul\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3; margin-left: 72pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; font-style: italic; font-weight: bold; color: #ff0000;\"><span style=\"position: absolute; top: -0.37em; left: 0; font-size: 2em;\">\u25e6<\/span>&nbsp;<\/span><strong><span style=\"color: #ff0000;\"><em>mkdir<\/em><\/span><span style=\"color: #ff0000;\"><em> -p \/etc\/ansible\/roles\/<\/em><\/span><span style=\"color: #ff0000;\"><em>AddtomcatSystemD<\/em><\/span><span style=\"color: #ff0000;\"><em>\/tasks\/<\/em><\/span><\/strong><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<div class=\"ul\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0; padding-bottom: 0; line-height: 1.3; margin-left: 36pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt;\"><span style=\"position: absolute; top: -0.34em; left: 0; font-size: 2em;\">\u2022<\/span>&nbsp;<\/span>Now create a yaml file that will run a set of tasks to set this up for ya.<\/div>\n<div class=\"ul\" style=\"margin: 0;\">\n<div class=\"li\" style=\"margin: 0;\">\n<div style=\"margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3; margin-left: 72pt;\"><span style=\"display: inline-block; position: relative; text-indent: -18pt; font-style: italic; font-weight: bold; color: #ff0000;\"><span style=\"position: absolute; top: -0.37em; left: 0; font-size: 2em;\">\u25e6<\/span>&nbsp;<\/span><strong><span style=\"color: #ff0000;\"><em>vi <\/em><\/span><span style=\"color: #ff0000;\"><em>main.yml<\/em><\/span><\/strong><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #000000;\">Main.yml<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"color: #000000;\">===========================================<\/span><\/p>\n<p><strong><span style=\"color: #000000;\">Note: this will install the <\/span><span style=\"color: #000000;\">redhat<\/span><span style=\"color: #000000;\"> tomcat version of tomcat. Do not worry we are not going to be using this tomcat. This is just so <\/span><span style=\"color: #000000;\">redhat<\/span><span style=\"color: #000000;\"> automatically setups all the needed services and locations. We will then update the <\/span><span style=\"color: #000000;\">SystemD<\/span><span style=\"color: #000000;\"> config for tomcat to use the custom version.<\/span><\/strong><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&#8211; name: Install the latest version of tomcat<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> package:<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> name: tomcat<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> state: latest<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><strong><span style=\"color: #000000;\">Note: This <\/span><span style=\"color: #000000;\">symlink<\/span><span style=\"color: #000000;\"> is important as tomcat default install by <\/span><span style=\"color: #000000;\">redhat<\/span><span style=\"color: #000000;\"> is inside \/opt\/tomcat. Update the <\/span><span style=\"color: #000000;\">src<\/span><span style=\"color: #000000;\"> to the custom location of your tomcat<\/span><\/strong><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&#8211; name: Create symbolic link for &#8220;tomcat&#8221; in \/opt<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> file:<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #00b0f0;\">src<\/span><span style=\"color: #00b0f0;\">: \/<\/span><span style=\"color: #00b0f0;\">custom\/install\/tomcat<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> path: \/opt\/tomcat<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> force: yes<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> state: link<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><strong><span style=\"color: #000000;\">Note: This will enable tomcat to start up on reboot<\/span><\/strong><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&#8211; name: Enable tomcat service on <\/span><span style=\"color: #00b0f0;\">startup<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> shell: <\/span><span style=\"color: #00b0f0;\">systemctl<\/span><span style=\"color: #00b0f0;\"> enable tomcat<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><strong><span style=\"color: #000000;\">Note: This is the tomcat <\/span><span style=\"color: #000000;\">systemd<\/span><span style=\"color: #000000;\"> service file that <\/span><span style=\"color: #000000;\">systemd<\/span><span style=\"color: #000000;\"> uses for the default install. We are going to empty.<\/span><\/strong><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&#8211; name: Null <\/span><span style=\"color: #00b0f0;\">tomcat.service<\/span><span style=\"color: #00b0f0;\"> file<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> shell: &#8220;&gt;\/etc\/<\/span><span style=\"color: #00b0f0;\">systemd<\/span><span style=\"color: #00b0f0;\">\/system\/<\/span><span style=\"color: #00b0f0;\">tomcat.service<\/span><span style=\"color: #00b0f0;\">&#8220;<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><strong><span style=\"color: #000000;\">Note: We are now going to add our custom block for tomcat into the <\/span><span style=\"color: #000000;\">tomcat.service<\/span><span style=\"color: #000000;\"> file we just emptied above using the <\/span><span style=\"color: #000000;\">blockinfle<\/span><span style=\"color: #000000;\"> module. This means that this whole section will also be managed by ansible as well. Make sure you adjust the <\/span><span style=\"color: #000000;\">java_home<\/span><span style=\"color: #000000;\"> if your java <\/span><span style=\"color: #000000;\">isn\u2019t<\/span><span style=\"color: #000000;\"> location inside tomcat. Along with the <\/span><span style=\"color: #000000;\">user<\/span><span style=\"color: #000000;\">,group<\/span><span style=\"color: #000000;\">,umask<\/span><span style=\"color: #000000;\"> for <\/span><span style=\"color: #000000;\">to your <\/span><span style=\"color: #000000;\">custom tomcat<\/span><span style=\"color: #000000;\">.<\/span> <\/strong><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&#8211; name: Edit <\/span><span style=\"color: #00b0f0;\">tomcat.service<\/span><span style=\"color: #00b0f0;\"> for <\/span><span style=\"color: #00b0f0;\">systemd<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;<\/span><span style=\"color: #00b0f0;\">blockinfile<\/span><span style=\"color: #00b0f0;\">:<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #00b0f0;\">dest<\/span><span style=\"color: #00b0f0;\">: \/etc\/<\/span><span style=\"color: #00b0f0;\">systemd<\/span><span style=\"color: #00b0f0;\">\/system\/<\/span><span style=\"color: #00b0f0;\">tomcat.service<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #00b0f0;\">insertafter<\/span><span style=\"color: #00b0f0;\">:<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> block: |<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> [Unit]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> Description=Apache Tomcat Web Application Container<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> After=<\/span><span style=\"color: #00b0f0;\">syslog.target<\/span> <span style=\"color: #00b0f0;\">network.target<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> [Service]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> Type=forking<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> Environment=JAVA_HOME=\/opt\/tomcat<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> Environment=CATALINA_PID=\/opt\/tomcat\/temp\/<\/span><span style=\"color: #00b0f0;\">tomcat.pid<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> Environment=CATALINA_HOME=\/opt\/tomcat<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> Environment=CATALINA_BASE=\/opt\/tomcat<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> Environment=&#8217;CATALINA_OPTS=-Xms512M -Xmx1024M -server &#8211;<\/span><span style=\"color: #00b0f0;\">XX:+<\/span><span style=\"color: #00b0f0;\">UseParallelGC<\/span><span style=\"color: #00b0f0;\">&#8216;<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> Environment=&#8217;JAVA_OPTS=-<\/span><span style=\"color: #00b0f0;\">Djava.awt.headless<\/span><span style=\"color: #00b0f0;\">=true &#8211;<\/span><span style=\"color: #00b0f0;\">Djava.security.egd<\/span><span style=\"color: #00b0f0;\">=file:\/dev\/.\/<\/span><span style=\"color: #00b0f0;\">urandom<\/span><span style=\"color: #00b0f0;\">&#8216;<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> ExecStart=\/opt\/tomcat\/bin\/startup.sh<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #00b0f0;\">ExecStop<\/span><span style=\"color: #00b0f0;\">=\/bin\/kill -15 $MAINPID<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> User=<\/span><span style=\"color: #00b0f0;\">tomcat<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> Group=<\/span><span style=\"color: #00b0f0;\">tomcat<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #00b0f0;\">UMask<\/span><span style=\"color: #00b0f0;\">=<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #00b0f0;\">RestartSec<\/span><span style=\"color: #00b0f0;\">=10<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> Restart=always<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> [Install]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #00b0f0;\">WantedBy<\/span><span style=\"color: #00b0f0;\">=multi-<\/span><span style=\"color: #00b0f0;\">user.target<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><strong><span style=\"color: #000000;\">Note: This will then reload the custom tomcat via <\/span><span style=\"color: #000000;\">systemd<\/span><\/strong><\/p>\n<p><span style=\"color: #00b0f0;\">&#8211; name: Start tomcat service with <\/span><span style=\"color: #00b0f0;\">Systemd<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;<\/span><span style=\"color: #00b0f0;\">systemd<\/span><span style=\"color: #00b0f0;\">: <\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> name: tomcat<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #00b0f0;\">daemon_<\/span><span style=\"color: #00b0f0;\">reload<\/span><span style=\"color: #00b0f0;\">:<\/span><span style=\"color: #00b0f0;\"> yes<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><strong><span style=\"color: #000000;\">Note: This will then check to see if the new tomcat is service running and out to the ansible playbook log.<\/span><\/strong><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;&nbsp;&nbsp;<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&#8211; name: get service facts<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&nbsp;&nbsp;<\/span><span style=\"color: #00b0f0;\">service_facts<\/span><span style=\"color: #00b0f0;\">:<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\">&#8211; name: Check to see if tomcat is running<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> debug:<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b0f0;\"> var: <\/span><span style=\"color: #00b0f0;\">ansible_<\/span><span style=\"color: #00b0f0;\">facts.services<\/span><span style=\"color: #00b0f0;\">[&#8220;<\/span><span style=\"color: #00b0f0;\">tomcat.service<\/span><span style=\"color: #00b0f0;\">&#8220;]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Ansibe playbook log:<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">[<\/span><span style=\"color: #00b050;\">root@<\/span><span style=\"color: #00b050;\">nickansible<\/span><span style=\"color: #00b050;\">]#<\/span><span style=\"color: #00b050;\"> ansible-playbook &#8211;<\/span><span style=\"color: #00b050;\">i<\/span><span style=\"color: #00b050;\"> i<\/span><span style=\"color: #00b050;\">nventory\/DEV\/hosts <\/span><span style=\"color: #00b050;\">justtomcatrole.yml<\/span><span style=\"color: #00b050;\"> &#8211;limit &#8216;<\/span><span style=\"color: #00b050;\">nicktestvm<\/span><span style=\"color: #00b050;\">&#8216; -k<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">SSH password:<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">PLAY [all] ************************************************************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">TASK [<\/span><span style=\"color: #00b050;\">AddTomCatSystemD<\/span><span style=\"color: #00b050;\"> : Create symbolic link for &#8220;tomcat&#8221; in \/opt] ***************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">changed: <\/span><span style=\"color: #00b050;\">nicktestvm<\/span><span style=\"color: #00b050;\">]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">TASK [<\/span><span style=\"color: #00b050;\">AddTomCatSystemD<\/span><span style=\"color: #00b050;\"> : Enable tomcat service on <\/span><span style=\"color: #00b050;\">startup<\/span><span style=\"color: #00b050;\">] ************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">changed: <\/span><span style=\"color: #00b050;\">nicktestvm<\/span><span style=\"color: #00b050;\">]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">TASK [<\/span><span style=\"color: #00b050;\">AddTomCatSystemD<\/span><span style=\"color: #00b050;\"> : Null <\/span><span style=\"color: #00b050;\">tomcat.service<\/span><span style=\"color: #00b050;\"> file] ********************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">changed: <\/span><span style=\"color: #00b050;\">nicktestvm<\/span><span style=\"color: #00b050;\">]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">TASK [<\/span><span style=\"color: #00b050;\">AddTomCatSystemD<\/span><span style=\"color: #00b050;\"> : Edit <\/span><span style=\"color: #00b050;\">tomcat.service<\/span><span style=\"color: #00b050;\"> for <\/span><span style=\"color: #00b050;\">systemd<\/span><span style=\"color: #00b050;\">] *************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">changed: <\/span><span style=\"color: #00b050;\">nicktestvm<\/span><span style=\"color: #00b050;\">]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">TASK [<\/span><span style=\"color: #00b050;\">AddTomCatSystemD<\/span><span style=\"color: #00b050;\"> : Start tomcat service with <\/span><span style=\"color: #00b050;\">Systemd<\/span><span style=\"color: #00b050;\">] ***********************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">ok: <\/span><span style=\"color: #00b050;\">nicktestvm<\/span><span style=\"color: #00b050;\">]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">TASK [<\/span><span style=\"color: #00b050;\">AddTomCatSystemD<\/span><span style=\"color: #00b050;\"> : get service facts] ***************************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">ok: <\/span><span style=\"color: #00b050;\">nicktestvm<\/span><span style=\"color: #00b050;\">]<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">TASK [<\/span><span style=\"color: #00b050;\">AddTomCatSystemD<\/span><span style=\"color: #00b050;\"> : Check to see if tomcat is running] ***********************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">ok: <\/span><span style=\"color: #00b050;\">nicktestvm<\/span><span style=\"color: #00b050;\">] =&gt; {<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\"> &#8220;<\/span><span style=\"color: #00b050;\">ansible_<\/span><span style=\"color: #00b050;\">facts.services<\/span><span style=\"color: #00b050;\">[\\&#8221;<\/span><span style=\"color: #00b050;\">tomcat.service<\/span><span style=\"color: #00b050;\">\\&#8221;]&#8221;: {<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\"> &#8220;name&#8221;: &#8220;<\/span><span style=\"color: #00b050;\">tomcat.service<\/span><span style=\"color: #00b050;\">&#8220;,<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\"> &#8220;source&#8221;: &#8220;<\/span><span style=\"color: #00b050;\">systemd<\/span><span style=\"color: #00b050;\">&#8220;,<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\"> &#8220;state&#8221;: &#8220;running&#8221;,<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\"> &#8220;status&#8221;: &#8220;enabled&#8221;<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\"> }<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">}<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">PLAY RECAP ************************************************************************************************************************************************************************************************<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">nicktestvm<\/span><span style=\"color: #00b050;\"> :<\/span><span style=\"color: #00b050;\"> ok=7 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0<\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">==========================<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">[root@nicktestvm ~]# cat \/etc\/systemd\/system\/tomcat.service<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><strong># BEGIN ANSIBLE MANAGED BLOCK<\/strong><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">[Unit]<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Description=Apache Tomcat Web Application Container<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">After=syslog.target network.target<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">[Service]<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Type=forking<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Environment=JAVA_HOME=\/opt\/tomcat<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Environment=CATALINA_PID=\/opt\/tomcat\/temp\/tomcat.pid<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Environment=CATALINA_HOME=\/opt\/tomcat<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Environment=CATALINA_BASE=\/opt\/tomcat<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Environment=&#8217;CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC&#8217;<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Environment=&#8217;JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:\/dev\/.\/urandom&#8217;<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">ExecStart=\/opt\/tomcat\/bin\/startup.sh<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">ExecStop=\/bin\/kill -15 $MAINPID<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">User=tomcat<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Group=tomcat<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">UMask=0028<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">RestartSec=10<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Restart=always<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">[Install]<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">WantedBy=multi-user.target<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><strong># END ANSIBLE MANAGED BLOCK<\/strong><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><strong><span style=\"color: #000000;\">SystemD<\/span><span style=\"color: #000000;\"> Status:<\/span><\/strong><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">root@nicktestvm ~]# systemctl status tomcat<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"color: #00b050;\">\u25cf <\/span>tomcat.service &#8211; Apache Tomcat Web Application Container<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Loaded: loaded (\/etc\/systemd\/system\/tomcat.service; enabled; vendor preset: disabled)<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Active:<span style=\"color: #00b050;\"> active <\/span>(running) since Thu 2020-12-24 05:11:21 GMT; 21h ago<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Process: 6333 ExecStop=\/bin\/kill -15 $MAINPID (code=exited, status=0\/SUCCESS)<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Process: 6353 ExecStart=\/opt\/tomcat\/bin\/startup.sh (code=exited, status=0\/SUCCESS)<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Main PID: 6363 (java)<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">&nbsp;&nbsp;&nbsp;CGroup: \/system.slice\/tomcat.service<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">\u2514\u25006363 \/usr\/local\/java\/java -Djava.util.logging.config.file=\/opt\/tomcat\/conf\/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -server -Xms1&#8230;<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Dec 24 05:11:21 nicktestvm systemd[1]: Starting Apache Tomcat Web Application Container&#8230;<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Dec 24 05:11:21 nicktestvm startup.sh[6353]: Existing PID file found during start.<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Dec 24 05:11:21 nicktestvm startup.sh[6353]: Removing\/clearing stale PID file.<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 0pt; padding-bottom: 0; line-height: 1.2;\">Dec 24 05:11:21 nicktestvm systemd[1]: Started Apache Tomcat Web Application Container.<\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n<p style=\"margin-top: 0pt; padding-top: 0; margin-bottom: 8pt; padding-bottom: 0; line-height: 1.3;\"><span style=\"display: inline-block; height: 1em;\"><span style=\"display: none;\">.<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Okay so say you have a custom install of tomcat and java, which is what a lot of people do because java update and tomcat updates can bring things down. So things need to be tested before updates and standard patch cycles can end up affecting the environment. But you want to handle the startup and stopping via systemd to<a href=\"https:\/\/nicktailor.com\/tech-blog\/how-to-add-your-custom-tomcat-installation-to-systemd-with-ansible\/\" class=\"read-more\">Read More &#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51,58,138],"tags":[],"class_list":["post-1217","post","type-post","status-publish","format-standard","hentry","category-ansible","category-centos","category-linux"],"_links":{"self":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/1217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/comments?post=1217"}],"version-history":[{"count":13,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/1217\/revisions"}],"predecessor-version":[{"id":1590,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/1217\/revisions\/1590"}],"wp:attachment":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/media?parent=1217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/categories?post=1217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/tags?post=1217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}