Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java mod #71

Merged
merged 10 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- ihs-v90-rockylinux8
- ohs-v12.2.1-rockylinux8
- liberty-rockylinux8
- open-liberty-rockylinux8
- weblogic-rockylinux8
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ name: spm_middleware

# The version of the collection. Must be compatible with semantic versioning
# Please note. version also exists in /github/workflows/release.yml and will need to be update also
version: 1.4.5
version: 1.5.0

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand Down
13 changes: 13 additions & 0 deletions molecule/__open-liberty/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Converge
hosts: all

collections:
- merative.spm_middleware

vars:
download_url: "{{ lookup('env', 'ARTIFACTORY_URL') }}/{{ lookup('env', 'ARTIFACTORY_REPO') }}/SoftwareInstallers"
download_header: { 'X-JFrog-Art-Api': "{{ lookup('env', 'ARTIFACTORY_TOKEN') }}"}

roles:
- open-liberty
26 changes: 26 additions & 0 deletions molecule/__open-liberty/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
# This is an example playbook to execute Ansible tests.

- name: Verify
hosts: all
# The pre_tasks section is used to perform some tasks before the main tasks run.
# It's a good place for setup tasks or data collection.
pre_tasks:
# - name: Check packages
# # Assuming 'iim_info' module is part of the 'iim' role or a custom module.
# # If it's a custom module, ensure that it's properly located in the 'library' directory inside the role.
# iim_info:
# iim_path: /opt/IBM/InstallationManager
# register: iim_info
- name: Get jvm.options
slurp:
src: /opt/IBM/WebSphere/Liberty/wlp/usr/shared/jvm.options
register: jvm_options

tasks:
# - name: Check that the correct packages are installed
- name: Check that jvm.options contains the expected content
# Using 'assert' module to check if '-Xmx1024m' is present in 'jvm.options' file.
assert:
that:
- "'-Xmx1024m' in (jvm_options['content'] | b64decode)"
34 changes: 34 additions & 0 deletions molecule/open-liberty-rockylinux8/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
driver:
name: docker
provider:
name: docker

lint: |
set -e
yamllint .

platforms:
- name: rockylinux8
image: rockylinux:8
dockerfile: ../_resources/Dockerfile.j2
pre_build_image: False
privileged: True
volume_mounts:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
environment:
container: docker

provisioner:
name: ansible
log: true
config_options:
defaults:
stderr_callback: debug
stdout_callback: debug
env:
ANSIBLE_FORCE_COLOR: 'true'
playbooks:
converge: ../__open-liberty/converge.yml
verify: ../__open-liberty/verify.yml
43 changes: 43 additions & 0 deletions roles/open-liberty/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# open-liberty

The `open-liberty` role will install IBM WebSphere Open Liberty.

## Requirements

N/A

## Role Variables

| Property Name | Default value |
| ----------------------- | --------------------------------------------------- |
| `liberty_install_path` | `/opt/IBM/WebSphere/Liberty/wlp` |
| `liberty_version` | `23.0.0.12` |
| `liberty_default_heapsize` | `1024m` |
| `liberty_enable_verbose_gc` | `false` |
| `liberty_extra_jvm_options` | `[]` |
| ----------------------- | --------------------------------------------------- |
| `profiled_path` | `/opt/profile.d` |

| `download_url` | # Set this if installation zips are being downloaded from a http server|
| `download_header` | # Use this in conjunction with `download_url` |

| `liberty_installers_path`| # Set these to your downloaded zip filepath if copying from local|
| `liberty_java_zip_path` | |
| ------------------------ | -----------------------------------------------------------------|

## Dependencies

None

## Example Playbook

```
- hosts: servers
roles:
- role: merative.spm_middleware.open-liberty
liberty_version: 23.0.0.12
```

## License

MIT
20 changes: 20 additions & 0 deletions roles/open-liberty/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---

liberty_install_path: /opt/IBM/WebSphere/Liberty
jdk_install_path: /opt/IBM/WebSphere/Liberty/java/17

liberty_version: 23.0.0.12

# Default JVM Options
liberty_default_heapsize: 1024m
liberty_enable_verbose_gc: false
liberty_extra_jvm_options: []
security_username: websphere
# use encrypted password
security_password: dummypassword

# Common
profiled_path: /opt/profile.d
# Server info for downloading installers / repos directly, leave blank to copy
# download_url: # e.g. https://artifactory/repo
# download_header: # e.g. X-JFrog-Art-Api: "{{ lookup('env', 'MYTOKEN') }}"
39 changes: 39 additions & 0 deletions roles/open-liberty/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
galaxy_info:
author: SPM DevOps Team
description: Install WebSphere Liberty.
company: Watson Health SPM

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker

license: MIT

min_ansible_version: 2.9

#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: EL
versions:
- 7
huangjien marked this conversation as resolved.
Show resolved Hide resolved
- 8

galaxy_tags:
[]
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

