Skip to main content
Redhat Developers  Logo
  • 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 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

    • OpenShift AI learning
    • 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.
    • Explore the solution
  • 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

    • Access product downloads to start building and testing right away.
    • 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.
    • Explore the benefits

WildFly server configuration with Ansible collection for JCliff, Part 3

December 21, 2020
Romain Pelisse
Related topics:
JavaDevOpsLinux
Related products:
Red Hat Enterprise Linux

    Welcome to the final installment in this three-part series about using Ansible Collection for JCliff to manage WildFly or Red Hat JBoss Enterprise Application Platform (JBoss EAP) instances. Previously, we've discussed installing and configuring the JCliff Ansible collection and using its basic features. In this article, we discuss advanced options available with the project's latest release. Without further ado, let's dive in!

    Using custom JCliff rules

    JCliff supports tweaking and configuring a large number of WildFly subsystems. Many of these have yet to be integrated into the Ansible collection. However, it is still possible to leverage those extra features. In this section, we’ll show you how to implement a custom ruleset to leverage JCliff's full capabilities inside Ansible.

    Configuring WildFly's mail subsystem

    Let’s say we wanted to configure a mail session inside a WildFly configuration. Currently, no mail element is available for the jcliff: module. Instead, we can use a script provided by the JCliff project:

    {
      "mail" => {
         "mail-session" => {
            "testSession" => {
               "from" => "a@b.com",
               "jndi-name" => "java:jboss/mail/testSession",
               "server" => {
                  "smtp" => {
                     "outbound-socket-binding-ref" => "mail-smtp",
                     "ssl" => false
                   }
               }
             }
         }
      }
    }

    We can provide this snippet to Ansible collection for JCliff to execute and thus configure our WildFly server's mail subsystem. First, let’s create a directory for the JCliff configuration file and download the example:

    vars:
    ...
      jcliff_config_files_dir: /opt/jcliff
    ...
         - name: Create directory for jcliff rules
           file:
             name: "{{ jcliff_config_files_dir }}"
             state: directory
      
         - name: Download mail.test configuration file for JCLiff
           uri:
             url: https://raw.githubusercontent.com/bserdar/jcliff/master/testscripts/mail.test
             dest: "{{ jcliff_config_files_dir }}/mail.test"
             creates: "{{ jcliff_config_files_dir }}/mail.test"
    

    Next, we configure the jcliff: module to execute the files available in this ruleset directory:

    ...
    - jcliff:
       wfly_home: "{{ jboss_home }}"
       rule_file: "{{ jcliff_config_files_dir }}"
       subsystems:
    ...

    Note: The next version of Ansible collection for JCliff will include a mail element.

    Verifying the new configuration

    It is easy to verify that the configuration change has happened as expected. WildFly's log file should contain a message mentioning the newly bound mail session:

    ...
    14:38:36,372 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-6) WFLYMAIL0001: Bound mail session [java:jboss/mail/testSession]
    ...

    For more information about the mail-session configuration, we can enter a simple query using WildFly's JBoss CLI:

    /subsystem=mail/mail-session=testSession:read-resource
    {
    
        "outcome" => "success",
        "result" => {
            "debug" => false,
            "from" => "a@b.com",
            "jndi-name" => "java:jboss/mail/testSession",
            "custom" => undefined,
            "server" => {"smtp" => undefined}
        },
        "response-headers" => {"process-state" => "reload-required"}
    }
    

    Note that this last change requires reloading WildFly's configuration. If you've deployed WildFly on the system as a service, you can also ask Ansible to restart it. If WildFly is not deployed as a service, you can still use the JBoss CLI in Ansible to reload:

    - name: "Restart WildFly"
      command: "{{ jboss_home }}/bin/jboss-cli.sh --connect --command=':reload'"
    

    Troubleshooting JCliff

    Of course, not everything works as expected out of the box. At times, you might need to analyze and investigate what is really happening under the covers. In this section, we’ll highlight how to troubleshoot issues when using JCliff with Ansible.

    First, bear in mind that Ansible only generates the configuration files required by JCliff and runs the command-line tool. As a result, very little can go wrong when using Ansible collection for JCliff. At worst, you might encounter invalid paths or similar human errors. Using Ansible with verbose logging (such as -vvvv) should help you identify such problems.

    If you run into challenges specific to the jcliff: module, it's often best to run the tool outside of Ansible to see what’s happening. In this case, your first step is to retrieve the configuration file generated by Ansible and ensure the content is correct.

    The generated configuration files for JCliff are deleted after each Ansible run. To access them, you must instruct Ansible not to delete those files. Set the following parameter before running Ansible:

    export ANSIBLE_KEEP_REMOTE_FILES=1
    

    When the jcliff: module fails, you should be able to locate the configuration file based on the failing subsystem's name. For instance, if you have issues with the automation of the JDBC driver deployment, you should look for a file named drivers-0.jcliff.yml.

    Once you have located the file, run jcliff with the option -v , and pass it the following configuration file:

    $ jcliff -v ~/.ansible/tmp/ansible-tmp-1597756555.46-5332-269490407528192//drivers-0.jcliff.yml
    

    If the problem is not revealed as part of the JCliff execution, the set of JBoss CLI queries executed should still give you an idea about what is happening. You can then connect to the WildFly instance (using the JBoss CLI script provided with the server) and directly run those queries. Doing that will most likely uncover the underlying issue.

    Conclusion

    Before releasing Ansible collection for JCliff, considerable plumbing was required to automate the setup and configuration of a WildFly instance. Even if you used JCliff directly, you still needed a few configuration files. Without JCliff, you were required to design, write, and test hundreds of lines of JBoss CLI scripts. Some developers tried to work around this limitation by using templating for automation. Unfortunately, that workaround caused issues if the configuration file was modified outside of Ansible.

    Ansible collection for JCliff resolves these issues. It is concise and integrates smoothly into Ansible. As a developer, you can state the desired configuration in a few lines, just as you would do for any other resources managed by Ansible.

    We hope you've enjoyed this series getting to know Ansible collection for JCliff, and that you will give the tool a try the next time you need to configure a WildFly or JBoss EAP instance.

    Acknowledgment

    Extra thanks to Andrew Block for reviewing this series of articles.

    Last updated: December 20, 2020

    Recent Posts

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    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

    Chat Support

    Please log in with your Red Hat account to access chat support.