Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

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

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

    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

    • A day in the life of an NVIDIA H100 on Red Hat OpenShift 5

    • Migrate BuildConfigs to builds for Red Hat OpenShift with one plug-in install

    • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

    • Agent harness engineering: Separating model capabilities from enforcement

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    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

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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