DevOps Classroomnotes 26/Mar/2022

Continuing Tomcat Installation with Ansible

  • For the link for installing tomcat Refer Here
  • Refer Here for the list of ansible modules
  • Extract the tar file
sudo tar -xf /tmp/apache-tomcat-${VERSION}.tar.gz -C /opt/tomcat/
  • Refer Here for the changes done
  • Since the tar file is present on the ansible node, we have to remote_src Refer Here for the changes
  • Create a link to the new folder
sudo ln -s /opt/tomcat/apache-tomcat-${VERSION} /opt/tomcat/latest


* Now change the folder permissions

sudo chown -R tomcat: /opt/tomcat



* Change the permissions of all executables

sudo sh -c 'chmod +x /opt/tomcat/latest/bin/*.sh'
  • Written the ansible module to find all the shell files and print the files found. Refer Here
  • The result which we got is
{
        "changed": false,
        "examined": 27,
        "failed": false,
        "files": [
            {
                "atime": 1648301913.4882483,
                "ctime": 1648301913.5282478,
                "dev": 51713,
                "gid": 1002,
                "gr_name": "tomcat",
                "inode": 542158,
                "isblk": false,
                "ischr": false,
                "isdir": false,
                "isfifo": false,
                "isgid": false,
                "islnk": false,
                "isreg": true,
                "issock": false,
                "isuid": false,
                "mode": "0750",
                "mtime": 1646837545.0,
                "nlink": 1,
                "path": "/opt/tomcat/latest/bin/tool-wrapper.sh",
                "pw_name": "tomcat",
                "rgrp": true,
                "roth": false,
                "rusr": true,
                "size": 5540,
                "uid": 1002,
                "wgrp": false,
                "woth": false,
                "wusr": true,
                "xgrp": true,
                "xoth": false,
                "xusr": true
            },
            {
                "atime": 1648301913.4882483,
                "ctime": 1648301913.5282478,
                "dev": 51713,
                "gid": 1002,
                "gr_name": "tomcat",
                "inode": 542156,
                "isblk": false,
                "ischr": false,
                "isdir": false,
                "isfifo": false,
                "isgid": false,
                "islnk": false,
                "isreg": true,
                "issock": false,
                "isuid": false,
                "mode": "0750",
                "mtime": 1646837545.0,
                "nlink": 1,
                "path": "/opt/tomcat/latest/bin/shutdown.sh",
                "pw_name": "tomcat",
                "rgrp": true,
                "roth": false,
                "rusr": true,
                "size": 1902,
                "uid": 1002,
                "wgrp": false,
                "woth": false,
                "wusr": true,
                "xgrp": true,
                "xoth": false,
                "xusr": true
            },
            {
                "atime": 1648301913.4882483,
                "ctime": 1648301913.5282478,
                "dev": 51713,
                "gid": 1002,
                "gr_name": "tomcat",
                "inode": 542157,
                "isblk": false,
                "ischr": false,
                "isdir": false,
                "isfifo": false,
                "isgid": false,
                "islnk": false,
                "isreg": true,
                "issock": false,
                "isuid": false,
                "mode": "0750",
                "mtime": 1646837545.0,
                "nlink": 1,
                "path": "/opt/tomcat/latest/bin/startup.sh",
                "pw_name": "tomcat",
                "rgrp": true,
                "roth": false,
                "rusr": true,
                "size": 1904,
                "uid": 1002,
                "wgrp": false,
                "woth": false,
                "wusr": true,
                "xgrp": true,
                "xoth": false,
                "xusr": true
            },
            {
                "atime": 1648301913.4882483,
                "ctime": 1648301913.5282478,
                "dev": 51713,
                "gid": 1002,
                "gr_name": "tomcat",
                "inode": 542150,
                "isblk": false,
                "ischr": false,
                "isdir": false,
                "isfifo": false,
                "isgid": false,
                "islnk": false,
                "isreg": true,
                "issock": false,
                "isuid": false,
                "mode": "0750",
                "mtime": 1646837545.0,
                "nlink": 1,
                "path": "/opt/tomcat/latest/bin/ciphers.sh",
                "pw_name": "tomcat",
                "rgrp": true,
                "roth": false,
                "rusr": true,
                "size": 1997,
                "uid": 1002,
                "wgrp": false,
                "woth": false,
                "wusr": true,
                "xgrp": true,
                "xoth": false,
                "xusr": true
            },
            {
                "atime": 1648301913.4882483,
                "ctime": 1648301913.5282478,
                "dev": 51713,
                "gid": 1002,
                "gr_name": "tomcat",
                "inode": 542152,
                "isblk": false,
                "ischr": false,
                "isdir": false,
                "isfifo": false,
                "isgid": false,
                "islnk": false,
                "isreg": true,
                "issock": false,
                "isuid": false,
                "mode": "0750",
                "mtime": 1646837545.0,
                "nlink": 1,
                "path": "/opt/tomcat/latest/bin/daemon.sh",
                "pw_name": "tomcat",
                "rgrp": true,
                "roth": false,
                "rusr": true,
                "size": 9100,
                "uid": 1002,
                "wgrp": false,
                "woth": false,
                "wusr": true,
                "xgrp": true,
                "xoth": false,
                "xusr": true
            },
            {
                "atime": 1648301913.4882483,
                "ctime": 1648301913.5282478,
                "dev": 51713,
                "gid": 1002,
                "gr_name": "tomcat",
                "inode": 542151,
                "isblk": false,
                "ischr": false,
                "isdir": false,
                "isfifo": false,
                "isgid": false,
                "islnk": false,
                "isreg": true,
                "issock": false,
                "isuid": false,
                "mode": "0750",
                "mtime": 1646837545.0,
                "nlink": 1,
                "path": "/opt/tomcat/latest/bin/configtest.sh",
                "pw_name": "tomcat",
                "rgrp": true,
                "roth": false,
                "rusr": true,
                "size": 1922,
                "uid": 1002,
                "wgrp": false,
                "woth": false,
                "wusr": true,
                "xgrp": true,
                "xoth": false,
                "xusr": true
            },
            {
                "atime": 1648301913.4882483,
                "ctime": 1648301913.5282478,
                "dev": 51713,
                "gid": 1002,
                "gr_name": "tomcat",
                "inode": 542159,
                "isblk": false,
                "ischr": false,
                "isdir": false,
                "isfifo": false,
                "isgid": false,
                "islnk": false,
                "isreg": true,
                "issock": false,
                "isuid": false,
                "mode": "0750",
                "mtime": 1646837545.0,
                "nlink": 1,
                "path": "/opt/tomcat/latest/bin/version.sh",
                "pw_name": "tomcat",
                "rgrp": true,
                "roth": false,
                "rusr": true,
                "size": 1908,
                "uid": 1002,
                "wgrp": false,
                "woth": false,
                "wusr": true,
                "xgrp": true,
                "xoth": false,
                "xusr": true
            },
            {
                "atime": 1648301913.4882483,
                "ctime": 1648301913.5282478,
                "dev": 51713,
                "gid": 1002,
                "gr_name": "tomcat",
                "inode": 542149,
                "isblk": false,
                "ischr": false,
                "isdir": false,
                "isfifo": false,
                "isgid": false,
                "islnk": false,
                "isreg": true,
                "issock": false,
                "isuid": false,
                "mode": "0750",
                "mtime": 1646837545.0,
                "nlink": 1,
                "path": "/opt/tomcat/latest/bin/catalina.sh",
                "pw_name": "tomcat",
                "rgrp": true,
                "roth": false,
                "rusr": true,
                "size": 25294,
                "uid": 1002,
                "wgrp": false,
                "woth": false,
                "wusr": true,
                "xgrp": true,
                "xoth": false,
                "xusr": true
            },
            {
                "atime": 1648301913.4882483,
                "ctime": 1648301913.5282478,
                "dev": 51713,
                "gid": 1002,
                "gr_name": "tomcat",
                "inode": 542153,
                "isblk": false,
                "ischr": false,
                "isdir": false,
                "isfifo": false,
                "isgid": false,
                "islnk": false,
                "isreg": true,
                "issock": false,
                "isuid": false,
                "mode": "0750",
                "mtime": 1646837545.0,
                "nlink": 1,
                "path": "/opt/tomcat/latest/bin/digest.sh",
                "pw_name": "tomcat",
                "rgrp": true,
                "roth": false,
                "rusr": true,
                "size": 1965,
                "uid": 1002,
                "wgrp": false,
                "woth": false,
                "wusr": true,
                "xgrp": true,
                "xoth": false,
                "xusr": true
            },
            {
                "atime": 1648301913.4882483,
                "ctime": 1648301913.5282478,
                "dev": 51713,
                "gid": 1002,
                "gr_name": "tomcat",
                "inode": 542154,
                "isblk": false,
                "ischr": false,
                "isdir": false,
                "isfifo": false,
                "isgid": false,
                "islnk": false,
                "isreg": true,
                "issock": false,
                "isuid": false,
                "mode": "0750",
                "mtime": 1646837545.0,
                "nlink": 1,
                "path": "/opt/tomcat/latest/bin/makebase.sh",
                "pw_name": "tomcat",
                "rgrp": true,
                "roth": false,
                "rusr": true,
                "size": 3382,
                "uid": 1002,
                "wgrp": false,
                "woth": false,
                "wusr": true,
                "xgrp": true,
                "xoth": false,
                "xusr": true
            },
            {
                "atime": 1648301913.4882483,
                "ctime": 1648301913.5282478,
                "dev": 51713,
                "gid": 1002,
                "gr_name": "tomcat",
                "inode": 542155,
                "isblk": false,
                "ischr": false,
                "isdir": false,
                "isfifo": false,
                "isgid": false,
                "islnk": false,
                "isreg": true,
                "issock": false,
                "isuid": false,
                "mode": "0750",
                "mtime": 1646837545.0,
                "nlink": 1,
                "path": "/opt/tomcat/latest/bin/setclasspath.sh",
                "pw_name": "tomcat",
                "rgrp": true,
                "roth": false,
                "rusr": true,
                "size": 3708,
                "uid": 1002,
                "wgrp": false,
                "woth": false,
                "wusr": true,
                "xgrp": true,
                "xoth": false,
                "xusr": true
            }
        ]
}
  • We need to iterate this list of files now and for every file we need to add execute permission
  • Loops in Ansible Refer Here
  • Lets run some examples
---
- name: loops demo
  hosts: all
  gather_facts: no
  tasks:
    - debug: 
        msg: "{{ item }}"
      loop:
        - Ansible
        - Kubernetes


* Refer Here for the changes done
* Now execute the playbook and verify the permissions of the shell files

* Now we need to create a SystemD unit file Refer Here

  • Refer Here for copy module and Refer Here
  • Refer Here for the changes done to install tomcat and enable, start tomcat service
  • Execute the playbook and access the http://<public-ip-node>:8080
  • Exercise: Refer Here for the documentation. Install Open JDK 11 on redhat 7 and install the tomcat 9 by following steps.
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

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

Please turn AdBlock off
Customized Social Media Icons from Acurax Digital Marketing Agency

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%%