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. Note 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: Install JBoss EAP from archive files that you can choose to download either automatically or manually from the Red Hat Customer Portal . Ensure that a supported JDK version is installed on your target hosts . Ensure that a product user account and group are created on your target hosts . 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 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 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. Note Service 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 . Note 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.yml file. To specify the JBoss EAP version that you want to install, set the eap_version variable to the appropriate base release. For example: Note Ensure that the value you specify for the eap_version variable 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 of 7.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_username and rhn_password variables to specify your Red Hat service account credentials. For example: 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. Note If 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_filename variable to specify the file that you want to install. For example: In the preceding example, replace <application_server_file> with the appropriate archive file name. Note If you did not change the file name, you do not need to set the eap_archive_filename variable. The JBoss EAP collection uses the value of the eap_version variable to determine the default file name automatically. Save your changes to the vars.yml file. 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 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. Note 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. Important 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. Note Service 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 . Note Because 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 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.yml file. Set the eap_apply_cp variable to True . For example: Note Ensure that the eap_version variable 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_version variable to the patch release that you want to install. For example: Based 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_cp variable is set to True , 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 the rhn_username and rhn_password variables to specify your Red Hat service account credentials. For example: 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. Note If 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_version variable 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_install variable to True . For example: Note The eap_offline_install variable 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 the eap_patch_version variable 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_install variable to True , the collection does not attempt to contact the Red Hat Customer Portal, even if you have also set the rhn_username and rhn_password variables to permit automatic file downloads. Save your changes to the vars.yml file. 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 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-headless on your target hosts, you can set the eap_java_package_name variable 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_name variable to an empty string. For example: If you already have a supported JDK installed on your target hosts, ensure that you set the eap_java_package_name variable to an empty string, as shown in the preceding example. Note 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.yml file. Set the eap_java_package_name variable to the appropriate OpenJDK package name that you want to install. For example: Based 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.yml file. 3.3. Ensuring that a product user and group are created on the target hosts 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. Note 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.yml file. Set the eap_user and eap_group variables to the appropriate product user name and group name that you want to create. For example: Based on the preceding example, the JBoss EAP collection automatically creates a myuser user account and group instead of creating the default eap user account and group. Save your changes to the vars.yml file. 3.4. Enabling the automated configuration of JBoss EAP subsystems 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: Note Because 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 . 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_configs with a value of jms.configuration.yml.j2 : If 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.name and queue.entry placeholders that you specified in Step 1 : Save your changes to the custom playbook. Enable the YAML configuration feature. On your Ansible control node, open the vars.yml file. Set the eap_enable_yml_config variable to True . For example: Save your changes to the vars.yml file. Note The eap_enable_yml_config variable is set to False by default. If you want to enable the automated configuration of JBoss EAP subsystems, you must set the eap_enable_yml_config variable to True . 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 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. Note 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: Save your changes to the playbook. Additional resources Files modules Net Tools modules

Commands:
[...] eap_version: 7.4.0
[...] rhn_username: <client_ID> rhn_password: <client_secret>
[...] eap_archive_filename: <application_server_file>
[...] eap_version: 7.4.0 [...] eap_apply_cp: True
[...] eap_apply_cp: True eap_patch_version: 7.4.2
[...] rhn_username: <client_ID> rhn_password: <client_secret>
[...] eap_offline_install: True
[...] eap_java_package_name: ""
[...] eap_java_package_name: java-1.8.0-openjdk-headless
[...] eap_user: myuser eap_group: myuser
jms_configuration.yml.j2: wildfly-configuration: subsystem: messaging-activemq: server: default: jms-queue: {{ queue.name }}: entries: - '{{ queue.entry }}'
--- - name: "JBoss EAP installation and configuration" hosts: all become: true vars: eap_yml_configs: - jms_configuration.yml.j2
--- [...] vars: queue: name: MyQueue entry: 'java:/jms/queue/MyQueue' eap_yml_configs: - jms_configuration.yml.j2
[...] eap_enable_yml_config: True
[...] 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 }}'" [...]