Skip to content

Commit

Permalink
Liberty role migration+alternative download (#25)
Browse files Browse the repository at this point in the history
* Liberty v1

* add liberty to tests

* change header

* fix java path

* return other tests

* Update README.md

* clean up

* sian review READMEs/comments

Co-authored-by: Roman Muntean <[email protected]>
  • Loading branch information
romakarol and Roman Muntean authored Oct 15, 2021
1 parent 3256837 commit a0f5b64
Show file tree
Hide file tree
Showing 20 changed files with 460 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ env:
- SCENARIO=iim-191-centos-8
- SCENARIO=ihs-v90-centos-8
- SCENARIO=ihs-v80-centos-7
- SCENARIO=liberty-centos-7
- SCENARIO=liberty-centos-8
- SCENARIO=weblogic-centos-7
- SCENARIO=weblogic-centos-8

stage: Molecule Tests

before_script:
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace: ibm
name: spm_middleware

# The version of the collection. Must be compatible with semantic versioning
version: 1.1.0
version: 1.1.1

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

collections:
- ibm.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:
- iim
- liberty
25 changes: 25 additions & 0 deletions molecule/__liberty/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# This is an example playbook to execute Ansible tests.

- name: Verify
hosts: all
pre_tasks:
- name: Check packages
iim_info:
iim_path: /opt/IBM/InstallationManager
register: iim_info
- name: Get jvm.options
slurp:
src: /opt/IBM/WebSphere/Liberty/usr/shared/jvm.options
register: jvm_options

tasks:
- name: Check that the correct packages are installed
assert:
that:
- "iim_info.packages | select('match', 'com.ibm.websphere.liberty.ND.*') | list | length > 0"
- "iim_info.packages | select('match', 'com.ibm.java.jdk.v8.*') | list | length > 0"
- name: Check that jvm.options contains the expected content
assert:
that:
- "'-Xmx1024m' in (jvm_options['content'] | b64decode)"
34 changes: 34 additions & 0 deletions molecule/liberty-centos-7/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: centos-7
image: centos:7
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: ../__liberty/converge.yml
verify: ../__liberty/verify.yml
34 changes: 34 additions & 0 deletions molecule/liberty-centos-8/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: centos-8
image: centos: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: ../__liberty/converge.yml
verify: ../__liberty/verify.yml
1 change: 0 additions & 1 deletion roles/iim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ None
| `download_header` | # Use this in conjunction with `download_url` |
| `iim_installer_path`| # Set this to your downloaded installers filepath if copying from local|
| # Set to remote filepath if downloading installers |
| # Default `/tmp/iim/` |
| ------------------- | ------------------------------------------------------|

## Dependencies
Expand Down
45 changes: 45 additions & 0 deletions roles/liberty/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# liberty

The `liberty` role will install IBM WebSphere Liberty.

## Requirements

IBM Installation Manager (1.9.x) must already be installed in the target environment.

## Role Variables

| Property Name | Default value |
| ----------------------- | --------------------------------------------------- |
| `liberty_install_path` | `/opt/IBM/WebSphere/Liberty` |
| `liberty_version` | `21.0.0.9` |
| `liberty_default_heapsize` | `1024m` |
| `liberty_enable_verbose_gc` | `false` |
| `liberty_extra_jvm_options` | `[]` |
| ----------------------- | --------------------------------------------------- |
| `iim_install_path` | `/opt/IBM/InstallationManager` |
| `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_fp_path` | # Set to remote filepath if downloading |
| `liberty_java_zip_path` | |
| ------------------------ | -----------------------------------------------------------------|

## Dependencies

None

## Example Playbook

```
- hosts: servers
roles:
- role: ibm.spm_middleware.liberty
liberty_version: 19.0.0.12
```

## License

MIT
17 changes: 17 additions & 0 deletions roles/liberty/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
iim_install_path: /opt/IBM/InstallationManager

liberty_install_path: /opt/IBM/WebSphere/Liberty

liberty_version: 21.0.0.9

# Default JVM Options
liberty_default_heapsize: 1024m
liberty_enable_verbose_gc: false
liberty_extra_jvm_options: []

# 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') }}"
33 changes: 33 additions & 0 deletions roles/liberty/files/AppServer.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## 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=websphere
# Encrypt the plain-text password using 'build encrypt -Dpassword=<password>'
# Below is the encryption for the default password ("websphere")
security.password=XOVRjjVTebM8gV953LGMLQ==

# 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
39 changes: 39 additions & 0 deletions roles/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
- 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.
41 changes: 41 additions & 0 deletions roles/liberty/tasks/base_install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
- name: Download Liberty repo
get_url:
dest: /tmp/repo.zip
url: "{{ download_url }}/{{ liberty_installers_path }}"
headers: "{{ download_header }}"
when: download_url is defined

- name: Create repo directory
file:
path: /tmp/repo
state: directory

- name: Copy Liberty installer repo
copy:
src: "{{ liberty_installers_path }}"
dest: "/tmp/repo.zip"
when: download_url is not defined

- name: Extract Liberty installers
unarchive:
src: /tmp/repo.zip
dest: /tmp/repo
remote_src: yes
creates: /tmp/repo/repository.config

- name: Install Liberty
iim_package:
iim_path: "{{ iim_install_path }}"
product_id: com.ibm.websphere.liberty.ND
path: "{{ liberty_install_path }}"
repo: /tmp/repo
state: present

- name: Cleanup
file:
path: "{{ item }}"
state: absent
loop:
- /tmp/repo
- /tmp/repo.zip
42 changes: 42 additions & 0 deletions roles/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 }}
export WLP_HOME
JAVA_HOME={{ liberty_install_path }}/java/8.0
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"
Loading

0 comments on commit a0f5b64

Please sign in to comment.