Showing posts with label automation. Show all posts
Showing posts with label automation. Show all posts

Saturday, May 25, 2024

Ansible automation for WebLogic - Part 3 installation of WebLogic 12.2.1.3.0 quick

As part of "Ansible automation for WebLogic" series - in this post we are going to install the WebLogic 12.2.1.3.0 quick installer. There is very interesting research on how and when to use ansible modules for WebLogic. This is true weekend I set my time to have how this ansible automation works for WebLogic installation task, serious focused on this task.

Prerequisites
We have already seen in the earlier posts [if not visited yet please do visit] following links:
  1. Java Installation using ansible playbook
  2. WebLogic installer unarchive copy response file, oraInst.loc file to remote node
Writing Playbook with command
In this post, I've explored on the below mentioned best suitable ansible modules
  1. command module
  2. pause module
The command module is better one,  I've choosen after trying with shell module.
Installing WebLogic is a single command that need to executed on the remote node.  As we already copied the WebLogic installer and response file, oraInst.loc to /tmp folder of remote nodes, which can be used by command. To give more generic automation solution we need to use the variables in the playbook.

The pause module will pause the playbook execution flow. To install WebLogic it requires some amount of time to complete the execution task of the command, and we need to wait till that so pause after install command is best option to use.

Ansible playbook executes command module to install WebLogic


There are some interesting sections in the playbook that we are going to use in this example post containing  :
  1. vars
  2. debug module
Ansible allows us to use vars with in the playbook and also we can define in separate file, then its reference file can be included in the playbook. There can be global variables which can be reusable in multiple playbooks depends on the roles that requires. We will discuss more on roles in the next post.

When some of the tasks in ansible modules are played then what happened we don't know. To get the insight on that we have debug moduleoption.  When debug module used we need to use the printing option with msg and the register variable to send the result or output to stdout. This stdout is raw string of JSON so that we can use the play.

Ansible playbook is so simple to design and develop code as we are seeing them since last two previous blog posts. If the playbook have a var multiple times same value required to define under vars and use them in multiple lines of a task. Here we will be using java_dir, mw_dir, mw_installer and oracle_home.

vi  wls_install.yml
---
- hosts: appservers
  remote_user: vagrant
  vars:
     java_dir: /home/vagrant/jdk1.8.0_172
     mw_dir: /tmp
     mw_installer: fmw_12.2.1.3.0_wls_quick.jar
     oracle_home: /home/vagrant/fmw
  tasks:
   - name: install WebLogic
     command: "{{ java_dir }}/bin/java -jar  {{ mw_dir }}/{{ mw_installer }} -ignoreSysPrereqs -force -novalidation ORACLE_HOME={{ oracle_home }} -responseFile {{ mw_dir }}/wls_install.rsp -invPtrLoc {{ mw_dir }}/oraInst.loc"
     register: command_result
   - debug:  msg={{ command_result.stdout.split('\n')[:-1]}}
   - name: Wait for installation complete
     pause:
        minutes: 3


The execution of WebLogic installation by playbook is simple as shown below:

vagrant@docking ~/wls-auto $ ansible-playbook -i ~/hosts wls_install.yml



Part 2 of screen shot
ansibible-playbook execution for WebLogic installation



Your valuable feedback is most important to us to improve our next articles. So request you to use the comment box.

Please write your comments and likes about this ansible series. Stay tuned to "WebLogic Tricks & Tips" for another wonderful automation soon.

Reference links
  1. debug module
  2. pause module
  3. command module

Friday, September 9, 2022

Single click installation of WebLogic 14c|12c in Linux

Current IT Trending towards devOps automation in every Software product development. I am also part of  this devOps culture. I had a thought that, How much I can leverage my regular task by making simple shell script for Installation task.

As every Oracle WebLogic system administrator would pass through this situation but only few of them who have "AUTOMATION IN MINDS" could attempt to resolve this with a nicely blended Shell script.

Here I would like to target two types of installations with two different Shell scripts:

  1. Fusion Middleware 12.2.1.2.0 WebLogic Server installation
  2. Fusion Middleware 12.2.1.2.0 Infrastructure installation


Objective of this script is to get single hit would do multiple tasks such as:

  • JAVA installation
  • setting the JAVA_HOME in shell profile
  • using Java run the WebLogic installer in silent mode

YOu can use the same logic in WebLogic 14c the latest version as well.
Assumptions:

  • Downloaded Software will be stored in common shared location. 
  • Installation of software such as JDK, WebLogic will be same mount point and directory structure
  • Linux Operating System user have bash shell!   
Knowledge base:


Auto Install pre-requisite for Application - Script 
wls.cfg
JDK_INSTALLER=jdk-8u*-linux-x64.tar.gz
JDK_INSTALLER_PATH=/u01/app/software/jdk
INSTAL_LOC=/u01/app/oracle
WLS_INSTALLER=fmw_12.*_wls.jar
WLS_INSTALLER_PATH=/u01/app/software/FMW_wls
SILENT_DIR=/u01/app/software/silent

