-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
677 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_store | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,115 @@ | ||
# ansible-websphere | ||
Ansible modules for WebSphere Application Server | ||
# README | ||
|
||
## ibmim.py | ||
This module installs or uninstalls IBM Installation Manager. | ||
#### Options | ||
| Parameter | Required | Default | Choices | Comments | | ||
|:---------|:--------|:---------|:---------|:---------| | ||
| state | true | N/A | present, abcent | present=install, abcent=uninstall | | ||
| src | true | N/A | N/A | Path to installation files for Installation Manager | | ||
| dest | false | N/A | /opt/IBM/InstallationManager | Path to desired installation directory of Installation Manager | | ||
| logdir | false | N/A | N/A | Path and file name of installation log file | | ||
``` | ||
# Example: | ||
# Install: | ||
ibmim: state=present src=/some/dir/install/ logdir=/tmp/im_install.log | ||
# Uninstall | ||
ibmim: state=abcent dest=/opt/IBM/InstallationManager | ||
``` | ||
|
||
## ibmwas.py | ||
This module installs or uninstalls IBM WebSphere products using Installation Manager. | ||
#### Options | ||
| Parameter | Required | Default | Choices | Comments | | ||
|:---------|:--------|:---------|:---------|:---------| | ||
| state | true | present | present, abcent | present=install,abcent=uninstall | | ||
| ibmim | true | N/A | N/A | Path to installation directory of Installation Manager | | ||
| dest | true | N/A | N/A | Path to destination installation directory | | ||
| im_shared | true | N/A | N/A | Path to Installation Manager shared resources folder | | ||
| repo | true | N/A | N/A | URL or path to the installation repository used by Installation Manager to install WebSphere products | | ||
| offering | true | com.ibm.websphere.ND.v85 | N/A | Name of the offering which you want to install | | ||
|
||
``` | ||
# Example: | ||
# Install: | ||
ibmwas: state=present ibmim=/opt/IBM/InstallationManager/ dest=/usr/local/WebSphere/AppServer im_shared=/usr/local/WebSphere/IMShared repo=http://example.com/was-repo/ offering=com.ibm.websphere.ND.v85 | ||
# Uninstall: | ||
ibmwas: state=abcent ibmim=/opt/IBM/InstallationManager dest=/usr/local/WebSphere/AppServer/ | ||
``` | ||
|
||
## liberty_server.py | ||
This module start os stops a Liberty Profile server | ||
#### Options | ||
| Parameter | Required | Default | Choices | Comments | | ||
|:---------|:--------|:---------|:---------|:---------| | ||
| state | true | started | started, stopped | N/A | | ||
| name | true | N/A | N/A | Name of the app server | | ||
| libertydir | true | N/A | N/A | Path to binary files of the application server | | ||
``` | ||
# Example: | ||
# Start: | ||
liberty_server: state=started libertydir=/usr/local/WebSphere/Liberty/ name=my-server-01 | ||
# Stop: | ||
liberty_server: state=stopped libertydir=/usr/local/WebSphere/Liberty/ name=my-server-01 | ||
``` | ||
|
||
## profile_dmgr.py | ||
This module creates or removes a WebSphere Application Server Deployment Manager profile. Requires a Network Deployment installation. | ||
#### Options | ||
| Parameter | Required | Default | Choices | Comments | | ||
|:---------|:--------|:---------|:---------|:---------| | ||
| state | true | present | present,abcent | present=create,abcent=remove | | ||
| wasdir | true | N/A | N/A | Path to installation location of WAS | | ||
| name | true | N/A | N/A | Name of the profile | | ||
| cell_name | true | N/A | N/A | Name of the cell | | ||
| host_name | true | N/A | N/A | Host Name | | ||
| node_name | true | N/A | N/A | Node name of this profile | | ||
| username | true | N/A | N/A | Administrative user name | | ||
| password | true | N/A | N/A | Administrative user password | | ||
``` | ||
# Example: | ||
# Create: | ||
profile_dmgr: state=present wasdir=/usr/local/WebSphere/AppServer/ name=dmgr cell_name=devCell host_name=localhost node_name=devcell-dmgr username=admin password=allyourbasearebelongtous | ||
# Remove: | ||
profile_dmgr: state=abcent wasdir=/usr/local/WebSphere/AppServer/ name=dmgr | ||
``` | ||
|
||
## profile_liberty.py | ||
This module creates or removes a Liberty Profile server runtime | ||
#### Options | ||
| Parameter | Required | Default | Choices | Comments | | ||
|:---------|:--------|:---------|:---------|:---------| | ||
| state | true | present | present,abcent | present=create,abcent=remove | | ||
| libertydir | true | N/A | N/A | Path to install location of Liberty Profile binaries | | ||
| name | true | N/A | N/A | Name of the server which is to be created/removed | | ||
``` | ||
# Example: | ||
# Create: | ||
profile_liberty: state=present libertydir=/usr/local/WebSphere/Liberty/ name=server01 | ||
# Remove | ||
profile_liberty: state=abcent libertydir=/usr/local/WebSphere/Liberty/ name=server01 | ||
``` | ||
|
||
## profile_nodeagent.py | ||
This module creates or removes a WebSphere Application Server Node Agent profile. Requires a Network Deployment installation. | ||
#### Options | ||
| Parameter | Required | Default | Choices | Comments | | ||
|:---------|:--------|:---------|:---------|:---------| | ||
| state | true | present | present,abcent | present=create,abcent=remove | | ||
| wasdir | true | N/A | N/A | Path to installation location of WAS | | ||
| name | true | N/A | N/A | Name of the profile | | ||
| cell_name | true | N/A | N/A | Name of the cell | | ||
| host_name | true | N/A | N/A | Host Name | | ||
| node_name | true | N/A | N/A | Node name of this profile | | ||
| username | true | N/A | N/A | Administrative user name of the deployment manager | | ||
| password | true | N/A | N/A | Administrative user password of the deployment manager | | ||
| dmgr_host | true | N/A | N/A | Host name of the Deployment Manager | | ||
| dmgr_port | true | N/A | N/A | SOAP port number of the Deployment Manager | | ||
| federate | false | N/A | N/A | Wether the node should be federated to a cell. If true, cell name cannot be the same as the cell name of the deployment manager. | | ||
``` | ||
# Example: | ||
# Create | ||
profile_nodeagent: state=present wasdir=/usr/local/WebSphere/AppServer/ name=nodeagent cell_name=devCellTmp host_name=localhost node_name=devcell-node1 username=admin password=allyourbasearebelongtous dmgr_host=localhost dmgr_port=8879 federate=true | ||
# Remove: | ||
profile_dmgr: state=abcent wasdir=/usr/local/WebSphere/AppServer/ name=nodeagent | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/python | ||
|
||
# | ||
# Author: Amir Mofasser <amir.mofasser@gmail.com> | ||
# | ||
# This is an Anible module. Installs/Uninstall IBM Installation Manager | ||
# | ||
|
||
import os | ||
import subprocess | ||
import platform | ||
import datetime | ||
|
||
def main(): | ||
|
||
# Read arguments | ||
module = AnsibleModule( | ||
argument_spec = dict( | ||
state = dict(default='present', choices=['present', 'abcent']), | ||
src = dict(required=True), | ||
dest = dict(required=False), | ||
logdir = dict(required=False) | ||
) | ||
) | ||
|
||
state = module.params['state'] | ||
src = module.params['src'] | ||
dest = module.params['dest'] | ||
logdir = module.params['logdir'] | ||
|
||
if state == 'present': | ||
|
||
# Check if paths are valid | ||
if not os.path.exists(src+"/install"): | ||
module.fail_json(msg=src+"/install not found") | ||
if not os.path.exists(logdir): | ||
if not os.listdir(logdir): | ||
os.makedirs(logdir) | ||
|
||
logfile = platform.node() + "_ibmim_" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S") + ".xml" | ||
child = subprocess.Popen([src+"/install -acceptLicense --launcher.ini "+src+"/silent-install.ini -log " + logdir+"/"+logfile], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
stdout_value, stderr_value = child.communicate() | ||
if child.returncode != 0: | ||
module.fail_json(msg="IBM IM installation failed", stderr=stderr_value, stdout=stdout_value) | ||
|
||
# Module finished | ||
module.exit_json(changed=True, msg="IBM IM installed successfully") | ||
|
||
if state == 'abcent': | ||
uninstall_dir = "/var/ibm/InstallationManager/uninstall/uninstallc" | ||
if not os.path.exists("/var/ibm/InstallationManager/uninstall/uninstallc"): | ||
module.fail_json(msg=uninstall_dir + " does not exist") | ||
child = subprocess.Popen([uninstall_dir], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
stdout_value, stderr_value = child.communicate() | ||
if child.returncode != 0: | ||
module.fail_json(msg="IBM IM uninstall failed", stderr=stderr_value, stdout=stdout_value) | ||
|
||
# Module finished | ||
module.exit_json(changed=True, msg="IBM IM uninstalled successfully", stdout=stdout_value) | ||
|
||
|
||
# import module snippets | ||
from ansible.module_utils.basic import * | ||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/usr/bin/python | ||
|
||
# | ||
# Author: Amir Mofasser <amir.mofasser@gmail.com> | ||
# | ||
# This is an Ansible module. Installs/Uninstall IBM WebSphere Application Server Binaries | ||
# | ||
# $IM_INSTALL_DIR/eclipse/tools/imcl install com.ibm.websphere.ND.v85 | ||
# -repositories $ND_REPO_DIR | ||
# -installationDirectory $ND_INSTALL_DIR | ||
# -sharedResourcesDirectory $IM_SHARED_INSTALL_DIR | ||
# -acceptLicense -showProgress | ||
|
||
import os | ||
import subprocess | ||
import platform | ||
import datetime | ||
import shutil | ||
|
||
def main(): | ||
|
||
# WAS offerings | ||
offerings = [ | ||
'com.ibm.websphere.ND.v85', | ||
'com.ibm.websphere.IHS.v85', | ||
'com.ibm.websphere.PLG.v85', | ||
'com.ibm.websphere.WCT.v85', | ||
'com.ibm.websphere.liberty.IBMJAVA.v70', | ||
'com.ibm.websphere.liberty.v85' | ||
] | ||
|
||
# Read arguments | ||
module = AnsibleModule( | ||
argument_spec = dict( | ||
state = dict(default='present', choices=['present', 'abcent']), | ||
ibmim = dict(required=True), | ||
dest = dict(required=True), | ||
im_shared = dict(required=False), | ||
repo = dict(required=False), | ||
offering = dict(default='com.ibm.websphere.ND.v85', choices=offerings), | ||
ihs_port = dict(default=8080), | ||
logdir = dict(required=False) | ||
) | ||
) | ||
|
||
state = module.params['state'] | ||
ibmim = module.params['ibmim'] | ||
dest = module.params['dest'] | ||
im_shared = module.params['im_shared'] | ||
repo = module.params['repo'] | ||
ihs_port = module.params['ihs_port'] | ||
offering = module.params['offering'] | ||
logdir = module.params['logdir'] | ||
|
||
# Check if paths are valid | ||
if not os.path.exists(ibmim+"/eclipse"): | ||
module.fail_json(msg=ibmim+"/eclipse not found") | ||
|
||
# Installation | ||
if state == 'present': | ||
child = subprocess.Popen([ibmim+"/eclipse/tools/imcl install " + offering + " -repositories " + repo + " -installationDirectory " + dest + " -sharedResourcesDirectory " + im_shared + " -acceptLicense -showProgress -properties user.ihs.httpPort=" + str(ihs_port)], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
stdout_value, stderr_value = child.communicate() | ||
if child.returncode != 0: | ||
module.fail_json(msg="WAS ND install failed", stdout=stdout_value, stderr=stderr_value) | ||
|
||
module.exit_json(changed=True, msg="WAS ND installed successfully", stdout=stdout_value) | ||
|
||
# Uninstall | ||
if state == 'abcent': | ||
if not os.path.exists(logdir): | ||
if not os.listdir(logdir): | ||
os.makedirs(logdir) | ||
logfile = platform.node() + "_wasnd_" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S") + ".xml" | ||
child = subprocess.Popen([ibmim+"/eclipse/IBMIM --launcher.ini " + ibmim + "/eclipse/silent-install.ini -input " + dest + "/uninstall/uninstall.xml -log " + logdir+"/"+logfile], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
stdout_value, stderr_value = child.communicate() | ||
if child.returncode != 0: | ||
module.fail_json(msg="WAS ND uninstall failed", stdout=stdout_value, stderr=stderr_value) | ||
|
||
# Remove AppServer dir forcefully so that it doesn't prevents us from | ||
# reinstalling. | ||
shutil.rmtree(dest, ignore_errors=False, onerror=None) | ||
|
||
module.exit_json(changed=True, msg="WAS ND uninstalled successfully", stdout=stdout_value) | ||
|
||
# import module snippets | ||
from ansible.module_utils.basic import * | ||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/python | ||
|
||
# | ||
# Author: Amir Mofasser <amir.mofasser@gmail.com> | ||
# | ||
# This is an Ansible module. Start/Stop a liberty server | ||
# | ||
# $LIBERTY_SERVER_DIR/server stop <server_name> | ||
# $LIBERTY_SERVER_DIR/server start <server_name> | ||
# | ||
|
||
import os | ||
import subprocess | ||
import platform | ||
import datetime | ||
|
||
def main(): | ||
|
||
# Read arguments | ||
module = AnsibleModule( | ||
argument_spec = dict( | ||
state = dict(default='started', choices=['started', 'stopped']), | ||
name = dict(required=True), | ||
libertydir = dict(required=True) | ||
) | ||
) | ||
|
||
state = module.params['state'] | ||
name = module.params['name'] | ||
libertydir = module.params['libertydir'] | ||
|
||
# Check if paths are valid | ||
if not os.path.exists(libertydir): | ||
module.fail_json(msg=libertydir+" does not exists") | ||
|
||
if state == 'stopped': | ||
child = subprocess.Popen([libertydir+"/bin/server stop " + name], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
stdout_value, stderr_value = child.communicate() | ||
if child.returncode != 0: | ||
if not stderr_value.find("is not running") < 0: | ||
module.fail_json(msg=name + " stop failed", stdout=stdout_value, stderr=stderr_value) | ||
|
||
module.exit_json(changed=True, msg=name + " stopped successfully", stdout=stdout_value) | ||
|
||
if state == 'started': | ||
child = subprocess.Popen([libertydir+"/bin/server start " + name], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
stdout_value, stderr_value = child.communicate() | ||
if child.returncode != 0: | ||
if not stderr_value.find("is running with process") < 0: | ||
module.fail_json(msg=name + " start failed", stdout=stdout_value, stderr=stderr_value) | ||
|
||
module.exit_json(changed=True, msg=name + " started successfully", stdout=stdout_value) | ||
|
||
|
||
# import module snippets | ||
from ansible.module_utils.basic import * | ||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.