Automation of JBoss EAP installation - using ansible

Automation of JBoss EAP installation – using ansible

Last Updated on April 1, 2023 by cscontents


In this article, we will discuss the automation of JBoss EAP installation using Ansible. There could be many ways through which you can automate the installation of JBoss EAP, but here we will try to achieve this using Ansible. And here we will install the JBoss EAP on a Linux (RHEL) machine.

Automation of any software installation is achievable if we know the steps to install it manually. So, if we know the manual steps to install JBoss EAP, then with the help of ansible we can achieve the automation.

JBoss EAP can be installed in multiple ways –

  • ZIP installation (preferred) – installation binaries are in a ZIP file.
  • Installer installation – installation is done from the JBoss EAP installer file
  • RPM installation – using Red Hat Package Manager. This requires a subscription.

We will discuss the ZIP installation steps.

Before going through this article, it is highly recommended to look at the manual steps. In the below article, we have discussed a step-by-step guide to installing JBoss EAP manually.

How to install JBoss EAP – step-by-step guide


You need to fulfill the below prerequisites to complete this tutorial.

Prerequisite Knowledge

  • Knowledge of Ansible
  • Knowledge of JBoss EAP
  • Basic Linux commands.

If you want to learn Ansible basics then please check out the below course from KodeKloud which offers one of the best learning material in DevOps world.

Link of Training Course: Ansible for absolute beginners

Note: The above links are affiliate links, if you enroll this course using the above link, then it would help us to get some monetary benefit from KodeKloud. It won’t cost you anything.

Prerequisite Setup

Two Linux machines – one machine will work as an ansible-controller which should have ansible installed and another will work as a target machine where ansible will perform the task. This target machine can also be called a remote machine.

Below article can be followed to get an understanding and fulfill the above prerequisite.

Basics of automation using Ansible | Automate any task

Automation of JBoss EAP installation

We will automate the installation using Ansible, and we know ansible has a module for each task, we will use those modules.

Below are the modules which will be used in our ansible playbook –

To understand the below playbook, you need to have some idea about the above ansible modules.

Ansible Playbook to install JBoss EAP

- name: JBoss EAP installation
  hosts: jboss-host
  become: true
    - name: Download JBoss EAP binaries
        url: <repository URL where you stored JBoss EAP>
        url_username: user
        url_password: password
        dest: /opt

    - name: Unzip the downloaded ZIP file
        src: /opt/
        dest: /opt
        remote_arc: yes

    - name: Create JBoss EAP Group
        name: jboss-group
        system: yes
        state: present
    - name: Create JBoss EAP user
        name: jboss-user
        group: jboss-group
        password: pa$$w0rd
        home: /opt/jboss-eap-7.4
        shell: "/bin/bash"

   - name: Change owner & group of JBoss EAP directory
       path: /opt/jboss-eap-7.4
       owner: jboss-user
       group: jboss-group
       recurse: yes

   - name: Edit JBoss EAP configuration file
       state: present
       path: /opt/jboss-eap-7.4/bin/init.d/jboss-eap.conf
       regexp: "{{ item.regexp }}"
       line: "{{ item.line }}"
       - {regexp: "^# JAVA_HOME=", line: 'JAVA_HOME="/opt/jdk-"'}
       - {regexp: "^# JBOSS_HOME=", line: 'JBOSS_HOME="/opt/jboss-eap-7.4"'}
       - {regexp: "^# JBOSS_USER=", line: 'JBOSS_USER=jboss-user'}

   - name: Update /etc/profile with JBOSS_HOME variable
       path: /etc/profile
       state: present
       line: "{{ item }}"
       - 'export JBOSS_HOME="/opt/jboss-eap-7.4"'
       - 'export PATH=$PATH:$JBOSS_HOME/bin'

   - name: Configure JBoss EAP as a service
       chdir: /opt/jboss-eap-7.4
       cmd: "{{item }}"
       - cp /opt/jboss-eap-7.4/bin/init.d/jboss-eap.conf /etc/default/
       - cp /opt/jboss-eap-7.4/bin/init.d/ /etc/init.d/
       - restorecon /etc/init.d/
       - chkconfig --add 

   - name: Start JBoss EAP Service
       name: jboss-eap-rhel
       state: started
       enabled: yes

To execute the above playbook, we need to create an inventory file. Below is the content of the inventory.txt file.

jboss-host ansible_host= ansible_ssh_user=remote_ssh_user ansible_ssh_pass=remote_ssh_password

Once we have the installation playbook (e.g., jboss-install.yml) and inventory.txt file, we need to run the below command on the ansible host.

ansible-playbook jboss-install.yml -i inventory.txt --extra-vars "ansible_sudo_pass=sudoPassword" -vv


ansible-playbook jboss-install.yml -i inventory.txt --ask-become-pass -vv

The above command will ask for the password, and we need to enter the password to become the root user in the target machine.

If we execute any of the above commands it will initiate the installation on the target machine.


Thank You.


If you are interested in learning DevOps, please have a look at the below articles, which will help you greatly.