DEV Community

Pelisse Romain
Pelisse Romain

Posted on • Originally published at developers.redhat.com

Automate message queue deployment on JBoss EAP

For decades now, software projects have relied on messaging APIs to exchange data. In the Java/Java EE ecosystem, this method of asynchronous communication has been standardized by the JMS specification. In many cases, individuals and organizations leverage Red Hat JBoss Enterprise Application Platform (JBoss EAP) to act as message-oriented middleware (MOM), which facilitates the management of message queues and topics.

Messaging ensures that no messages are lost as they are transmitted from the client and delivered to interested parties. On top of that, JBoss EAP provides authentication and other security-focused capabilities on top of the management functions.

In this article, we'll show how to fully automate the setup of JBoss EAP and a JMS queue using Ansible so that we can easily make this service available.

Prerequisites and installation

Install Ansible

First, we’ll set up our Ansible control machine, which is where the automation will be executed. On this system, we need to install Ansible as the first step:

$ sudo dnf install -y ansible-core
Enter fullscreen mode Exit fullscreen mode

Note that the package name has changed recently from ansible to ansible-core.

Configure Ansible to use Red Hat Automation Hub

An extension to Ansible, an Ansible collection, dedicated to Red Hat JBoss EAP is available from Automation Hub. Red Hat customers need to add credentials and the location for Red Hat Automation Hub to their Ansible configuration file (ansible.cfg) to be able to install the content using the ansible-galaxy command-line tool.

Be sure to replace the with the API token you retrieved from Automation Hub. For more information about using Red Hat Automation Hub, please refer to the associated documentation.

#ansible.cfg:
[defaults]
host_key_checking = False
retry_files_enabled = False
nocows = 1

[inventory]
# fail more helpfully when the inventory file does not parse (Ansible 2.4+)
unparsed_is_failed=true

[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/
auth_url=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token
token=<paste-your-token-here>
Enter fullscreen mode Exit fullscreen mode

Install the Ansible collection for JBoss EAP

With this configuration, we can now install the Ansible collection for JBoss EAP (redhat.eap) available on Red Hat Ansible Automation Hub:

$ ansible-galaxy collection install redhat.eap
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-eap-1.3.4.tar.gz to /root/.ansible/tmp/ansible-local-2529rs7zh7/tmps_4n2eyj/redhat-eap-1.3.4-lr8dvcxo
Installing 'redhat.eap:1.3.4' to '/root/.ansible/collections/ansible_collections/redhat/eap'
Downloading https://console.redhat.com/api/automation-hub/v3/plugin/ansible/content/published/collections/artifacts/redhat-runtimes_common-1.1.0.tar.gz to /root/.ansible/tmp/ansible-local-2529rs7zh7/tmps_4n2eyj/redhat-runtimes_common-1.1.0-o6qfkgju
redhat.eap:1.3.4 was installed successfully
Installing 'redhat.runtimes_common:1.1.0' to '/root/.ansible/collections/ansible_collections/redhat/runtimes_common'
Downloading https://console.redhat.com/api/automation-hub/v3/plugin/ansible/content/published/collections/artifacts/ansible-posix-1.5.4.tar.gz to /root/.ansible/tmp/ansible-local-2529rs7zh7/tmps_4n2eyj/ansible-posix-1.5.4-4pgukpuo
redhat.runtimes_common:1.1.0 was installed successfully
Installing 'ansible.posix:1.5.4' to '/root/.ansible/collections/ansible_collections/ansible/posix'
ansible.posix:1.5.4 was installed successfully
Enter fullscreen mode Exit fullscreen mode

As we will describe a little later on, this extension for Ansible will manage the entire installation and configuration of the Java application server on the target systems.

Inventory file

Before we can start using our collection, we need to provide the inventory of targets to Ansible. There are several ways to provide this information to the automation tool, but for the purposes of this article, we elected to use a simple ini-formatted inventory file.

To easily reproduce this article's demonstration, you can use the same control node as the target. This also removes the need to deploy the required SSH key on all the systems involved. To do so, simply use the following inventory file by creating a file called inventory:

[all]
localhost ansible_connection=local

[messaging_servers]
localhost ansible_connection=local
Enter fullscreen mode Exit fullscreen mode

Deploying JBoss EAP

JBoss EAP installation

Before we configure the JMS queues that will be configured by Ansible, we'll first deploy JBoss EAP. Once the server is successfully running on the target system, we'll adjust the automation to add the required configuration to set up the messaging layer. This is purely for didactic purposes.

Since we can leverage the content of the redhat.eap collection, the playbook to install EAP and set it up as systemd service on the target system is minimal. Create a file called eap_jms.yml with the following content:

---
- name: "Deploy a JBoss EAP"
  hosts: messaging_servers
  vars:
    eap_apply_cp: true
    eap_version: 7.4.0
    eap_offline_install: false
    eap_config_base: 'standalone-full.xml'
  collections:
    - redhat.eap
  roles:
    - eap_install
    - eap_systemd
Enter fullscreen mode Exit fullscreen mode

Note that the Ansible collection for JBoss EAP will also take care of downloading the required assets from the Red Hat Customer Portal (the archive containing the Java app server files). However, one does need to provide the credentials associated with a service account. A Red Hat customer can manage service accounts using the hybrid cloud console. Within this portal, on the service accounts tab, you can create a new service account if one does not already exist.

**Note: **The values obtained from the hybrid cloud console are sensitive and should be managed accordingly. For the purpose of this article, the value is passed to the ansible-playbook command line. Alternatively, ansible-vault could be used to enforce additional defense mechanisms:

$ ansible-playbook -i inventory -e rhn_username=<client_id> -e rhn_password=<client_secret> eap_jms.yml

PLAY [Deploy a JBoss EAP] ******************************************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [redhat.eap.eap_install : Validating arguments against arg spec 'main'] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure prerequirements are fullfilled.] *********
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_install/tasks/prereqs.yml for localhost

