Chapter 3. Enabling automated deployments of JBoss EAP
The JBoss EAP collection provides a comprehensive set of variables and default values that you can manually update to match your setup requirements. These variable settings provide all the information that the JBoss EAP collection requires to complete an automated and customized installation of Red Hat JBoss Enterprise Application Platform (JBoss EAP) on your target hosts.
For a full list of variables that the JBoss EAP collection provides, see the redhat.eap roles in Ansible automation hub. The information page for the role lists the names, descriptions, and default values for all the variables that you can define.
You can define variables in multiple ways. By default, the JBoss EAP collection includes an example playbook.yml file that links to a vars.yml file in the same playbooks folder. For illustrative purposes, the instructions in this section describe how to define variables in the vars.yml file that the collection provides. You can use a different way to define variables if you prefer.
You can define variables to automate the following tasks:
You can also perform the following automation enablement tasks:
- Enable automated configuration of JBoss EAP by specifying YAML configuration values and defining a variable to enable the YAML configuration feature, as described in Enabling the automated configuration of JBoss EAP subsystems.
- Enable automated deployment of JBoss EAP applications by adding customized tasks to the playbook, as described in Enabling the automated deployment of JBoss EAP applications on your target hosts.
3.1. Enablement of automated installations of JBoss EAP from archive files Copy linkLink copied to clipboard!
By default, the JBoss EAP collection is configured to install Red Hat JBoss Enterprise Application Platform (JBoss EAP) on each target host from product archive files. Depending on your setup requirements, you can enable the JBoss EAP collection to install a base product release, product patch updates, or both simultaneously from archive files. You can choose to download the archive files manually from the Red Hat Customer Portal or enable the JBoss EAP collection to download the archive files automatically.
3.1.1. Enabling the automated installation of a JBoss EAP base release Copy linkLink copied to clipboard!
You can enable the JBoss EAP collection to install the base release of a specified JBoss EAP product version from archive files. A base release is the initial release of a specific product version (for example, 7.4.0 is the base release of version 7.4).
The JBoss EAP collection requires that local copies of the appropriate archive files are available on your Ansible control node. If copies of the archive files are not already on your system, you can set variables to specify Red Hat service account credentials to permit automatic file downloads from the Red Hat Customer Portal. Alternatively, you can download the archive files manually.
Prerequisites
- You have installed the JBoss EAP collection.
- If a copy of the JBoss EAP archive file is already on your system, you have copied this archive file to your Ansible control node. In this situation, you must copy the archive file to the same directory as your custom playbook on the Ansible control node.
If you want the JBoss EAP collection to download archive files automatically from the Red Hat Customer Portal, you have created a Red Hat service account.
NoteService accounts enable you to securely and automatically connect and authenticate services or applications without requiring end-user credentials or direct interaction. To create a service account, log in to the Service Accounts page in the Red Hat Hybrid Cloud Console, and click Create service account.
If you prefer to download the archive file manually, you have downloaded the appropriate archive file to your Ansible control node. In this situation, you must download the archive file to the same directory as your custom playbook on the Ansible control node. For more information about downloading archive files, see the Red Hat JBoss Enterprise Application Platform Installation Guide.
NoteIf you manually download the archive file, you do not need to extract this file on your Ansible control node. In this situation, the JBoss EAP collection extracts the archive file automatically.
Procedure
-
On your Ansible control node, open the
vars.ymlfile. To specify the JBoss EAP version that you want to install, set the
eap_versionvariable to the appropriate base release.For example:
[...] eap_version: 7.4.0NoteEnsure that the value you specify for the
eap_versionvariable matches the version of the product archive file that you want to install. For example, to install the archive file for JBoss EAP 7.4, specify a value of7.4.0.If you do not specify credentials for automatic file downloads as described in Step 3, ensure that you have copied the archive file for the specified product version to your Ansible control node.
If a copy of the JBoss EAP archive file does not exist on your Ansible control node, the collection contacts the Red Hat Customer Portal by default to download the archive file automatically. To ensure successful contact with the Red Hat Customer Portal, set the
rhn_usernameandrhn_passwordvariables to specify your Red Hat service account credentials.For example:
[...] rhn_username: <client_ID> rhn_password: <client_secret>In the preceding example, replace <client_ID> and <client_secret> with the client ID and secret that are associated with your Red Hat service account.
NoteIf a copy of the appropriate archive file already exists on your Ansible control node, the collection does not download this archive file again.
If you prefer to download the archive file manually or you have already obtained this file in some other way, you can enforce a fully offline installation. For more information about enforcing offline installations, see Enabling the automated installation of JBoss EAP patch updates.
If you changed the name of the downloaded archive file on your Ansible control node, set the
eap_archive_filenamevariable to specify the file that you want to install.For example:
[...] eap_archive_filename: <application_server_file>In the preceding example, replace <application_server_file> with the appropriate archive file name.
NoteIf you did not change the file name, you do not need to set the
eap_archive_filenamevariable. The JBoss EAP collection uses the value of theeap_versionvariable to determine the default file name automatically.-
Save your changes to the
vars.ymlfile.
By setting these variables, as appropriate, you enable the JBoss EAP collection to install the base product release automatically on your target hosts when you subsequently run the playbook.
3.1.2. Enabling the automated installation of JBoss EAP patch updates Copy linkLink copied to clipboard!
If product patch updates are available for the JBoss EAP version that is being installed, you can also enable the JBoss EAP collection to install these patch updates from archive files. Depending on your requirements, you can enable the JBoss EAP collection to install either the latest available patch or a specified patch release. You can use the same steps to enable the automated installation of patch updates regardless of whether you want to install the updates at the same time as the base release or later.
The JBoss EAP collection requires that local copies of the appropriate archive files are available on your Ansible control node. If copies of the archive files are not already on your system, you can set variables to specify Red Hat service account credentials to permit automatic file downloads from the Red Hat Customer Portal. Alternatively, you can download the archive files manually.
Patch updates are cumulative, which means that each patch update automatically includes any earlier patch releases that are available for the same product version. For example, a 7.4.2 patch update would include the 7.4.1 release, a 7.4.3 patch update would include the 7.4.1 and 7.4.2 releases, and so on.
You cannot use cumulative patch updates to install the base (X.X.0) release of a product version. For example, a 7.4.2 patch would include the 7.4.1 release but cannot install the base 7.4.0 release. In this situation, you must ensure that the base release of the appropriate product version (for example, 7.4.0) is also installed either at the same time or previously.
Prerequisites
- You have installed the JBoss EAP collection.
- If a copy of the archive file for the patch update that you want to install is already on your system, you have copied this archive file to your Ansible control node. In this situation, you must copy the archive file to the same directory as your custom playbook on the Ansible control node.
If you want the JBoss EAP collection to download archive files automatically from the Red Hat Customer Portal, you have created a Red Hat service account.
NoteService accounts enable you to securely and automatically connect and authenticate services or applications without requiring end-user credentials or direct interaction. To create a service account, log in to the Service Accounts page in the Red Hat Hybrid Cloud Console, and click Create service account.
If you prefer to download the archive file manually, you have downloaded the appropriate archive file to your Ansible control node. In this situation, you must download the archive file to the same directory as your custom playbook on the Ansible control node. For more information about downloading archive files, see the Red Hat JBoss Enterprise Application Platform Installation Guide.
NoteBecause patch updates are cumulative, you only need to download the archive file for the patch release that you want to install. You do not need to download any previous patch updates.
If you manually download the archive file, you do not need to extract this file on your Ansible control node. In this situation, the JBoss EAP collection extracts the archive file automatically.
Procedure
-
On your Ansible control node, open the
vars.ymlfile. Set the
eap_apply_cpvariable toTrue.For example:
[...] eap_version: 7.4.0 [...] eap_apply_cp: TrueNoteEnsure that the
eap_versionvariable is set to the base release for the appropriate product version (for example,7.4.0).The JBoss EAP collection is configured to install the latest patch update by default. The collection contacts the Red Hat Customer Portal to determine the correct patch to install.
If you want the collection to install a specified patch release rather than the latest patch update, set the
eap_patch_versionvariable to the patch release that you want to install.For example:
[...] eap_apply_cp: True eap_patch_version: 7.4.2Based on the preceding example, the collection installs the cumulative 7.4.2 patch only, even if later patches are also available.
When the
eap_apply_cpvariable is set toTrue, the JBoss EAP collection contacts the Red Hat Customer Portal by default to check if new patch updates are available. The collection also downloads patch updates, if necessary. To ensure successful contact with the Red Hat Customer Portal, set therhn_usernameandrhn_passwordvariables to specify your Red Hat service account credentials.For example:
[...] rhn_username: <client_ID> rhn_password: <client_secret>In the preceding example, replace <client_ID> and <client_secret> with the client ID and secret that are associated with your Red Hat service account.
NoteIf a copy of the appropriate archive file already exists on your Ansible control node, the collection does not download this archive file again.
If the
eap_patch_versionvariable is set to a specific patch release, the collection downloads the specified patch release only, even if later patches are also available.If you prefer to download the archive file manually or you have already obtained this file in some other way, you can enforce a fully offline installation, as described in Step 5.
If you want to enforce a fully offline installation and prevent the collection from contacting the Red Hat Customer Portal, set the
eap_offline_installvariable toTrue.For example:
[...] eap_offline_install: TrueNoteThe
eap_offline_installvariable is useful if your Ansible control node does not have internet access or you want the collection to avoid contacting the Red Hat Customer Portal for file downloads. In this situation, you must set theeap_patch_versionvariable to the patch release you want to install.Ensure that you have copied the archive file for the appropriate patch update to your Ansible control node. In this situation, you must copy the archive file to the same directory as your custom playbook on the Ansible control node.
If you set the
eap_offline_installvariable toTrue, the collection does not attempt to contact the Red Hat Customer Portal, even if you have also set therhn_usernameandrhn_passwordvariables to permit automatic file downloads.-
Save your changes to the
vars.ymlfile.
By setting these variables, as appropriate, you enable the JBoss EAP collection to install the product patch updates automatically on your target hosts when you subsequently run the playbook.
3.2. Ensuring that a JDK is installed on the target hosts Copy linkLink copied to clipboard!
JBoss EAP requires that a Java Development Kit (JDK) is already installed as a prerequisite on your target hosts to ensure that JBoss EAP operates successfully. A JDK includes a Java Runtime Environment (JRE) and Java Virtual Machine (JVM), which must be available on any host where you want to run JBoss EAP. For a full list of JDK versions that JBoss EAP supports, see JBoss EAP 7.4 Supported Configurations.
By default, the JBoss EAP collection is configured to install the java-11-openjdk-headless package on each target host, based on the default value of the eap_java_package_name variable. If you want the JBoss EAP collection to install a different OpenJDK package version, you can modify the behavior of the collection to match your setup requirements
Consider the following guidelines for installing a JDK when you use the JBoss EAP collection:
-
If you want to install a Red Hat build of OpenJDK package other than
java-11-openjdk-headlesson your target hosts, you can set theeap_java_package_namevariable to the appropriate JDK package name. The JBoss EAP collection automatically installs the specified package on each target host when you subsequently run the playbook. If you want to install a different type of JDK that is listed in the JBoss EAP 7.4 Supported Configurations page, you must install the JDK manually on each target host. Alternatively, you can automate this process by using your own playbook. For more information about installing a different type of JDK, see the appropriate user documentation.
In this situation, ensure that you set the
eap_java_package_namevariable to an empty string.For example:
[...] eap_java_package_name: ""-
If you already have a supported JDK installed on your target hosts, ensure that you set the
eap_java_package_namevariable to an empty string, as shown in the preceding example.
Use the following procedure if you want to enable the JBoss EAP collection to install a Red Hat build of OpenJDK package other than java-11-openjdk-headless on your target hosts.
Prerequisites
- You have installed the JBoss EAP collection.
Procedure
-
On your Ansible control node, open the
vars.ymlfile. Set the
eap_java_package_namevariable to the appropriate OpenJDK package name that you want to install.For example:
[...] eap_java_package_name: java-1.8.0-openjdk-headlessBased on the preceding example, the JBoss EAP collection automatically installs the java-1.8.0-openjdk-headless package on each target host when you run the playbook.
-
Save your changes to the
vars.ymlfile.
3.3. Ensuring that a product user and group are created on the target hosts Copy linkLink copied to clipboard!
JBoss EAP requires that a product user account and user group are already created as a prerequisite on your target hosts. By default, the JBoss EAP collection handles this requirement by creating an eap user account and an eap group automatically on each target host. However, if you want the JBoss EAP collection to create a different user account and group, you can modify the behavior of the JBoss EAP collection to match your setup requirements.
The product user account is also assigned ownership of the directories that are required to run the JBoss EAP service.
Use the following procedure if you want to enable the JBoss EAP collection to create a different user account and group rather than the eap default values.
Prerequisites
- You have installed the JBoss EAP collection.
Procedure
-
On your Ansible control node, open the
vars.ymlfile. Set the
eap_userandeap_groupvariables to the appropriate product user name and group name that you want to create.For example:
[...] eap_user: myuser eap_group: myuserBased on the preceding example, the JBoss EAP collection automatically creates a
myuseruser account and group instead of creating the defaulteapuser account and group.-
Save your changes to the
vars.ymlfile.
3.4. Enabling the automated configuration of JBoss EAP subsystems Copy linkLink copied to clipboard!
You can enable the JBoss EAP collection to configure JBoss EAP subsystems with customized settings that match your setup requirements. In this situation, the JBoss EAP collection uses a YAML configuration feature for JBoss EAP.
If you want to enable the automated configuration of JBoss EAP, you must specify the appropriate configuration values in YAML format in a Jinja2 template file. Provided that you also set a variable to enable the YAML configuration feature, the JBoss EAP collection automatically creates a YAML configuration file based on the Jinja2 template settings.
Prerequisites
- You have installed the JBoss EAP collection.
Procedure
Create a Jinja2 template that contains YAML configuration values for the JBoss EAP subsystems:
-
On your Ansible control node, create a Jinja2 template named, for example,
jms_configuration.yml.j2. Add the appropriate configuration values to the template.
For example, the following content shows configuration values for the Java Message Service (JMS) queue:
jms_configuration.yml.j2: wildfly-configuration: subsystem: messaging-activemq: server: default: jms-queue: {{ queue.name }}: entries: - '{{ queue.entry }}'NoteBecause the Jinja2 file is a template, you can use placeholders for the subsystem configuration values, as shown in the preceding example. If you use placeholders in the Jinja2 template, you must specify details of these placeholders in your playbook, as described in Step 2.
- Save your changes to the Jinja2 template.
For more information about the types of YAML configuration settings that you can specify for the JBoss EAP subsystems, see Update standalone server configuration using YAML files.
-
On your Ansible control node, create a Jinja2 template named, for example,
Update the playbook to include variables for the name of the Jinja2 template and any placeholders that you specified in the template:
- On your Ansible control node, open your custom playbook.
In the
vars:section of the playbook, add a variable to specify the name of the Jinja2 template that you created in Step 1.For example, add a variable named
eap_yml_configswith a value ofjms.configuration.yml.j2:--- - name: "JBoss EAP installation and configuration" hosts: all become: true vars: eap_yml_configs: - jms_configuration.yml.j2If you specified placeholders for the configuration values in the Jinja2 template, update the
vars:section of your playbook with the appropriate placeholder details.For example, add variables for the
queue.nameandqueue.entryplaceholders that you specified in Step 1:--- [...] vars: queue: name: MyQueue entry: 'java:/jms/queue/MyQueue' eap_yml_configs: - jms_configuration.yml.j2- Save your changes to the custom playbook.
Enable the YAML configuration feature.
-
On your Ansible control node, open the
vars.ymlfile. Set the
eap_enable_yml_configvariable toTrue.For example:
[...] eap_enable_yml_config: TrueSave your changes to the
vars.ymlfile.NoteThe
eap_enable_yml_configvariable is set toFalseby default. If you want to enable the automated configuration of JBoss EAP subsystems, you must set theeap_enable_yml_configvariable toTrue.
-
On your Ansible control node, open the
By performing all the steps in this procedure, as appropriate, you enable the JBoss EAP collection to create YAML configuration files based on your Jinja2 template settings when you subsequently run the playbook.
3.5. Enabling the automated deployment of JBoss EAP applications on your target hosts Copy linkLink copied to clipboard!
You can also automate the deployment of web applications on your target JBoss EAP hosts by adding customized tasks to the playbook. If you want to deploy a new or updated application, the JBoss EAP collection provides a reusable task for this purpose.
The following procedure assumes that you have created a custom playbook.
Prerequisites
- You have installed the JBoss EAP collection.
- You are familar with general Ansible concepts and creating Ansible playbooks. For more information, see the Ansible documentation.
Procedure
- On your Ansible control node, open your custom playbook.
In the
tasks:section of the playbook, add a task to deploy the appropriate web application.For example:
[...] post_tasks: [...] - name: "Deploy webapp" ansible.builtin.include_role: name: eap_utils tasks_from: jboss_cli.yaml vars: jboss_cli_query: "'deploy --force {{ path_to_warfile }}'" [...]- Save your changes to the playbook.