The article A tutorial on Middleware Automation Collections discussed using the ansible-galaxy tool to install Ansible Content Collections on a control node. It also guides you in using the ansible-navigator utility and Ansible Execution Environments to perform automation tasks. Finally, an overview of the ansible-middleware-ee execution environment from the Ansible Middleware project is provided. It describes how this EE includes all of the Ansible Content Collections and their dependencies.
In this tutorial, we will leverage the ansible-middleware-ee Execution Environment as the basis for carrying out automation activities. Let's get started using the JBoss Web Server collection, provided by the Ansible Middleware team, which can help automate the management of Red Hat JBoss Web Server.
Step 1: Use the ansible-navigator utility
Let’s use the execution environment and the ansible-navigator utility to automate and provision the JBoss Web Server collection. The ansible-middleware-ee Execution Environment contains all the latest upstream collections within the image, so no additional actions are needed. To browse the set of collections included in the image, run the following command:
$ ansible-navigator --eei quay.io/ansible-middleware/ansible-middleware-ee:latest collections
Name Version Shadowed Type Path
0│ansible.builtin 2.15.3 False contained /usr/local/lib/python3.9/si
1│ansible.netcommon 5.1.2 False contained /usr/share/ansible/collecti
2│ansible.posix 1.5.4 False contained /usr/share/ansible/collecti
3│ansible.utils 2.10.3 False contained /usr/share/ansible/collecti
4│community.general 7.3.0 False contained /usr/share/ansible/collecti
5│middleware_automation.amq 1.3.8 False contained /usr/share/ansible/collecti
6│middleware_automation.amq_s0.0.5 False contained /usr/share/ansible/collecti
7│middleware_automation.commo1.1.2 False contained /usr/share/ansible/collecti
8│middleware_automation.infin1.2.0 False contained /usr/share/ansible/collecti
9│middleware_automation.jws 1.2.3 False contained /usr/share/ansible/collecti
10│middleware_automation.keycl1.2.8 False contained /usr/share/ansible/collecti
11│middleware_automation.redha1.2.2 False contained /usr/share/ansible/collecti
12│middleware_automation.wildf1.3.4 False contained /usr/share/ansible/collecti
Step 2: Set up the inventory
Let's now set up an instance of the JBoss Web Server. Create an inventory file that includes a Red Hat Enterprise Linux 8 machine, the IP address of the instance, and the associated login information that Ansible can use. For this demonstration, SSH keys are being used instead of passwords. These SSH keys need to be available on the control node and the location of the private key is referenced in the inventory file. The inventory file look should look similar to the following:
[jws]
jws-0 ansible_host=10.0.0.1 ansible_user=root ansible_ssh_private_key_file=”path to your private key”
Step 3: Set up the vars.yml file
On the Ansible control node, create a vars.yml
file which will contain variables to customize the execution of the Ansible automation. To specify the JBoss Web Server version to install, set the jws_version
variable. For example, set jws_version
to 5.7.0 to install that specific version of the server. By default, the collection installs the latest patch update. You can set jws_apply_patchs
to true and specify the jws_patch_version
with the specific version of the patch to install. We can set the jws_java_version
variable to set the appropriate JDK version. For example, we can set the variable to 1.8.0
or 11
or 17
. The collection also configures a systemd service by specifying jws_systemd_enabled
as true
. Once configured, the vars.yml
file appears similar to the following:
---
jws_setup: true
jws_java_version: 17
jws_listen_http_bind_address: 127.0.0.1
jws_systemd_enabled: True
jws_service_systemd_type: forking
jws_selinux_enabled: False
Step 4: Install and configure the JBoss Web Server
Create a file called jws.yml
containing a playbook to install and configure the JBoss Web Server on the target hosts. In addition, it will also deploy a web application to demonstrate the functionality of the web server. See below:
---
- name: "Red Hat JBoss Web Server installation and configuration"
hosts: all
become: True
vars_files:
- vars.yml
roles:
- redhat.jws.jws
tasks:
- name: "Deploy webapp"
ansible.builtin.get_url:
url: "https://drive.google.com/uc?export=download&id=1w9ss5okctnjUvRAxhPEPyC7DmbUwmbhb"
dest: "{{ jws_home }}/webapps/info.war"
Step 5: Run the Ansible Playbook
With all of the prerequisite and configuration steps complete, run the Ansible Playbook using ansible-navigator
and the execution environment to configure the JBoss Web Server on the remote hosts:
$ ansible-navigator --eei quay.io/ansible-middleware/ansible-middleware-ee:latest run jws.yml -i inventory -m stdout --become
Once the JWS service is deployed, start an SSH to the instance to check the status of the systemd service:
ssh root@10.0.0.1 systemctl status jws.service
We can also check if the port is accessible or not using the following command:
# curl -I http://localhost:9990/health
Alternatively, we can perform validation checks using the validation role from the collection. To do so, create a new file called validation.yml
with the following content.
---
- name: "Red Hat JBoss Web Server validation"
hosts: all
become: true
vars_files:
- vars.yml
roles:
- middleware_automation.jws.jws_validation
Now, invoke the validation playbook using ansible-navigator
:
$ ansible-navigator --eei quay.io/ansible-middleware/ansible-middleware-ee:latest run validation.yml -i inventory -m stdout --become
In this tutorial, we have demonstrated how to use the Ansible middleware execution environment and set up JBoss Web Server using the Ansible Content Collections for JBoss Web Server. We can also deploy JBoss Web Server using the certified JBoss Web Server collection on the Ansible Automation Hub. You can check out the other collections and demos within the GitHub organization: ansible-middleware and the Middleware Automation Collections website.