Script name: install_wls.sh
#!/bin/bash
# This script will be installing JDK
# installing WebLogic in silent mode
#
#- Info 
#-    Author   : Pavan Devarakonda
#-    Date     : 30-March-2017
##############################################

. wls.cfg
echo "installing JDK ${JDK_INSTALLER}"
cd $INSTAL_LOC
tar -zxvf $JDK_INSTALLER_PATH/$JDK_INSTALLER

ls -l
echo confirm JDK installation
cd $INSTAL_LOC/jdk*

JAVA_HOME=`pwd`
echo "export JAVA_HOME=$JAVA_HOME">>$HOME/.bashrc
echo "export PATH=$JAVA_HOME/bin:$PATH">>$HOME/.bashrc

. $HOME/.bashrc

echo "Check for java version"
java -version

echo Installing WebLogic now...
echo .

java -jar $WLS_INSTALLER_PATH/$WLS_INSTALLER -silent -invPtrLoc $SILENT_DIR/oraInst.loc -responseFile $SILENT_DIR/wls_install.rsp

echo "WebLogic $WLS_INSTALLER installed successfully...."
echo .
echo setting MW_HOME ...
MW_HOME=`grep ORACLE_HOME $SILENT_DIR/wls_install.rsp |cut -d'=' -f2`
echo "export MW_HOME=$MW_HOME">>$HOME/.bashrc
echo "export WL_HOME=$MW_HOME/wlserver">>$HOME/.bashrc
echo "alias wlst=$MW_HOME/oracle_common/common/bin/wlst.sh">>$HOME/.bashrc
. $HOME/.bashrc
echo "Use wlst command to test everything working..."

Oracle Fusion Middleware Infrastructure installation Shell Script

Here the script is little bit improved the installer normally coming as zip file which can be uncompressed by script and also silent file will be using
INSTALL_TYPE=Fusion Middleware Infrastructure With Examples
Now the script for Infrastructure will be look like this.
#!/bin/bash
# This script will be installing JDK
# installing WebLogic in silent mode
#
JDK_INSTALLER=jdk-8u121-linux-x64.tar.gz
JDK_INSTALLER_PATH=/u01/app/software/jdk
INSTAL_LOC=/u01/app/oracle

echo "installing JDK ${JDK_INSTALLER}"
cd $INSTAL_LOC
tar -zxvf $JDK_INSTALLER_PATH/$JDK_INSTALLER

ls -l
echo confirm JDK installation
cd $INSTAL_LOC/jdk*

JAVA_HOME=`pwd`
echo "export JAVA_HOME=$JAVA_HOME">>$HOME/.bashrc
echo "export PATH=$JAVA_HOME/bin:$PATH">>$HOME/.bashrc

. $HOME/.bashrc

echo "Check for java version"
java -version

echo Installing WebLogic now...
echo .

WLS_INSTALLER=fmw_12.2.1.2.0_infrastructure_Disk1_1of1.zip
WLS_INSTALLER_PATH=/u01/app/software/FMW_wls
cd $WLS_INSTALLER_PATH
unzip $WLS_INSTALLER_PATH/$WLS_INSTALLER

INFRA_JAR=fmw_12.2.1.2.0_infrastructure.jar

SILENT_DIR=/u01/app/software/silent

java -jar $WLS_INSTALLER_PATH/$INFRA_JAR -silent -invPtrLoc $SILENT_DIR/oraInst.loc -responseFile $SILENT_DIR/fmw12.2.1_infra_install.rsp

echo "FMW Infrastructure $WLS_INSTALLER installed successfully...."
echo .
echo setting MW_HOME ...
MW_HOME=`grep ORACLE_HOME $SILENT_DIR/$SILENT_DIR/fmw12.2.1_infra_install.rsp |cut -d'=' -f2`
echo "export MW_HOME=$MW_HOME">>$HOME/.bashrc
echo "export WL_HOME=$MW_HOME/wlserver">>$HOME/.bashrc
echo "alias wlst=$MW_HOME/oracle_common/common/bin/wlst.sh">>$HOME/.bashrc
. $HOME/.bashrc
echo "Use wlst command to test everything working..."


Note: If you are running other than Linux platform you can use ksh shell .profile.

keep in touch with your comment and suggestions for improve more effective way.

cheers!!!

Tuesday, June 5, 2012

Check URL using shell script


We had an issue on production environment. Suddenly one of the webserver got crashed that no one aware of it. That was happen in the Weekend there were no users accessing at that time. When the business hour started Monday morning customer reported to service desk that one of the URL is not working for them. We middleware support team check the URL and identified that the HTTP server not working. Next action items as you know taking the logs backup and starting the HTTP server done.
As part of issue management preventive action to this there could be a monitoring of the URLs. All the web servers hosted application, load balancer that is serving the application or Application server that hosted the web application must be checked randomly or every day before business hours starts.
To do this monitoring team started working on listing out all loadbalancer URL, primary, secondary webserver URLs and also Application server hosted URL lists and checking on the browser each URL. Here is the pain-area doing this in manually there could be
Human errors, Re-testing same URL 
Each URL checking takes almost 1 min
Business have 10 domains then each domain have load balancer URL, primary, secondary webserver URL approx 30 min
Thought of the day! Why don’t we automate this task using UNIX shell scripting. My friend Pubba Praveen came up with idea using wget command.  Started brainstorming searching on internet for a scripts that could monitor the URL. Many forums, blogs, most of them are using curl command whereas Solaris box is not having this command.
Alternate to curl command we have powerful wget command on Solaris.
Challenges
1. While using wget it is downloading junk
2. We have URL list some of them are SSO enabled
The first challenge, can be fix with –spider option will avoid the downloading anything from the website.
The second challenge overcome by using --no-check-certificate option
Redirect output of command into a variable
Test the test url from the command line, that is giving output from HTTP header of that URL. From that we need only single line that shows HTTP status. The grep command will do this, but it cannot be applied directly to that command. Because the wget execution is unable to sending the response to STDOUT, rather it will send to STDERR. To fix this, redirect the STDERR to STDOUT and do this in background ( 2> &1).  You can do this by storing that into a file, but it is not optimum solution. To store it into a variable, So that grep command will be enabled to find the pattern ‘HTTP’.
Create a file with desired URL list - urls.txt
Prepared a bash script that will work as web crawler for your business to check the URL and tells you it’s host is OK or not.
Effective automation script made the script as follows:

#!/bin/bash
#=========================================================
# This script will check for the appliction url working or not
# Author: Pavan Devarakonda
# Date  : 5/29/2012
#=========================================================

# Function that check the URL returns HTTP Status Code
checkURL()
{
       # keep below 2 lines in one
       s=`(/usr/sfw/bin/wget -t 0 --spider --no-check-certificate $1) 2>&1 \
       grep HTTP| tail -1|cut -c 41-43`
       echo $s
}

#========== = = = main script = = = ===========
clear
for url in `cat urls.txt`
do
         HTTPCode=$(checkURL $url) # function call
         if [ $HTTPCode -ge 500 ]
         then
             status="DOWN"
             # mail if this have issue
         else
             status="UP"
         fi
         TIME=`date +%d-%m-%Y_%H.%M.%S`
         echo At $TIME the URL $url $HTTPCode $status
done

This script can be associated with schedule job
 1. crontab old way
2. autosys job scheduler
3. at command for trials
 
Now concern is when my webserver is down the script hangs..
Looking for help now... any comments are invited

Wednesday, July 7, 2010

Copying to multiple remote machines

Here is another interesting story of WLA (of-course mine), When I visited US in 2007 there was lot of restrictions in work places. "Hey its production you know what happen if you touch it??" "Don't open this files", "Don't enter into that folders", it will be dangerous... I know that very well what is missing in the system, where it is required a change but my hands kept criss cross!!

Days passed I got opportunity to come again on long term. Now, the whole new System is going shapeup with my hands. The system is awaiting for me since long days. :) All those sparkling colorful ideas running around my mind, got chance to flow onto the system to form various automated scripts, which are having little in size with greater capabilities.

Whenever there is a application version release the archive files(.jar, .war, .ear) need to copied to all over the remote machines. In olden days we were using 'sftp' command and its related 'put', 'mput', 'get' and 'mget' commands to complete the task. Manually double checking wheather the copying is done correct or not, by verifying in each machine content by comparing the each file sizes. Here I found a flaw that there could be chance of human error. While understanding 'Six Sigma Course', where I learnt about human errors makes greater defect to many customer's business. To avoid this better option is automation of the task as possible as much.I remembered Mr. Neil Gogte words about "Cyber Coolie". The software engineer who works as per his contractor asked him to do only those things he will do. Never think other than the work which is assigned to him. My soul shouts out 'NO!!', I cannot be a Cyber coolie any more !!

My beautiful sparkling colorful ideas SSH password less connection to multiple remote machines, powerful bright idea of 'scp' command usage with verification option built within a script come out as a wonderful shell script, which had mighty power of built-in checking with no chances of human error. When I show the execution of this script to my teammates they are very happy and appreciated me. Many productive hours are saved though this activity was disturging to other regular job. The script made almost hands free task!! Finally, That's the way team turn happy ever by using the easy script.

Script is :
TADAA!!!!!!!!!!

# Define variables values
src=
target=
hostlist=
user=
Logfile=

#=== script logic starts here ====
if [ -d $src ]
then
echo "Code folder found, preparing to transfer\n"
while read server
do
result=scp -r $src $user@${server}:$target
if [ $result -eq 0 ]
then
echo $server transfer done >> $Logfile
else
echo $server transfer failed.
exit
fi
done < $hostlist
else
echo "Code folder \"$src\" not found\n"
fi

Blurb about this blog

Blurb about this blog

Essential Middleware Administration takes in-depth look at the fundamental relationship between Middleware and Operating Environment such as Solaris or Linux, HP-UX. Scope of this blog is associated with beginner or an experienced Middleware Team members, Middleware developer, Middleware Architects, you will be able to apply any of these automation scripts which are takeaways, because they are generalized it is like ready to use. Most of the experimented scripts are implemented in production environments.
You have any ideas for Contributing to a Middleware Admin? mail to me wlatechtrainer@gmail.com
QK7QN6U9ZST6