TASK [redhat.eap.eap_install : Validate credentials] ***************************
ok: [localhost]

TASK [redhat.eap.eap_install : Validate existing zipfiles for offline installs] ***
skipping: [localhost]

TASK [redhat.eap.eap_install : Validate existing zipfiles for offline installs] ***
skipping: [localhost]

TASK [redhat.eap.eap_install : Check that required packages list has been provided.] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Prepare packages list] **************************
skipping: [localhost]

TASK [redhat.eap.eap_install : Add JDK package java-11-openjdk-headless to packages list] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Install required packages (4)] ******************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure required local user exists.] *************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_install/tasks/user.yml for localhost

TASK [redhat.eap.eap_install : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Set eap group] **********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure group eap exists.] ***********************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure user eap exists.] ************************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure workdir /opt/jboss_eap/ exists.] *********
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure archive_dir /opt/jboss_eap/ exists.] *****
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure server is installed] *********************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_install/tasks/install.yml for localhost

TASK [redhat.eap.eap_install : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Check local download archive path] **************
ok: [localhost]

TASK [redhat.eap.eap_install : Set download paths] *****************************
ok: [localhost]

TASK [redhat.eap.eap_install : Check target archive: /opt/jboss_eap//jboss-eap-7.4.0.zip] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Retrieve archive from website: https://github.com/eap/eap/releases/download] ***
skipping: [localhost]

TASK [redhat.eap.eap_install : Retrieve archive from RHN] **********************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_install/tasks/install/rhn.yml for localhost

TASK [redhat.eap.eap_install : Check arguments] ********************************
ok: [localhost]

TASK [Download JBoss EAP from CSP] *********************************************

TASK [redhat.eap.eap_utils : Check arguments] **********************************
ok: [localhost]

TASK [redhat.eap.eap_utils : Retrieve product download using JBoss Network API] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Determine install zipfile from search results] ****
ok: [localhost]

TASK [redhat.eap.eap_utils : Download Red Hat Single Sign-On] ******************
ok: [localhost]

TASK [redhat.eap.eap_install : Install server using RPM] ***********************
skipping: [localhost]

TASK [redhat.eap.eap_install : Check downloaded archive] ***********************
ok: [localhost]

TASK [redhat.eap.eap_install : Copy archive to target nodes] *******************
changed: [localhost]

TASK [redhat.eap.eap_install : Check target archive: /opt/jboss_eap//jboss-eap-7.4.0.zip] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Verify target archive state: /opt/jboss_eap//jboss-eap-7.4.0.zip] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Read target directory information: /opt/jboss_eap/jboss-eap-7.4/] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Extract files from /opt/jboss_eap//jboss-eap-7.4.0.zip into /opt/jboss_eap/.] ***
changed: [localhost]

TASK [redhat.eap.eap_install : Note: decompression was not executed] ***********
skipping: [localhost]

TASK [redhat.eap.eap_install : Read information on server home directory: /opt/jboss_eap/jboss-eap-7.4/] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Check state of server home directory: /opt/jboss_eap/jboss-eap-7.4/] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Set instance name] ******************************
ok: [localhost]

TASK [redhat.eap.eap_install : Deploy custom configuration] ********************
skipping: [localhost]

TASK [redhat.eap.eap_install : Deploy configuration] ***************************
changed: [localhost]

TASK [redhat.eap.eap_install : Ensure required parameters for cumulative patch application are provided.] ***
skipping: [localhost]

TASK [Apply latest cumulative patch] *******************************************
skipping: [localhost]

TASK [redhat.eap.eap_install : Ensure required parameters for elytron adapter are provided.] ***
skipping: [localhost]

TASK [Install elytron adapter] *************************************************
skipping: [localhost]

TASK [redhat.eap.eap_install : Install server using Prospero] ******************
skipping: [localhost]

TASK [redhat.eap.eap_install : Check eap install directory state] **************
ok: [localhost]

TASK [redhat.eap.eap_install : Validate conditions] ****************************
ok: [localhost]

TASK [Ensure firewalld configuration allows server port (if enabled).] *********
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Validating arguments against arg spec 'main'] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Check current EAP patch installed] **************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Check arguments for yaml configuration] *********
skipping: [localhost]

TASK [Ensure required local user and group exists.] ****************************

