This guide provides an Ansible example for JBoss EAP using licensed media with a dedicated service user and a managed systemd unit.
It focuses on RHEL-compatible systems.
- name: Install JBoss EAP
hosts: jboss
become: true
vars:
jboss_user: jboss
jboss_group: jboss
jboss_home: /opt/jboss
jboss_version: "8.0.0"
jboss_archive: "/tmp/jboss-eap-{{ jboss_version }}.zip"
jboss_install_dir: "{{ jboss_home }}/jboss-eap-{{ jboss_version }}"
jboss_service_name: jboss
jboss_java_home: /usr/lib/jvm/java-17-openjdk
tasks:
- name: Install runtime dependencies on RHEL family
dnf:
name:
- java-17-openjdk
- unzip
state: present
when: ansible_os_family == "RedHat"
- name: Create JBoss group
group:
name: "{{ jboss_group }}"
state: present
- name: Create JBoss user
user:
name: "{{ jboss_user }}"
group: "{{ jboss_group }}"
home: "{{ jboss_home }}"
shell: /usr/sbin/nologin
create_home: false
system: true
- name: Create JBoss home directory
file:
path: "{{ jboss_home }}"
state: directory
owner: "{{ jboss_user }}"
group: "{{ jboss_group }}"
mode: "0755"
- name: Assert JBoss EAP archive exists
stat:
path: "{{ jboss_archive }}"
register: jboss_archive_stat
- name: Fail if JBoss EAP archive is missing
fail:
msg: "Expected archive {{ jboss_archive }}. Stage Red Hat media first."
when: not jboss_archive_stat.stat.exists
- name: Extract JBoss EAP archive
unarchive:
src: "{{ jboss_archive }}"
dest: "{{ jboss_home }}"
remote_src: true
creates: "{{ jboss_install_dir }}/bin/standalone.sh"
- name: Ensure JBoss ownership
file:
path: "{{ jboss_home }}"
state: directory
owner: "{{ jboss_user }}"
group: "{{ jboss_group }}"
recurse: true
- name: Create JBoss systemd unit
copy:
dest: "/etc/systemd/system/{{ jboss_service_name }}.service"
mode: "0644"
content: |
[Unit]
Description=JBoss EAP
After=network.target
[Service]
Type=simple
User={{ jboss_user }}
Group={{ jboss_group }}
Environment=JAVA_HOME={{ jboss_java_home }}
Environment=JBOSS_HOME={{ jboss_install_dir }}
ExecStart={{ jboss_install_dir }}/bin/standalone.sh -b 0.0.0.0
ExecStop={{ jboss_install_dir }}/bin/jboss-cli.sh --connect command=:shutdown
Restart=on-failure
[Install]
WantedBy=multi-user.target
- name: Reload systemd
systemd:
daemon_reload: true
- name: Enable and start application service
service:
name: "{{ jboss_service_name }}"
state: started
enabled: true
jboss_archive to the exact EAP package name in your environment.standalone.sh with the domain controller startup flow.Any questions?
Feel free to contact us. Find all contact information on our contact page.