dependencies:
[]
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
42 changes: 42 additions & 0 deletions roles/open-liberty/tasks/env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
- name: "Create {{ profiled_path }}"
file:
path: "{{ profiled_path }}"
mode: 0755
state: directory
when: ansible_os_family != "Windows"

- name: "Create {{ profiled_path }}/liberty.sh"
copy:
dest: "{{ profiled_path }}/liberty.sh"
content: |
#!/bin/bash
WLP_HOME={{ liberty_install_path }}/wlp
export WLP_HOME

JAVA_HOME={{ jdk_install_path }}
export JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH:$WLP_HOME/bin
mode: 0755
when: ansible_os_family != "Windows"

- name: Create /opt/.profile
copy:
dest: /opt/.profile
content: |
#!/bin/bash
PATH=.:$PATH

if [ -e {{ profiled_path }} ]; then
if [ "$PS1" ]; then
ls -l {{ profiled_path }}/*.sh
fi
for lizard in {{ profiled_path }}/*.sh ; do
. $lizard
done
fi

LANG=en_US.ISO-8859-1
umask 002
mode: 0755
when: ansible_os_family != "Windows"
83 changes: 83 additions & 0 deletions roles/open-liberty/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
- name: Include version variables
include_vars: "v{{ liberty_version }}.yml"

- name: Download Liberty repo
get_url:
dest: /tmp/liberty.zip
url: "{{ download_url }}/{{ liberty_installers_path }}"
headers: "{{ download_header }}"
when: download_url is defined

- name: Download Liberty repo
get_url:
dest: /tmp/jdk.zip
url: "{{ download_url }}/{{ liberty_java_zip_path }}"
headers: "{{ download_header }}"
when: download_url is defined

- name: Prepare Open Liberty Folder
file:
path: "{{ liberty_install_path }}"
state: directory
owner: root
group: root

- name: Prepare Open Liberty Server Folder
file:
path: "{{ liberty_install_path }}/wlp/usr/shared"
state: directory
owner: root
group: root

- name: Install Open-Liberty
unarchive:
src: /tmp/liberty.zip
dest: "{{ liberty_install_path }}"
creates: "{{ liberty_install_path }}/repository.config"
remote_src: yes

- name: Prepare Open JDK Folder
file:
path: "{{ jdk_install_path }}"
state: directory
owner: root
group: root

- name: Install OpenJDK
unarchive:
src: /tmp/jdk.zip
dest: "{{ jdk_install_path }}"
creates: "{{ jdk_install_path }}/repository.config"
remote_src: yes

- name: Create /opt/Props
file:
path: /opt/Props
mode: 0755
state: directory
when: ansible_os_family != "Windows"

- name: Copy AppServer.properties
template:
dest: /opt/Props/AppServer.properties
src: AppServer.properties.j2
mode: 0644
force: no

- name: Create environment files
include_tasks: env.yml

- name: Render jvm.options
template:
src: jvm.options.j2
dest: "{{ liberty_install_path }}/wlp/usr/shared/jvm.options"
mode: 0644

- name: Clean up
file:
path: "{{ item }}"
state: absent
loop:
- /tmp/liberty.zip
- /tmp/jdk.zip
32 changes: 32 additions & 0 deletions roles/open-liberty/templates/AppServer.properties.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## APPLICATION SERVER PROPERTIES

## IT IS VERY IMPORTANT TO USE '/' FOR DIRECTORY PATHS. ##

# Property to indicate whether WLS/SAP or WAS is installed.
as.vendor=WLP

# The username and password for admin server.
security.username={{ security_username }}
# Encrypt the plain-text password using 'build encrypt -Dpassword=<password>'
security.password={{ security_password }}

# The name of the WebSphere Node or WebLogic Domain Name.
node.name=liberty

# The name of the server on which the application will be hosted.
curam.server.name=CuramServer
curam.server.port=2809

###############################################
## THE FOLLOWING PROPERTIES ARE FOR WAS ONLY ##
###############################################
# The alias that should be used for the database authorization
curam.db.auth.alias=databaseAlias

# HTTP Port for the server on which the client
# will be accessed
curam.client.httpport=10101

# HTTP Port for the server on which the Web services
# will be accessed
curam.webservices.httpport=10102
14 changes: 14 additions & 0 deletions roles/open-liberty/templates/jvm.options.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Set the maximum heap size to {{ liberty_default_heapsize }}.
-Xmx{{ liberty_default_heapsize }}

# Set the min heap size to {{ liberty_default_heapsize }}.
-Xms{{ liberty_default_heapsize }}

{% if liberty_enable_verbose_gc %}
# Enable verbose garbage collection logs.
-verbose:gc
{% endif %}

{% for jvm_opt in liberty_extra_jvm_options %}
{{ jvm_opt }}
{% endfor %}
4 changes: 4 additions & 0 deletions roles/open-liberty/vars/v23.0.0.12.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
liberty_installers_path: WLP/openliberty-23.0.0.12.zip

liberty_java_zip_path: Java/Openjdk-Temurin-17.0.8_7-Linux.Zip
Loading