TASK [redhat.eap.eap_install : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Set eap group] **********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure group eap exists.] ***********************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure user eap exists.] ************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set destination directory for configuration] ****
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set instance destination directory for configuration] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Check arguments] ********************************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Set base directory for instance] ****************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Check arguments] ********************************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Set instance name] ******************************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Set instance name] ******************************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Set bind address] *******************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Create basedir /opt/jboss_eap/jboss-eap-7.4//standalone for instance: eap] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Create deployment directories for instance: eap] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Deploy custom configuration] ********************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Deploy configuration] ***************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Include YAML configuration extension] ***********
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Check YAML configuration is disabled] ***********
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set systemd envfile destination] ****************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Determine JAVA_HOME for selected JVM RPM] *******
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set systemd unit file destination] **************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Deploy service instance configuration: /etc//eap.conf] ***
changed: [localhost]

TASK [redhat.eap.eap_systemd : Deploy Systemd configuration for service: /usr/lib/systemd/system/eap.service] ***
changed: [localhost]

TASK [redhat.eap.eap_systemd : Perform daemon-reload to ensure the changes are picked up] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Ensure service is started] **********************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_systemd/tasks/service.yml for localhost

TASK [redhat.eap.eap_systemd : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set instance eap state to started] **************
changed: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=59   changed=6    unreachable=0    failed=0    skipped=22   rescued=0    ignored=0
Enter fullscreen mode Exit fullscreen mode

Validating the installation

Before going any further with our automation, we will be thorough and add a validation step to double-check that the application server is not only running but also functional. This will ensure, down the road, that any JMS-related issue only affects this subsystem.

The Ansible collection for JBoss EAP comes with a handy role, called eap_validation, for this purpose, so it's fairly easy to add this step to our playbook:

---
- name: "Deploy a JBoss EAP"
  hosts: messaging_servers
  vars:
    eap_apply_cp: true
    eap_version: 7.4.0
    eap_offline_install: false
    eap_config_base: 'standalone-full.xml'
  collections:
    - redhat.eap
  roles:
    - eap_install
    - eap_systemd
    - eap_validation
Enter fullscreen mode Exit fullscreen mode

Let's execute our playbook once again and observe the execution of this validation step:

$ ansible-playbook -i inventory -e rhn_username=<client_id> -e rhn_password=<client_secret> eap_jms.yml

PLAY [Deploy a JBoss EAP] ******************************************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [redhat.eap.eap_install : Validating arguments against arg spec 'main'] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure prerequirements are fullfilled.] *********
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_install/tasks/prereqs.yml for localhost

TASK [redhat.eap.eap_install : Validate credentials] ***************************
ok: [localhost]

TASK [redhat.eap.eap_install : Validate existing zipfiles for offline installs] ***
skipping: [localhost]

TASK [redhat.eap.eap_install : Validate existing zipfiles for offline installs] ***
skipping: [localhost]

TASK [redhat.eap.eap_install : Check that required packages list has been provided.] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Prepare packages list] **************************
skipping: [localhost]

TASK [redhat.eap.eap_install : Add JDK package java-11-openjdk-headless to packages list] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Install required packages (4)] ******************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure required local user exists.] *************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_install/tasks/user.yml for localhost

TASK [redhat.eap.eap_install : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Set eap group] **********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure group eap exists.] ***********************
changed: [localhost]

TASK [redhat.eap.eap_install : Ensure user eap exists.] ************************
changed: [localhost]

TASK [redhat.eap.eap_install : Ensure workdir /opt/jboss_eap/ exists.] *********
changed: [localhost]

TASK [redhat.eap.eap_install : Ensure archive_dir /opt/jboss_eap/ exists.] *****
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure server is installed] *********************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_install/tasks/install.yml for localhost

TASK [redhat.eap.eap_install : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Check local download archive path] **************
ok: [localhost]

TASK [redhat.eap.eap_install : Set download paths] *****************************
ok: [localhost]

TASK [redhat.eap.eap_install : Check target archive: /opt/jboss_eap//jboss-eap-7.4.0.zip] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Retrieve archive from website: https://github.com/eap/eap/releases/download] ***
skipping: [localhost]

TASK [redhat.eap.eap_install : Retrieve archive from RHN] **********************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_install/tasks/install/rhn.yml for localhost

TASK [redhat.eap.eap_install : Check arguments] ********************************
ok: [localhost]

TASK [Download JBoss EAP from CSP] *********************************************

TASK [redhat.eap.eap_utils : Check arguments] **********************************
ok: [localhost]

TASK [redhat.eap.eap_utils : Retrieve product download using JBoss Network API] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Determine install zipfile from search results] ****
ok: [localhost]

TASK [redhat.eap.eap_utils : Download Red Hat Single Sign-On] ******************
ok: [localhost]

TASK [redhat.eap.eap_install : Install server using RPM] ***********************
skipping: [localhost]

TASK [redhat.eap.eap_install : Check downloaded archive] ***********************
ok: [localhost]

TASK [redhat.eap.eap_install : Copy archive to target nodes] *******************
changed: [localhost]

TASK [redhat.eap.eap_install : Check target archive: /opt/jboss_eap//jboss-eap-7.4.0.zip] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Verify target archive state: /opt/jboss_eap//jboss-eap-7.4.0.zip] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Read target directory information: /opt/jboss_eap/jboss-eap-7.4/] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Extract files from /opt/jboss_eap//jboss-eap-7.4.0.zip into /opt/jboss_eap/.] ***
changed: [localhost]

TASK [redhat.eap.eap_install : Note: decompression was not executed] ***********
skipping: [localhost]

TASK [redhat.eap.eap_install : Read information on server home directory: /opt/jboss_eap/jboss-eap-7.4/] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Check state of server home directory: /opt/jboss_eap/jboss-eap-7.4/] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Set instance name] ******************************
ok: [localhost]

TASK [redhat.eap.eap_install : Deploy custom configuration] ********************
skipping: [localhost]

TASK [redhat.eap.eap_install : Deploy configuration] ***************************
changed: [localhost]

TASK [redhat.eap.eap_install : Ensure required parameters for cumulative patch application are provided.] ***
skipping: [localhost]

TASK [Apply latest cumulative patch] *******************************************
skipping: [localhost]

TASK [redhat.eap.eap_install : Ensure required parameters for elytron adapter are provided.] ***
skipping: [localhost]

TASK [Install elytron adapter] *************************************************
skipping: [localhost]

TASK [redhat.eap.eap_install : Install server using Prospero] ******************
skipping: [localhost]

TASK [redhat.eap.eap_install : Check eap install directory state] **************
ok: [localhost]

TASK [redhat.eap.eap_install : Validate conditions] ****************************
ok: [localhost]

TASK [Ensure firewalld configuration allows server port (if enabled).] *********
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Validating arguments against arg spec 'main'] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Check current EAP patch installed] **************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Check arguments for yaml configuration] *********
skipping: [localhost]

TASK [Ensure required local user and group exists.] ****************************

TASK [redhat.eap.eap_install : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Set eap group] **********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure group eap exists.] ***********************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure user eap exists.] ************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set destination directory for configuration] ****
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set instance destination directory for configuration] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Check arguments] ********************************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Set base directory for instance] ****************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Check arguments] ********************************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Set instance name] ******************************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Set instance name] ******************************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Set bind address] *******************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Create basedir /opt/jboss_eap/jboss-eap-7.4//standalone for instance: eap] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Create deployment directories for instance: eap] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Deploy custom configuration] ********************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Deploy configuration] ***************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Include YAML configuration extension] ***********
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Check YAML configuration is disabled] ***********
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set systemd envfile destination] ****************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Determine JAVA_HOME for selected JVM RPM] *******
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set systemd unit file destination] **************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Deploy service instance configuration: /etc//eap.conf] ***
changed: [localhost]

TASK [redhat.eap.eap_systemd : Deploy Systemd configuration for service: /usr/lib/systemd/system/eap.service] ***
changed: [localhost]

TASK [redhat.eap.eap_systemd : Perform daemon-reload to ensure the changes are picked up] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Ensure service is started] **********************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_systemd/tasks/service.yml for localhost

TASK [redhat.eap.eap_systemd : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set instance eap state to started] **************
changed: [localhost]

TASK [redhat.eap.eap_validation : Validating arguments against arg spec 'main'] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Ensure required parameters are provided.] ****
ok: [localhost]

TASK [redhat.eap.eap_validation : Ensure user eap were created.] ***************
ok: [localhost]

TASK [redhat.eap.eap_validation : Validate state of user: eap] *****************
ok: [localhost]

TASK [redhat.eap.eap_validation : Ensure user eap were created.] ***************
ok: [localhost]

TASK [redhat.eap.eap_validation : Validate state of group: eap.] ***************
ok: [localhost]

TASK [redhat.eap.eap_validation : Wait for HTTP port 8080 to become available.] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Check if web connector is accessible] ********
ok: [localhost]

TASK [redhat.eap.eap_validation : Populate service facts] **********************
ok: [localhost]

TASK [redhat.eap.eap_validation : Check if service is running] *****************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [redhat.eap.eap_validation : Verify server's internal configuration] ******
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_validation/tasks/verify_with_cli_queries.yml for localhost => (item={'query': '/core-service=server-environment:read-attribute(name=start-gracefully)'})
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_validation/tasks/verify_with_cli_queries.yml for localhost => (item={'query': '/subsystem=undertow/server=default-server/http-listener=default:read-attribute(name=enabled)'})

TASK [redhat.eap.eap_validation : Ensure required parameters are provided.] ****
ok: [localhost]

TASK [Use CLI query to validate service state: /core-service=server-environment:read-attribute(name=start-gracefully)] ***

TASK [redhat.eap.eap_utils : Ensure required params for JBoss CLI have been provided] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Ensure server's management interface is reachable] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Execute CLI query '/core-service=server-environment:read-attribute(name=start-gracefully)'] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Validate CLI query was successful] ***********
ok: [localhost]

TASK [redhat.eap.eap_validation : Transform output to JSON] ********************
ok: [localhost]

TASK [redhat.eap.eap_validation : Display transformed result] ******************
skipping: [localhost]

TASK [redhat.eap.eap_validation : Check that query was successfully performed.] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Ensure required parameters are provided.] ****
ok: [localhost]

TASK [Use CLI query to validate service state: /subsystem=undertow/server=default-server/http-listener=default:read-attribute(name=enabled)] ***

TASK [redhat.eap.eap_utils : Ensure required params for JBoss CLI have been provided] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Ensure server's management interface is reachable] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Execute CLI query '/subsystem=undertow/server=default-server/http-listener=default:read-attribute(name=enabled)'] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Validate CLI query was successful] ***********
ok: [localhost]

