Coder Social home page Coder Social logo

tomcat-ansible's Introduction

Role info

Ansible Role to Install Tomcat on CentOS, Fedora, Debian and Ubuntu Linux. This works for any version of Tomcat: https://computingforgeeks.com/install-tomcat-on-ubuntu-centos-with-ansible/

Tested on the following operating systems

  • CentOS 8
  • CentOS 7
  • Fedora 39
  • Ubuntu 22.04/20.04/18.04
  • Debian 12/11/10

Tasks in the role

This role contains tasks to:

  • Install basic packages required
  • Install Java
  • Add tomcat user and group
  • Download tomcat and install - configure systemd
  • Configure firewall

How to use this role

  • Clone the Project:
$ git clone https://github.com/jmutai/tomcat-ansible.git
$ cd tomcat-ansible
  • Update your inventory, e.g:
$ vim hosts
[tomcat_nodes]
192.168.10.20       # Remote user to act on
  • Update variables in playbook file - Set Tomcat version, remote user and Tomcat UI access credentials
  • Update ansible.cfg file if necessary
$ vim tomcat-setup.yml
---
- name: Tomcat deployment playbook
  hosts: tomcat_nodes       # Inventory hosts group / server to act on
  become: yes               # If to escalate privilege
  become_method: sudo       # Set become method
  remote_user: root         # Update username for remote server
  vars:
    tomcat_ver: 10.1.19                         # 9.0.64 - Tomcat full version number to install, see https://archive.apache.org/dist/tomcat/
    tomcat_v_num: 10                            # Tomcat major release number, e.g 10 or 9
    ui_manager_user: manager                    # User who can access the UI manager section only
    ui_manager_pass: Str0ngManagerP@ssw3rd      # UI manager user password
    ui_admin_username: admin                    # User who can access bpth manager and admin UI sections
    ui_admin_pass: Str0ngAdminP@ssw3rd          # UI admin password
  roles:
    - tomcat

If you are using non root remote user, then set username and enable sudo:

become: yes
become_method: sudo

Running Playbook

Once all values are updated, you can then run the playbook against your nodes.

Playbook executed as root user - with ssh key:

$ ansible-playbook -i hosts tomcat-setup.yml

Playbook executed as root user - with password:

$ ansible-playbook -i hosts tomcat-setup.yml --ask-pass

Playbook executed as sudo user - with password:

$ ansible-playbook -i hosts tomcat-setup.yml --ask-pass --ask-become-pass

Playbook executed as sudo user - with ssh key and sudo password:

$ ansible-playbook -i hosts tomcat-setup.yml --ask-become-pass

Playbook executed as sudo user - with ssh key and passwordless sudo:

$ ansible-playbook -i hosts tomcat-setup.yml --ask-become-pass

Execution should be successful without errors:

tomcat-ansible's People

Contributors

jmutai avatar trust914 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

tomcat-ansible's Issues

Failed to start Tomcat

Hello Josphat,

Apologies for being the first one to report an issue... :-)

Unfortunately something does not work as expected here on a freshly installed CentOS 8 VM...

Sep 07 15:09:10 foobar01 systemd[1]: Starting Tomcat...
Sep 07 15:09:10 foobar01 catalina.sh[8673]: touch: cannot touch '/opt/tomcat/logs/catalina.out': Permission denied
Sep 07 15:09:10 foobar01 catalina.sh[8673]: /opt/tomcat/bin/catalina.sh: line 505: /opt/tomcat/logs/catalina.out: Permission denied
Sep 07 15:09:10 foobar01 systemd[1]: tomcat.service: Control process exited, code=exited status=1
Sep 07 15:09:10 foobar01 systemd[1]: tomcat.service: Failed with result 'exit-code'.
Sep 07 15:09:10 foobar01 systemd[1]: Failed to start Tomcat.

These are the permissions fpr the logs directory:

[root@foobar01 ~]# ls -ld /opt/tomcat/logs/
drwxr-x---. 2 tomcat9 tomcat 6 Jun 30 22:09 /opt/tomcat/logs/
[root@foobar01 ~]#

Any ideas?

Thanks in advance!

Best,
Martin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.