Featured image for Red Hat JBoss Enterprise Application Platform.

This article demonstrates how to deploy Red Hat JBoss Enterprise Application Platform (JBoss EAP) on Microsoft Azure using Ansible automation. Currently, Red Hat has a Microsoft Azure Marketplace offering of JBoss EAP, but it's available only through the Bring-Your-Own-Subscription (BYOS) model, which is relatively complex. This article creates Azure resources using Ansible Collections for Azure and then deploys JBoss EAP using the WildFly service provided by the Ansible Middleware project.

Deploy JBoss EAP in 6 easy steps

We will use azure-eap-demo as the sample application for this article. Using this application, we will automate and deploy JBoss EAP instances on Azure virtual machines running Red Hat Enterprise Linux.

Step 1.  Prerequisites setup

To run the sample application, please put the following requirements in place:

  • An Azure account with an active subscription. If you do not have an Azure subscription, create one for free.
  • JBoss EAP: You need a Red Hat account with a Red Hat Subscription Management entitlement for JBoss EAP. This entitlement allows you to download a version of JBoss EAP tested and certified by Red Hat. If you do not have a JBoss EAP entitlement, sign up for a free developer subscription:  Red Hat Developer Subscription for Individuals. Once registered, you can find the necessary credentials (pool IDs) at the Red Hat customer portal.
  • The following software on the controller host or local machine:

Step 2.  Install WildFly and other components

After you unpack the azure-eap-demo application, change into the repository's top-level directory, and run the following command:

$ ansible-galaxy collection install -r requirements.yml

We are using a dynamic inventory provided by Azure. Once the instances are created, you can view the inventory with the following command:

$ ansible-inventory -i inventory/myazure_rm.yml --graph

Step 3.  Create credentials for Red Hat portal access

You need to provide credentials in the playbook so that it can download software from the Red Hat customer portal. Specify your Red Hat account name in the rhn_username variable and your password in the rhn_password variable.

In addition, you have to specify the Red Hat Subscription Management entitlement for JBoss EAP in the jboss_eap_rhn_id variable. This variable allows you to specify which version of JBoss EAP (supported by Red Hat) you would like to install. Alternatively, you can just download and install the JBoss EAP ZIP file from the Red Hat customer portal.

All these variables can be stored in a YAML file, whose name you specify in a section in the Ansible playbook named vars_files.

Step 4.  Run the Ansible playbook

Now run the Ansible playbook in create-demo-setup.yml which creates resources on Azure and deploys JBoss EAP:

​​​​​​​$ ansible-playbook -e @rhn-creds.yml -i inventory/myazure_rm.yml -e
"ansible_ssh_user=rheluser ansible_ssh_private_key_file='provide_your_ssh_private_key'
hosts_group_name=eap wildfly_version=7.4 override_install_name=jboss-eap"
create-demo-setup.yml

As part of the playbook execution, the azure-eap-demo repository is cloned. Its create-demo-setup.yml file contains:

- name: Create Azure VM
  hosts: localhost
  gather_facts: false
  connection: local
  vars:
   repo_url: "https://github.com/ansible-middleware/wildfly-cluster-demo.git"
   branch: main
  tasks:
   - name: Git checkout
     ansible.builtin.git:
       repo: "{{ repo_url }}"
       dest: "{{ playbook_dir }}/wildfly-cluster-demo"
       version: "{{ branch }}"
       single_branch: yes
       clone: yes
       update: yes

   - name: Create demo resources on azure.
     include_role:
       name: 'azure'
     vars:
       ssh_key_path: "{{ ssh_key | default(lookup('env', 'HOME') + '/.ssh/id_rsa.pub')}}"

   - meta: refresh_inventory
   - pause:
       minutes: 1

- name: Run wildfly-cluster-demo
  import_playbook: wildfly-cluster-demo/playbook.yml

This playbook creates the Azure resources the application needs, including a resource group, virtual networks, subnets, security groups, network interfaces, three virtual machines running Red Hat Enterprise Linux, and public IP addresses for the virtual machines.

All the default parameters for the Azure cloud instances are within the installed package: roles/azure/defaults/main.yml ​​​​​​.

Finally, the playbook deploys the WildFly cluster demo. Refer to the article Automate and deploy a JBoss EAP cluster with Ansible to learn more about how to use WildFly.

Step 5.  Verify deployment of the JBoss EAP cluster and application

Once the playbook completes successfully, you can verify the JBoss EAP cluster by logging into the Azure portal. Here, you will find all the resources created to support the JBoss EAP cluster. Log in or SSH into any of the virtual machines created and confirm that the WildFly service is running and accessible. Alternatively, you can run the validate.yml playbook provided in the wildfly-cluster-demo application to validate the configuration.

Step 6.  Clean up Azure resources

To clean up all the resources created on Azure, run the clean-demo-resources.yml playbook:

$ ansible-playbook clean-demo-resources.yml

The contents of clean-demo-resources.yml are as follows:

- name: Create Azure VM
  hosts: localhost
  connection: local
  tasks:
   - name: Create VM's on azure.
     include_role:
       name: 'azure'
     vars:
       action: destroy

The destroy action runs the roles/azure/tasks/destroy.yml file, which contains:

---
- name: Remove a VM and all resources that were autocreated
  azure_rm_virtualmachine:
   resource_group: "{{ item.resourcegroup_name }}"
   name: "{{ item.name }}"
   remove_on_absent: all_autocreated
   state: absent
  loop: "{{ vm }}"

- name: Delete a resource group including resources it contains
  azure_rm_resourcegroup:
   name: "{{ item.name }}"
   force_delete_nonempty: yes
   state: absent
  loop: "{{ resource_groups }}"

The playbook removes all the virtual machines and deletes all the resources under the eap-cluster resource group.

Ansible simplifies deployment on Azure

In this article, we demonstrated a step-by-step process to create resources using Ansible on Microsoft Azure and deploy a JBoss EAP cluster using tooling from the Ansible Middleware project. Check out the other collections and demos within the ansible-middleware GitHub organization and the Ansible Middleware website.

Last updated: September 19, 2023