TASK [redhat.eap.eap_validation : Transform output to JSON] ********************
ok: [localhost]

TASK [redhat.eap.eap_validation : Display transformed result] ******************
skipping: [localhost]

TASK [redhat.eap.eap_validation : Check that query was successfully performed.] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Ensure yaml setup] ***************************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_validation/tasks/yaml_setup.yml for localhost

TASK [Check standard-sockets configuration settings] ***************************

TASK [redhat.eap.eap_utils : Ensure required params for JBoss CLI have been provided] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Ensure server's management interface is reachable] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Execute CLI query /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=mail-smtp:read-attribute(name=host)] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Display result of standard-sockets configuration settings] ***
ok: [localhost]

TASK [Check ejb configuration settings] ****************************************

TASK [redhat.eap.eap_utils : Ensure required params for JBoss CLI have been provided] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Ensure server's management interface is reachable] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Execute CLI query /subsystem=ejb3:read-attribute(name=default-resource-adapter-name)] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Display result of ejb configuration settings] ***
ok: [localhost]

TASK [Check ee configuration settings] *****************************************

TASK [redhat.eap.eap_utils : Ensure required params for JBoss CLI have been provided] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Ensure server's management interface is reachable] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Execute CLI query /subsystem=ee/service=default-bindings:read-attribute(name=jms-connection-factory)] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Display result of ee configuration settings] ***
ok: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=98   changed=9    unreachable=0    failed=0    skipped=24   rescued=0    ignored=0
Enter fullscreen mode Exit fullscreen mode

If the execution of the playbook completed without error, validation of the application server passed successfully.

Deploying JMS queues on JBoss EAP using Ansible

Changing EAP configuration

Because the JMS subsystem is not used in the default JBoss EAP server configuration (standalone.xml), we also need to use a different profile (standalone-alone.xml). This is why, in the playbook above, we are specifying the required configuration profile:

---
- name: "Deploy a JBoss EAP"
  hosts: messaging_servers
  vars:
      eap_apply_cp: true
      eap_version: 7.4.0
      eap_offline_install: false
      eap_config_base: 'standalone-full.xml'
  collections:
    - redhat.eap
  roles:
    - eap_install
    - eap_systemd
    - eap_validation
Enter fullscreen mode Exit fullscreen mode

Leveraging the YAML config feature of EAP using Ansible

In the previous section, JBoss EAP was installed and configured as a systemd service on the target systems. Now, we will update this automation to change the configuration of the app server to ensure a JMS queue is deployed and made available.

In order to accomplish this goal, we just need to provide a YAML definition with the appropriate configuration for the JMS subsystem of JBoss EAP. This configuration file is used by the app server, on boot, to update its configuration.

To achieve this, we need to add another file to our project that we named jms_configuration.yml.j2. While the content of the file itself is YAML, the extension is .j2 because it's a jinja2 template, which allows us to take advantage of the advanced, dynamic capabilities provided by Ansible.

jms_configuration.yml.j2:
wildfly-configuration:
  subsystem:
    messaging-activemq:
      server:
        default:
          jms-queue:
            {{ queue.name }}:
              entries:
                - '{{ queue.entry }}'
Enter fullscreen mode Exit fullscreen mode

Below, you'll see the playbook updated with all the required parameters to deploy the JMQ queue on JBoss EAP:

---
- name: "Deploy a Red Hat JBoss EAP server and set up a JMS Queue"
  hosts: messaging_servers
  vars:
    eap_apply_cp: true
    eap_version: 7.4.0
    eap_offline_install: false
    eap_config_base: 'standalone-full.xml'
    eap_enable_yml_config: True
    queue:
      name: MyQueue
      entry: 'java:/jms/queue/MyQueue'
    eap_yml_configs:
      - jms_configuration.yml.j2
  collections:
    - redhat.eap
  roles:
    - eap_install
    - eap_systemd
    - eap_validation
Enter fullscreen mode Exit fullscreen mode

Let's execute this playbook again:

$ ansible-playbook -i inventory -e rhn_username=<client_id> -e rhn_password=<client_secret> eap_jms.yml

PLAY [Deploy a Red Hat JBoss EAP server and set up a JMS Queue] ****************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [redhat.eap.eap_install : Validating arguments against arg spec 'main'] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure prerequirements are fullfilled.] *********
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_install/tasks/prereqs.yml for localhost

TASK [redhat.eap.eap_install : Validate credentials] ***************************
ok: [localhost]

TASK [redhat.eap.eap_install : Validate existing zipfiles for offline installs] ***
skipping: [localhost]

TASK [redhat.eap.eap_install : Validate existing zipfiles for offline installs] ***
skipping: [localhost]

TASK [redhat.eap.eap_install : Check that required packages list has been provided.] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Prepare packages list] **************************
skipping: [localhost]

TASK [redhat.eap.eap_install : Add JDK package java-11-openjdk-headless to packages list] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Install required packages (4)] ******************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure required local user exists.] *************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_install/tasks/user.yml for localhost

TASK [redhat.eap.eap_install : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Set eap group] **********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure group eap exists.] ***********************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure user eap exists.] ************************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure workdir /opt/jboss_eap/ exists.] *********
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure archive_dir /opt/jboss_eap/ exists.] *****
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure server is installed] *********************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_install/tasks/install.yml for localhost

TASK [redhat.eap.eap_install : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Check local download archive path] **************
ok: [localhost]

TASK [redhat.eap.eap_install : Set download paths] *****************************
ok: [localhost]

TASK [redhat.eap.eap_install : Check target archive: /opt/jboss_eap//jboss-eap-7.4.0.zip] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Retrieve archive from website: https://github.com/eap/eap/releases/download] ***
skipping: [localhost]

TASK [redhat.eap.eap_install : Retrieve archive from RHN] **********************
skipping: [localhost]

TASK [redhat.eap.eap_install : Install server using RPM] ***********************
skipping: [localhost]

TASK [redhat.eap.eap_install : Check downloaded archive] ***********************
ok: [localhost]

TASK [redhat.eap.eap_install : Copy archive to target nodes] *******************
skipping: [localhost]

TASK [redhat.eap.eap_install : Check target archive: /opt/jboss_eap//jboss-eap-7.4.0.zip] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Verify target archive state: /opt/jboss_eap//jboss-eap-7.4.0.zip] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Read target directory information: /opt/jboss_eap/jboss-eap-7.4/] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Extract files from /opt/jboss_eap//jboss-eap-7.4.0.zip into /opt/jboss_eap/.] ***
skipping: [localhost]

TASK [redhat.eap.eap_install : Note: decompression was not executed] ***********
ok: [localhost] => {
    "msg": "/opt/jboss_eap/jboss-eap-7.4/ already exists and version unchanged, skipping decompression"
}

TASK [redhat.eap.eap_install : Read information on server home directory: /opt/jboss_eap/jboss-eap-7.4/] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Check state of server home directory: /opt/jboss_eap/jboss-eap-7.4/] ***
ok: [localhost]

TASK [redhat.eap.eap_install : Set instance name] ******************************
ok: [localhost]

TASK [redhat.eap.eap_install : Deploy custom configuration] ********************
skipping: [localhost]

TASK [redhat.eap.eap_install : Deploy configuration] ***************************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure required parameters for cumulative patch application are provided.] ***
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Apply latest cumulative patch] *******************************************

TASK [redhat.eap.eap_utils : Check installation] *******************************
ok: [localhost]

TASK [redhat.eap.eap_utils : Set patch directory] ******************************
ok: [localhost]

TASK [redhat.eap.eap_utils : Set download patch archive path] ******************
ok: [localhost]

TASK [redhat.eap.eap_utils : Set patch destination directory] ******************
ok: [localhost]

TASK [redhat.eap.eap_utils : Check download patch archive path] ****************
ok: [localhost]

TASK [redhat.eap.eap_utils : Check local download archive path] ****************
ok: [localhost]

TASK [redhat.eap.eap_utils : Check local downloaded archive: jboss-eap-7.4.9-patch.zip] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Retrieve product download using JBossNetwork API] ***
skipping: [localhost]

TASK [redhat.eap.eap_utils : Determine patch versions list] ********************
skipping: [localhost]

TASK [redhat.eap.eap_utils : Determine latest version] *************************
skipping: [localhost]

TASK [redhat.eap.eap_utils : Determine install zipfile from search results] ****
skipping: [localhost]

TASK [redhat.eap.eap_utils : Determine selected patch from supplied version: 7.4.9] ***
skipping: [localhost]

TASK [redhat.eap.eap_utils : Check remote downloaded archive: /opt/jboss-eap-7.4.9-patch.zip] ***
skipping: [localhost]

TASK [redhat.eap.eap_utils : Download Red Hat EAP patch] ***********************
skipping: [localhost]

TASK [redhat.eap.eap_utils : Set download patch archive path] ******************
ok: [localhost]

TASK [redhat.eap.eap_utils : Check remote download patch archive path] *********
ok: [localhost]

TASK [redhat.eap.eap_utils : Copy patch archive to target nodes] ***************
changed: [localhost]

TASK [redhat.eap.eap_utils : Check patch state] ********************************
ok: [localhost]

TASK [redhat.eap.eap_utils : Set checksum file path for patch] *****************
ok: [localhost]

TASK [redhat.eap.eap_utils : Check /opt/jboss_eap/jboss-eap-7.4//.applied_patch_checksum_f641b6de2807fac18d2a56de7a27c1ea3611e5f3.txt state] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Print when patch has been applied already] ********
skipping: [localhost]

TASK [redhat.eap.eap_utils : Check if management interface is reachable] *******
ok: [localhost]

TASK [redhat.eap.eap_utils : Set apply CP conflict default strategy to default (if not defined): --override-all] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Apply patch /opt/jboss-eap-7.4.9-patch.zip to server installed in /opt/jboss_eap/jboss-eap-7.4/] ***
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_utils/tasks/jboss_cli.yml for localhost

TASK [redhat.eap.eap_utils : Ensure required params for JBoss CLI have been provided] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Ensure server's management interface is reachable] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Execute CLI query 'patch apply --override-all /opt/jboss-eap-7.4.9-patch.zip'] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Display patching result] **************************
ok: [localhost] => {
    "msg": "Apply patch operation result: {\n    \"outcome\" : \"success\",\n    \"response-headers\" : {\n        \"operation-requires-restart\" : true,\n        \"process-state\" : \"restart-required\"\n    }\n}"
}

TASK [redhat.eap.eap_utils : Set checksum file] ********************************
changed: [localhost]

TASK [redhat.eap.eap_utils : Set latest patch file] ****************************
changed: [localhost]

TASK [redhat.eap.eap_utils : Restart server to ensure patch content is running] ***
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_utils/tasks/jboss_cli.yml for localhost

TASK [redhat.eap.eap_utils : Ensure required params for JBoss CLI have been provided] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Ensure server's management interface is reachable] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Execute CLI query 'shutdown --restart'] ***********
ok: [localhost]

TASK [redhat.eap.eap_utils : Wait for management interface is reachable] *******
ok: [localhost]

TASK [redhat.eap.eap_utils : Stop service if it was started for patching] ******
skipping: [localhost]

TASK [redhat.eap.eap_utils : Display resulting output] *************************
skipping: [localhost]

TASK [redhat.eap.eap_install : Ensure required parameters for elytron adapter are provided.] ***
skipping: [localhost]

TASK [Install elytron adapter] *************************************************
skipping: [localhost]

TASK [redhat.eap.eap_install : Install server using Prospero] ******************
skipping: [localhost]

TASK [redhat.eap.eap_install : Check eap install directory state] **************
ok: [localhost]

TASK [redhat.eap.eap_install : Validate conditions] ****************************
ok: [localhost]

TASK [Ensure firewalld configuration allows server port (if enabled).] *********
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Validating arguments against arg spec 'main'] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Check current EAP patch installed] **************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Check arguments for yaml configuration] *********
ok: [localhost]

TASK [Ensure required local user and group exists.] ****************************

TASK [redhat.eap.eap_install : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Set eap group] **********************************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure group eap exists.] ***********************
ok: [localhost]

TASK [redhat.eap.eap_install : Ensure user eap exists.] ************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set destination directory for configuration] ****
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set instance destination directory for configuration] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Check arguments] ********************************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Set base directory for instance] ****************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Check arguments] ********************************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Set instance name] ******************************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Set instance name] ******************************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Set bind address] *******************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Create basedir /opt/jboss_eap/jboss-eap-7.4//standalone for instance: eap] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Create deployment directories for instance: eap] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Deploy custom configuration] ********************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Deploy configuration] ***************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Include YAML configuration extension] ***********
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_systemd/tasks/yml_config.yml for localhost

TASK [redhat.eap.eap_systemd : Create YAML configuration directory] ************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Enable YAML configuration extension] ************
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Create YAML configuration directory] ************
changed: [localhost]

TASK [redhat.eap.eap_systemd : Enable YAML configuration extension] ************
changed: [localhost]

TASK [redhat.eap.eap_systemd : Deploy YAML configuration files] ****************
changed: [localhost] => (item=jms_configuration.yml.j2)

TASK [redhat.eap.eap_systemd : Check YAML configuration is disabled] ***********
skipping: [localhost]

TASK [redhat.eap.eap_systemd : Set systemd envfile destination] ****************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Determine JAVA_HOME for selected JVM RPM] *******
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set systemd unit file destination] **************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Deploy service instance configuration: /etc//eap.conf] ***
changed: [localhost]

TASK [redhat.eap.eap_systemd : Deploy Systemd configuration for service: /usr/lib/systemd/system/eap.service] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Perform daemon-reload to ensure the changes are picked up] ***
ok: [localhost]

TASK [redhat.eap.eap_systemd : Ensure service is started] **********************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_systemd/tasks/service.yml for localhost

TASK [redhat.eap.eap_systemd : Check arguments] ********************************
ok: [localhost]

TASK [redhat.eap.eap_systemd : Set instance eap state to started] **************
ok: [localhost]

TASK [redhat.eap.eap_validation : Validating arguments against arg spec 'main'] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Ensure required parameters are provided.] ****
ok: [localhost]

TASK [redhat.eap.eap_validation : Ensure user eap were created.] ***************
ok: [localhost]

TASK [redhat.eap.eap_validation : Validate state of user: eap] *****************
ok: [localhost]

TASK [redhat.eap.eap_validation : Ensure user eap were created.] ***************
ok: [localhost]

TASK [redhat.eap.eap_validation : Validate state of group: eap.] ***************
ok: [localhost]

TASK [redhat.eap.eap_validation : Wait for HTTP port 8080 to become available.] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Check if web connector is accessible] ********
ok: [localhost]

TASK [redhat.eap.eap_validation : Populate service facts] **********************
ok: [localhost]

TASK [redhat.eap.eap_validation : Check if service is running] *****************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [redhat.eap.eap_validation : Verify server's internal configuration] ******
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_validation/tasks/verify_with_cli_queries.yml for localhost => (item={'query': '/core-service=server-environment:read-attribute(name=start-gracefully)'})
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_validation/tasks/verify_with_cli_queries.yml for localhost => (item={'query': '/subsystem=undertow/server=default-server/http-listener=default:read-attribute(name=enabled)'})

TASK [redhat.eap.eap_validation : Ensure required parameters are provided.] ****
ok: [localhost]

TASK [Use CLI query to validate service state: /core-service=server-environment:read-attribute(name=start-gracefully)] ***

TASK [redhat.eap.eap_utils : Ensure required params for JBoss CLI have been provided] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Ensure server's management interface is reachable] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Execute CLI query '/core-service=server-environment:read-attribute(name=start-gracefully)'] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Validate CLI query was successful] ***********
ok: [localhost]

TASK [redhat.eap.eap_validation : Transform output to JSON] ********************
ok: [localhost]

TASK [redhat.eap.eap_validation : Display transformed result] ******************
skipping: [localhost]

TASK [redhat.eap.eap_validation : Check that query was successfully performed.] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Ensure required parameters are provided.] ****
ok: [localhost]

TASK [Use CLI query to validate service state: /subsystem=undertow/server=default-server/http-listener=default:read-attribute(name=enabled)] ***

TASK [redhat.eap.eap_utils : Ensure required params for JBoss CLI have been provided] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Ensure server's management interface is reachable] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Execute CLI query '/subsystem=undertow/server=default-server/http-listener=default:read-attribute(name=enabled)'] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Validate CLI query was successful] ***********
ok: [localhost]

TASK [redhat.eap.eap_validation : Transform output to JSON] ********************
ok: [localhost]

TASK [redhat.eap.eap_validation : Display transformed result] ******************
skipping: [localhost]

TASK [redhat.eap.eap_validation : Check that query was successfully performed.] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Ensure yaml setup] ***************************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_validation/tasks/yaml_setup.yml for localhost

TASK [Check standard-sockets configuration settings] ***************************

TASK [redhat.eap.eap_utils : Ensure required params for JBoss CLI have been provided] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Ensure server's management interface is reachable] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Execute CLI query /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=mail-smtp:read-attribute(name=host)] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Display result of standard-sockets configuration settings] ***
ok: [localhost]

TASK [Check ejb configuration settings] ****************************************

TASK [redhat.eap.eap_utils : Ensure required params for JBoss CLI have been provided] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Ensure server's management interface is reachable] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Execute CLI query /subsystem=ejb3:read-attribute(name=default-resource-adapter-name)] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Display result of ejb configuration settings] ***
ok: [localhost]

TASK [Check ee configuration settings] *****************************************

TASK [redhat.eap.eap_utils : Ensure required params for JBoss CLI have been provided] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Ensure server's management interface is reachable] ***
ok: [localhost]

TASK [redhat.eap.eap_utils : Execute CLI query /subsystem=ee/service=default-bindings:read-attribute(name=jms-connection-factory)] ***
ok: [localhost]

TASK [redhat.eap.eap_validation : Display result of ee configuration settings] ***
ok: [localhost]

RUNNING HANDLER [redhat.eap.eap_systemd : Restart Wildfly] *********************
included: /root/.ansible/collections/ansible_collections/redhat/eap/roles/eap_systemd/tasks/service.yml for localhost

RUNNING HANDLER [redhat.eap.eap_systemd : Check arguments] *********************
ok: [localhost]

RUNNING HANDLER [redhat.eap.eap_systemd : Set instance eap state to restarted] ***
changed: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=127  changed=8    unreachable=0    failed=0    skipped=34   rescued=0    ignored=0
Enter fullscreen mode Exit fullscreen mode

As illustrated in the output above, the YAML definition is now enabled and the configuration of the JBoss EAP running on the target host has been updated.

Validate the JMS queue deployment

As always, we are going to be thorough and verify that the playbook execution has, indeed, properly set up a JMS queue. To do so, we can simply use the JBoss CLI provided with JBoss EAP to confirm:

$ /opt/jboss_eap/jboss-eap-7.4/bin/jboss-cli.sh --connect --command="/subsystem=messaging-activemq/server=default/jms-queue=MyQueue:read-resource"
{
    "outcome" => "success",
    "result" => {
        "durable" => true,
        "entries" => ["queues/MyQueue"],
        "legacy-entries" => undefined,
        "selector" => undefined
    }
}
Enter fullscreen mode Exit fullscreen mode

The output, as shown above, confirms that the server configuration has indeed been updated and that a brand new JMS queue is now available. Since this verification is fairly easy to automate, we will also add it to our playbook.

The Ansible collection for JBoss EAP comes with a handy wrapper allowing for the execution of the JBoss CLI within a playbook. So, all that is needed is the inclusion of the task and the desired command, as shown below:

post_tasks:
    - name: "Check that Queue {{ queue.name }} is available."
      ansible.builtin.include_role:
        name: eap_utils
        tasks_from: jboss_cli.yml
      vars:
        jboss_home: "{{ eap_home }}"
        jboss_cli_query: "/subsystem=messaging-activemq/server=default/jms-queue={{ queue.name }}:read-resource"
Enter fullscreen mode Exit fullscreen mode

Conclusion

Thanks to the Ansible collection for JBoss EAP, we have a minimalistic playbook, spared of all the heavy lifting of managing the Java application server, fulfilling the role of MOM. All the configuration required by the automation concerns only the use case we tried to implement, not the inner working of the solution (JBoss EAP).

All the configuration required by the automation concerns only the use case we tried to implement, not the inner working of the solution (JBoss EAP). The resulting playbook is safely repeatable and can be used to install the software on any number of target systems. Using the collection for JBoss EAP also makes it easy to keep the deployment up to date.

Top comments (0)