Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Automate JBoss Web Server deployment with the Red Hat Certified Content Collection for JWS

December 22, 2022
Romain Pelisse
Related topics:
Automation and managementJavaLinux
Related products:
Red Hat Ansible Automation PlatformRed Hat JBoss Web Server

Share:

    According to several sources we queried, more than 33 percent of the world's web servers are running Apache Tomcat, while other sources show that it's 48 percent of application servers. Some of these instances have been containerized over the years, but many still run in the traditional setup of a virtual machine with Linux.

    Red Hat JBoss Web Server (JWS) combines a web server (Apache HTTPD), a servlet engine (Apache Tomcat), and modules for load balancing (mod_jk and mod_cluster). Ansible is an automation engine that provides a suite of tools for managing an enterprise at scale. In this article, we'll show how 1+1 becomes 11 by using Ansible to completely automate the deployment of a JBoss Web Server instance on a Red Hat Enterprise Linux 8 server.

    A prior article covered this subject, but now you can use the Red Hat certified content collection for JBoss Web Server, which has been available since the 5.7 release.

    In this article, you will automate a JBoss Web Server deployment through the following tasks:

    • Retrieve the archive containing the JBoss Web Server from a repository and install the files on the system.
    • Configure the Red Hat Enterprise Linux operating system, creating of users, groups, and the required setup files to enable JBoss Web Server as a systemd service.
    • Fine-tune the configuration of the JBoss Web Server server, such as binding it to the appropriate interface and port.
    • Deploy a web application and start the systemd service.
    • Perform a health check to ensure that the deployed application is accessible.

    Ansible fully automates all those operations, so no manual steps are required.

    Preparing the target environment

    Before you start the automation, you need to specify your target environment. In this case, you'll be using Red Hat Enterprise Linux 8 with Python 3.6. You'll use this setup on both the Ansible control node (where Ansible is executed) and the Ansible target (the system being configured).

    On the control node, confirm the following requirements:

    $ cat /etc/redhat-release
    
    Red Hat Enterprise Linux release 8.7 (Ootpa)
    
    $ ansible --version
    ansible [core 2.13.3]
      config file = /etc/ansible/ansible.cfg
      configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
      ansible python module location = /usr/lib/python3.9/site-packages/ansible
      ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
      executable location = /usr/bin/ansible
      python version = 3.9.13 (main, Nov  9 2022, 13:16:24) [GCC 8.5.0 20210514 (Red Hat 8.5.0-15)]
      jinja version = 3.1.2
      libyaml = True

    Note: The procedure in this article might not execute successfully if you use a different Python version or target operating system.

    Installing the Red Hat Ansible Certified Content Collection

    Once you have Red Hat Enterprise Linux 8 set up and Ansible ready to go, you need to install the Red Hat Ansible Certified Content Collection 1.2 for Red Hat JBoss Web Server. Ansible uses the collection to perform the following tasks on JBoss Web Server:

    • Ensure that the required system dependencies (e.g., unzip) are installed.
    • Install Java (if it is missing and requested).
    • Install the web server binaries and integrate the software into the system (setting the user, group, etc.).
    • Deploy the configuration files.
    • Start and enable JBoss Web Server as a systemd service.

    To install the certified collection for JBoss Web Server, you'll have to configure Ansible to use Red Hat Automation Hub as a Galaxy server. Follow the instructions on Automation Hub to retrieve your token and update the ansible.cfg configuration file in your project directory. Update the <your-token> field with the token obtained from Automation Hub:

    [galaxy]
    server_list = automation_hub, galaxy
    
    [galaxy_server.galaxy]
    url=https://galaxy.ansible.com/
    
    [galaxy_server.automation_hub]
    url=https://cloud.redhat.com/api/automation-hub/api/galaxy/
    auth_url=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token
    
    token=<your-token>

    Install the certified collection:

    $ ansible-galaxy collection install redhat.jws
    Starting galaxy collection install process
    Process install dependency map
    Starting collection install process
    Downloading https://console.redhat.com/api/automation-hub/v3/plugin/ansible/content/published/collections/artifacts/redhat-jws-1.2.2.tar.gz to /root/.ansible/tmp/ansible-local-475cum49011/tmptmiuep63/redhat-jws-1.2.2-299_snr4
    Installing 'redhat.jws:1.2.2' to '/root/.ansible/collections/ansible_collections/redhat/jws'
    Downloading https://console.redhat.com/api/automation-hub/v3/plugin/ansible/content/published/collections/artifacts/redhat-redhat_csp_download-1.2.2.tar.gz to /root/.ansible/tmp/ansible-local-475cum49011/tmptmiuep63/redhat-redhat_csp_download-1.2.2-tb4zjzut
    redhat.jws:1.2.2 was installed successfully
    Installing 'redhat.redhat_csp_download:1.2.2' to '/root/.ansible/collections/ansible_collections/redhat/redhat_csp_download'
    redhat.redhat_csp_download:1.2.2 was installed successfully

    Ansible Galaxy fetches and downloads the collection's dependencies. These dependencies include the redhat_csp_download collection, which helps facilitate the retrieval of the archive containing the JBoss Web Server server from either the Red Hat customer portal or a specified local or remote location. For more information about this step, please refer to the official documentation for Red Hat.

    Installing the Red Hat JBoss Web server

    The configuration steps in this section include downloading JBoss Web Server, installing Java, and enabling JBoss Web Server as a system service (systemd).

    Downloading the archive

    First, you need to download the archive for JBoss Web Server from the Red Hat Customer Portal. By default, the collection expects the archive to be in the root folder of the Ansible project. The only remaining requirement is to specify the version of JBoss Web Server being used (5.7) in the playbooks. Based upon this information, the collection determines the path and the full name of the archive.

    Therefore, update the value of jws_version in the jws-article.yml playbook:

    ---
    - name: "Red Hat JBoss Web Server installation and configuration"
      hosts: all
      vars:
        jws_setup: True
        jws_version: 5.7.0
        jws_home: /opt/jws-5.7/tomcat
      …

    Installing Java

    JBoss Web Server is a Java-based server, so the target system must have a Java Virtual Machine (JVM) installed. Although Ansible primitives can perform such tasks natively, the redhat.jws collection can also take care of this task, provided that the jws_java_version variable is defined:

    jws_home: /opt/jws-5.7/tomcat
    jws_java_version: 1.8.0
    …

    Note: This feature works only if the target system's distribution belongs to the Red Hat family.

    Enabling JBoss Web Server as a system service (systemd)

    The JBoss Web Server server on the target system should run as a service system. The collection can also take care of this task, if the jws_systemd_enabled variable is defined as True:

    jws_java_version: 1.8.0
    jws_systemd_enabled: True
    jws_service_name: jws

    Note: This configuration works only when systemd is installed and the system belongs to the Red Hat family.

    Now that you have defined all the required variables to deploy JBoss Web Server, finish the playbook:

    ...
    jws_service_name: jws
      collections:
        - redhat.jws
      roles:
        - role: jws
    

    Running the playbook

    Run the playbook to see whether it works as expected:

    $ ansible-playbook -i inventory jws-article.yml
    PLAY [Red Hat JBoss Web Server installation and configuration] *******************************************************************************************************************************************************************************
    TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************************************
    ok: [localhost]
    TASK [redhat.jws.jws : Validating arguments against arg spec 'main'] *************************************************************************************************************************************************************************
    ok: [localhost]
    TASK [redhat.jws.jws : Set default values] ***************************************************************************************************************************************************************************************************
    skipping: [localhost]
    TASK [redhat.jws.jws : Set default values (jws)] *********************************************************************************************************************************************************************************************
    ok: [localhost]
    TASK [redhat.jws.jws : Set jws_home to /opt/jws-5.7/tomcat if not already defined] ***********************************************************************************************************************************************************
    skipping: [localhost]
    TASK [redhat.jws.jws : Check that jws_home has been defined.] ********************************************************************************************************************************************************************************
    ok: [localhost] => {
      "changed": false,
      "msg": "All assertions passed"
    }
    TASK [redhat.jws.jws : Install required dependencies] ****************************************************************************************************************************************************************************************
    included: /root/.ansible/collections/ansible_collections/redhat/jws/roles/jws/tasks/fastpackage.yml for localhost => (item=zip)
    included: /root/.ansible/collections/ansible_collections/redhat/jws/roles/jws/tasks/fastpackage.yml for localhost => (item=unzip)
    TASK [redhat.jws.jws : Check arguments] ******************************************************************************************************************************************************************************************************
    ok: [localhost]
    …
    TASK [redhat.jws.jws : Remove apps] **********************************************************************************************************************************************************************************************************
    changed: [localhost] => (item=ROOT)
    ok: [localhost] => (item=examples)
    TASK [redhat.jws.jws : Create vault configuration (if enabled)] ******************************************************************************************************************************************************************************
    skipping: [localhost]
    RUNNING HANDLER [redhat.jws.jws : Reload Systemd] ********************************************************************************************************************************************************************************************
    ok: [localhost]
    RUNNING HANDLER [redhat.jws.jws : Ensure Jboss Web Server runs under systemd] ****************************************************************************************************************************************************************
    included: /root/.ansible/collections/ansible_collections/redhat/jws/roles/jws/tasks/systemd/service.yml for localhost
    RUNNING HANDLER [redhat.jws.jws : Check arguments] *******************************************************************************************************************************************************************************************
    ok: [localhost]
    RUNNING HANDLER [redhat.jws.jws : Enable jws.service] ****************************************************************************************************************************************************************************************
    changed: [localhost]
    RUNNING HANDLER [redhat.jws.jws : Start jws.service] *****************************************************************************************************************************************************************************************
    changed: [localhost]
    RUNNING HANDLER [redhat.jws.jws : Restart Jboss Web Server service] **************************************************************************************************************************************************************************
    changed: [localhost]
    PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
    localhost               : ok=64   changed=15   unreachable=0 failed=0 skipped=19   rescued=2 ignored=0

    As you can see, quite a lot happened during this execution. Indeed, the redhat.jws role took care of the entire setup:

    1. Deploying a base configuration
    2. Removing unused applications
    3. Starting the web server

    Deploying a web application

    Now that JBoss Web Server is running, modify the playbook to facilitate the deployment of a web application:

    roles:
    - role: jws
    tasks:
      - name: " Checks that server is running"
        ansible.builtin.uri:
          url: "http://localhost:8080/"
          status_code: 404
          return_content: no
    
      - name: "Deploy demo webapp"
        ansible.builtin.get_url:
          url: 'https://people.redhat.com/~rpelisse/info-1.0.war'
          dest: "{{ jws_home }}/webapps/info.war"
        notify:
          - "Restart Jboss Web Server service"

    The configuration uses a handler, provided by the redhat.jws collection, to ensure that the JBoss Web Server is restarted once the application is downloaded.

    Automation saves time and reduces the chance of error

    The Red Hat Ansible Certified Content Collection encapsulates, as much as possible, the complexities and the inner workings of Red Hat JBoss Web Server deployment. With the help of the collection, you can focus on your business use case, such as deploying applications, instead of establishing the underlying application server. The result is reduced complexity and faster time to value. The automated process is also repeatable and can be used to set up as many systems as needed.

    Last updated: March 14, 2023

    Recent Posts

    • More Essential AI tutorials for Node.js Developers

    • How to run a fraud detection AI model on RHEL CVMs

    • How we use software provenance at Red Hat

    • Alternatives to creating bootc images from scratch

    • How to update OpenStack Services on OpenShift

    What’s up next?

    Automation IT

    Automating IT operations lets you do more with what you have, freeing up teams to work on projects that deliver greater business value. In An IT executive's guide to automation, you'll discover the benefits of a long-term transformative automation strategy, explore automation adoption best practices, and more.

    Download the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue