cant execute bashfile using ansible

624 views
Skip to first unread message

vowner

unread,
Sep 24, 2018, 9:41:12 AM9/24/18
to Ansible Project
Hi Experts,

I am automating IBM CLM application and i would need to run the application default .bat file for starting the server. Eg: (server.startup.bat). I tried with win_command, script and win_shell modules and its not running the bash file.

Could you please provide any solution.

Tony Chia

unread,
Sep 24, 2018, 10:26:18 AM9/24/18
to Ansible Project
.bat extension is for Windows batch file. Bash files typically have .sh or .bash extension.  Could you show the tasks you have tried and their respective output ? 

vivek mv

unread,
Sep 24, 2018, 12:12:39 PM9/24/18
to ansible...@googlegroups.com
Hi ,

Yes. It's .bat file and it's for stating a ibm liberty server "server.startup.bat".

--- 
 - name: start liberty server
   hosts: win
   tasks: 
     - name: start server
       Win_commad: D:\IBM\JazzTeamServer\server.startup.bat


Ansible is running this playbook without error .. but it's not starting or executing the file

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7ad6d4ce-8f35-4372-8d98-4692d44e106d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

vivek mv

unread,
Sep 24, 2018, 2:57:32 PM9/24/18
to ansible...@googlegroups.com
Hi Tony,

Any suggestions here please

vowner

unread,
Sep 25, 2018, 7:07:59 AM9/25/18
to Ansible Project
Hello Experts,

Any suggestion here... ?


On Tuesday, September 25, 2018 at 12:27:32 AM UTC+5:30, vowner wrote:
Hi Tony,

Any suggestions here please

On Mon, 24 Sep 2018, 21:42 vivek mv, <vivek....@gmail.com> wrote:
Hi ,

Yes. It's .bat file and it's for stating a ibm liberty server "server.startup.bat".

--- 
 - name: start liberty server
   hosts: win
   tasks: 
     - name: start server
       Win_commad: D:\IBM\JazzTeamServer\server.startup.bat


Ansible is running this playbook without error .. but it's not starting or executing the file

On Mon, 24 Sep 2018, 19:56 Tony Chia, <tch...@gmail.com> wrote:
.bat extension is for Windows batch file. Bash files typically have .sh or .bash extension.  Could you show the tasks you have tried and their respective output ? 

On Monday, September 24, 2018 at 6:41:12 AM UTC-7, vowner wrote:
Hi Experts,

I am automating IBM CLM application and i would need to run the application default .bat file for starting the server. Eg: (server.startup.bat). I tried with win_command, script and win_shell modules and its not running the bash file.

Could you please provide any solution.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.

Jordan Borean

unread,
Sep 25, 2018, 6:06:38 PM9/25/18
to Ansible Project
The win_command module can be used to execute batch files without any issues. If it is returning without any errors it sounds like the batch file is failing silently and not informing you of what has gone wrong. You can add some echo statements  or create files to verify whether it is truly running but I did some tests myself just now and it had no issues.

vivek mv

unread,
Sep 26, 2018, 12:08:38 AM9/26/18
to ansible...@googlegroups.com
Hello Jordan,

Thanks for your advise.

But same batch file u can execute in the server and it's working. And also through powershell it's getting executed.



On Wed, 26 Sep 2018, 03:36 Jordan Borean, <jbor...@gmail.com> wrote:
The win_command module can be used to execute batch files without any issues. If it is returning without any errors it sounds like the batch file is failing silently and not informing you of what has gone wrong. You can add some echo statements  or create files to verify whether it is truly running but I did some tests myself just now and it had no issues.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9055a44f-4c8a-4d48-9041-7ebe5952e1a4%40googlegroups.com.

Jordan Borean

unread,
Sep 26, 2018, 12:47:41 AM9/26/18
to Ansible Project
Running through Ansible is different from running locally because the tasks are being run under a WinRM logon. Windows treats network (WinRM) and interactive (local) logons differently and can have different behaviour and access permissions depending on the type of logon. My recommendations still stand;

  • Split the batch file into smaller steps and run each one manually to see if it breaks
  • Add some logging to your batch file to log each step into a file to verify that is is actually running
  • Don't use a batch file and convert to a PowerShell script instead
  • Use become on the task to replicate how it would run on an interactive logon
  • Use native PowerShell with Invoke-Command to see if that works, Ansible uses a similar mechanism to execute tasks
One thing I am curious about, the batch file is server.startup.bat which indicates this is trying to startup an executable. Unless you are using this to startup a scheduled task, service, or a process that is explicitly defined to breakaway from a job, you will find that once the initial WinRM process spawned from Ansible is completed, Windows will kill all of it's child processes.

If this is the case, you really should be using a proper scheduler like Windows SCM or Scheduled tasks to run this and not try and spawn it directly from Ansible.

Thanks

Jordan

vivek mv

unread,
Sep 26, 2018, 1:08:14 AM9/26/18
to ansible...@googlegroups.com
Hello Jordan.

Yes you are correct. Actually through ansible I already installed IBM liberty server using installer. And here the server.startup. bat file is the default IBM package getting deployed during the liberty server installation. So inorder to start the liberty server, I want to execute that batch file. Usually we are starting it through command line manually by running the batch file. 

So here I tried to automate it through ansible playbook and my play was like as given below in this mail chain.

I am using server local admin user for winrm connection and installation process. Splitting the batch file will be a difficult task for us as it is a default IBM provided package and I am not well aware of that.

Is there anyways to overcome this. I used win_shell, scrit, win_command modules and it's not happening.
Please advise me here.

I am very new to ansible and apologies for any repeated query.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

vivek mv

unread,
Sep 27, 2018, 3:06:56 AM9/27/18
to ansible...@googlegroups.com
Hi Jordan,
 Any suggestions further to guide me here in this scenario..??

Jordan Borean

unread,
Sep 27, 2018, 6:03:22 AM9/27/18
to Ansible Project
You never really said what the batch file actually does. Does it start a process that runs in the background or is it meant to run a short living process?

vowner

unread,
Sep 27, 2018, 9:35:59 AM9/27/18
to Ansible Project
Hello Jordan,

the attached are the batch file, which will start and stop IBM Liberty servers and deploy the war files on this. Once it got started, a process will be running in windows for liberty server.

server.startup.bat
_____________________

#!/bin/sh

# Licensed Materials - Property of IBM (c) Copyright IBM Corporation 2008, 2017.
# All Rights Reserved.
# Note to U.S. Government Users Restricted Rights: Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

if [ `uname` = SunOS ];
  then
    SPACE_PATTERN=' ' ;
  else
    SPACE_PATTERN='[[:space:]]' ;
fi

# Having a space in the directory name causes problems for how Tomcat handles
# the JAVA_OPTS environment variable.
pwd | grep "$SPACE_PATTERN"
if [ $? -eq 0 ];
  then /bin/echo \
ERROR:  The Jazz Team Server may not be installed in a directory whose name contains a space character.  Please relocate the jazz directory and try again.
  exit 1
fi

PWD=`pwd`
if [ "$PWD" = "/" ] ; then
   PWD=""
fi

START_DIR=`dirname "$0"`
cd "$START_DIR"

CLEAN=false
ACTION=start
LIBERTY=false
export LIBERTY

# Run in Liberty if it is installed, unless overridden by a command option
if [ -f "$PWD/liberty.server" ]; then
    LIBERTY=true;
fi

for var in "$@" 
do
   if [ "$var" = "-debug" ] ; then
      ACTION=debug
   fi
   if [ "$var" = "-clean" ] ; then
      CLEAN=true
   fi
   if [ "$var" = "-create" ] ; then
      ACTION=create
   fi
   if [ "$var" = "-run" ] ; then
      ACTION=run
   fi
   if [ "$var" = "-tomcat" ] ; then
      LIBERTY=false
   fi
done

echo $TMP | grep "$SPACE_PATTERN"
if [ $? -eq 0 ];
  then TEMP_DIR=/tmp ;
  else TEMP_DIR=${TMP:-/tmp} ;
fi

# Unset JAVA_HOME because we really want to use the JRE that is bundled
unset JAVA_HOME

# When running in a Jazz build, JRE_HOME is already set
if [ -z "$_RUNNING_IN_JAZZ_BUILD" ]; then
    # For Mac OS X (unsupported, but used by developers)
    if [ `uname` = Darwin ];
      then
        JRE_HOME=$(/usr/libexec/java_home -v 1.7)
      else
        JRE_HOME="$PWD/jre";
    fi;
fi
    
export JRE_HOME

#   Using TLS only protocols protects against CVE-2014-3566 vulnerability    
if [ `uname` = Darwin ];
  then
    JAVA_OPTS="$JAVA_OPTS -Djazz.connector.sslEnabledProtocols=\"SSLv2Hello,TLSv1,TLSv1.1,TLSv1.2\""
    JAVA_OPTS="$JAVA_OPTS -Djazz.connector.algorithm=SunX509"
  else
    JAVA_OPTS="$JAVA_OPTS -Djazz.connector.sslEnabledProtocols=\"TLSv1,TLSv1.1,TLSv1.2\""
    JAVA_OPTS="$JAVA_OPTS -Djazz.connector.algorithm=IbmX509"
fi

if [ -z "$CATALINA_HOME" ]; then
    CATALINA_HOME="$PWD/tomcat"
    export CATALINA_HOME;
fi

# Database properties may be provided by the db_system_properties environment variable
if [ -n "${db_system_properties}" ]; then
    JAVA_OPTS="$JAVA_OPTS ${db_system_properties}";
else
# The following four environment variables are used to point to the appropriate
# JDBC jar file supplied by the database vendor.  For Oracle and SQL Server, the
# environment variable should point to the driver file itself; for db2i and
# db2z, the variable should point to the directory that contains the multiple
# necessary jdbc driver files required on those platforms (for example, 
# /opt/ibm/db2/V9.7/java). For DB2, the use of DB2_ABSPATH var is optional; if not
# set the default driver packaged with the server will be used.

# Users should set these variables; if they are set, the script will respect
# their value.  If they are unset, we try locating the driver files in a
# directory under <JazzInstallDir>/server.  (For example, the default location
# for the Oracle JDBC driver is under <JazzInstallDir>/server/oracle/ojdbc8.jar).

    if [ -z "$ORACLE_JDBC_DRIVER_FILE" ] ; then
      ORACLE_JDBC_DRIVER_FILE="`cd \"$START_DIR\" 2>/dev/null && pwd || echo \"$START_DIR\"`/oracle/ojdbc8.jar" ;
    fi
    
    if [ -z "$SQLSERVER_JDBC_DRIVER_FILE" ] ; then
      SQLSERVER_JDBC_DRIVER_FILE="`cd \"$START_DIR\" 2>/dev/null && pwd || echo \"$START_DIR\"`/sqlserver/sqljdbc41.jar" ;
    fi
    
    if [ -z "$DB2I_ABSPATH" ] ; then
      DB2I_ABSPATH="`cd \"$START_DIR\" 2>/dev/null && pwd || echo \"$START_DIR\"`/db2i" ;
    fi
    
    if [ -z "$DB2Z_ABSPATH" ] ; then
      DB2Z_ABSPATH="`cd \"$START_DIR\" 2>/dev/null && pwd || echo \"$START_DIR\"`/db2z" ;
    fi
    
    JAVA_OPTS="$JAVA_OPTS -DSQLSERVER_JDBC_DRIVER_FILE=$SQLSERVER_JDBC_DRIVER_FILE"
    JAVA_OPTS="$JAVA_OPTS -DORACLE_JDBC_DRIVER_FILE=$ORACLE_JDBC_DRIVER_FILE"
    JAVA_OPTS="$JAVA_OPTS -DDB2I_JDBC=$DB2I_ABSPATH"
    JAVA_OPTS="$JAVA_OPTS -DDB2Z_JDBC=$DB2Z_ABSPATH"
    if [ -n "$DB2_ABSPATH" ] ; then
      JAVA_OPTS="$JAVA_OPTS -DDB2_ABSPATH=$DB2_ABSPATH/"
    fi;
fi

COGNOS_SDK=$START_DIR/CognosSDK
export COGNOS_SDK

JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
JAVA_OPTS="$JAVA_OPTS -Dorg.eclipse.emf.ecore.plugin.EcorePlugin.doNotLoadResourcesPlugin=true"
JAVA_OPTS="$JAVA_OPTS -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true"
JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true"
JAVA_OPTS="$JAVA_OPTS -DJAZZ_HOME=file://$PWD/conf"
JAVA_OPTS="$JAVA_OPTS -Dcom.ibm.team.repository.tempDir=$TEMP_DIR"
JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file://$PWD/conf/startup_log4j.properties"

# When run in a Jazz build, a 32-bit JRE is used, so don't set 64-bit options
if [ -z "$_RUNNING_IN_JAZZ_BUILD" ]; then
    JAVA_OPTS="$JAVA_OPTS -Xmx4G"
    JAVA_OPTS="$JAVA_OPTS -Xms4G"
    JAVA_OPTS="$JAVA_OPTS -Xmn1G"
    JAVA_OPTS="$JAVA_OPTS -XX:MaxDirectMemorySize=1G";
fi

JAVA_OPTS="$JAVA_OPTS -Dderby.locks.waitTimeout=1200"
JAVA_OPTS="$JAVA_OPTS -Dderby.locks.deadlockTimeout=1140"

if [ "$CLEAN" = "true" ] ; then
   JAVA_OPTS="$JAVA_OPTS -Djazz.clean=true"
fi
if [ "$ACTION" = "debug" ] ; then
   JAVA_OPTS="$JAVA_OPTS -Dcom.ibm.team.repository.debug.enabled=true"
   JAVA_OPTS="$JAVA_OPTS -Dcom.ibm.team.repository.debug.users=*"
fi

## *** Debug service properties ***

## Give access to restricted areas to all JazzAdmins users.

#JAVA_OPTS="$JAVA_OPTS -Dcom.ibm.team.repository.debug.users=JazzAdmins"

## Expose /repodebug/access service.
#JAVA_OPTS="$JAVA_OPTS -Dcom.ibm.team.repository.debug.accessServiceEnabled=true"

## Patch service options.
#JAVA_OPTS="$JAVA_OPTS -Dcom.ibm.team.osgi.patch.disable=true"
#JAVA_OPTS="$JAVA_OPTS -Dcom.ibm.team.osgi.patch.directory=patch"

## Required for CLM Monitoring
# JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote=true"
# JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=1099"
# JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
# JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"

## BEGIN app-specific options section
## END app-specific options section

# Enable verbose GC logging for serviceability
JAVA_OPTS="$JAVA_OPTS -verbose:gc"
if [ `uname` = SunOS ];
  then
    JAVA_OPTS="$JAVA_OPTS -d64" ;
    JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=768m -XX:ReservedCodeCacheSize=512M -XX:CodeCacheMinimumFreeSpace=2M -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass" ;
    JAVA_OPTS="$JAVA_OPTS -Djava.protocol.handler.pkgs=com.ibm.net.ssl.www2.protocol" ;
elif [ `uname` = Darwin ];
  then
    JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=1024m"
#   JAVA_OPTS="$JAVA_OPTS -XX:ReservedCodeCacheSize=512M -XX:CodeCacheMinimumFreeSpace=2M -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass"
elif [ `uname` = AIX ];
  then
    JAVA_OPTS="$JAVA_OPTS -Xgcpolicy:gencon"
    JAVA_OPTS="$JAVA_OPTS -Xnocompressedrefs"
    # Enable GC log management only for IBM JVM
    JAVA_OPTS="$JAVA_OPTS -Xverbosegclog:verbosegc.%y%m%d.%pid.txt,5,100000"
else
    JAVA_OPTS="$JAVA_OPTS -Xgcpolicy:gencon"
    # When run in a Jazz build, a 32-bit JRE is used, so don't set 64-bit options
    if [ -z "$_RUNNING_IN_JAZZ_BUILD" ]; then
        JAVA_OPTS="$JAVA_OPTS -Xcompressedrefs -Xgc:preferredHeapBase=0x100000000";
    fi
    # Enable GC log management only for IBM JVM
    JAVA_OPTS="$JAVA_OPTS -Xverbosegclog:verbosegc.%y%m%d.%pid.txt,5,100000"
fi

export JAVA_OPTS

if [ "$LIBERTY" = "true" ]; then
    ./liberty.server $ACTION;
else
    if [ ! -d "$CATALINA_HOME"/bin ]; then
        /bin/echo "ERROR:  There is no Liberty or Tomcat application server to start."
        exit 1
    fi
# healthcenter not supported on Mac
if [ `uname` != Darwin ]; then
    # health center currently disabled by default; see work item 413691
        # JAVA_OPTS="$JAVA_OPTS -agentlib:healthcenter -Dcom.ibm.java.diagnostics.healthcenter.agent.port=1972 -Dsun.rmi.registry.registryFilter=javax.rmi.CORBA.Stub"
    JAVA_OPTS="$JAVA_OPTS"
fi
    if [ "$ACTION" = "debug" ]; then
       $CATALINA_HOME/bin/catalina.sh jpda start;
    else
       $CATALINA_HOME/bin/startup.sh;
    fi;
fi

Jordan Borean

unread,
Sep 27, 2018, 3:44:39 PM9/27/18
to Ansible Project
2 things;

1. That's a bash script and not a batch file, simply changing the extension from .sh to .bat will not work
2. Processes spawned in WinRM are killed once the parent process exist

1 is either you copied the wrong script or are using the wrong file, I can't help you there. 2 can be overcome in multiple ways;

1. Use async to run the process in the background that is escaped from the WinRM job, this must have a timeout and cannot be run indefinitely
2. Use the proper way of putting this in a scheduled task or Windows service and run it that way

You really should be using a scheduled task or Windows server to run this as it has fine controls over error actions, scheduling and the like. This isn't designed to be run directly from Ansible except maybe for debugging purposes.

Thanks

Jordan

vowner

unread,
Sep 28, 2018, 4:15:52 AM9/28/18
to Ansible Project
Hello Jordan,

ya, its my bad that i mistakenly pasted the wrong script. The batch script is as given below., Also, in my playbook, starting the liberty server using this batch file is a one task only and there are too many other tasks in continuous to this after the server got started.

could you please explain that how to use async for calling this startup batch file to start the server.

Batch file- server.startup.bat
_______________________

@echo off
rem *******************************************************************************
rem Licensed Materials - Property of IBM
rem (c) Copyright IBM Corporation 2008, 2017. All Rights Reserved.
rem 
rem Note to U.S. Government Users Restricted Rights:  
rem Use, duplication or disclosure restricted by GSA ADP Schedule 
rem Contract with IBM Corp. 
rem *******************************************************************************

setlocal

set START_DIR=%~dp0

set CLEAN=false
set LIBERTY=false
set ACTION=start

rem Run in Liberty if it is installed, unless overridden by a command option
if exist "%START_DIR%"\liberty.server.bat (
    set LIBERTY=true
)

FOR %%A IN (%*) DO (
   if "%%A"=="-debug" (
      set ACTION=debug
   )
   if "%%A"=="-clean" (
      set CLEAN=true
   )
   if "%%A"=="-create" (
      set ACTION=create
   )
   if "%%A"=="-run" (
      set ACTION=run
   )
   if "%%A"=="-tomcat" (
      set LIBERTY=false
   )
)

rem The following four environment variables are used to point to the
rem appropriate JDBC jar file supplied by the database vendor.  For Oracle and
rem SQL Server, the environment variable should point to the driver file itself;
rem for db2i and db2z, the variable should point to the directory that contains
rem the multiple necessary jdbc driver files required on those platforms (for example, 
rem c:\Program Files\IBM\SQLLIB\java\). For DB2, the use of DB2_ABSPATH is optional; 
rem if not set, the default driver installed with the server will be used.

rem Users should set these variables; if they are set, the script will respect
rem their value.  If they are unset, we try locating the driver files in a
rem directory under <JazzInstallDir>/server.  (For example, the default location
rem for the Oracle JDBC driver is under
rem <JazzInstallDir>/server/oracle/ojdbc8.jar).

rem Do not use double quotes when you define your environment variable.  If
rem you're setting it from the command line, do:
rem set ORACLE_JDBC_DRIVER_FILE=c:\path name\ojdbc8.jar
rem not:
rem set ORACLE_JDBC_DRIVER_FILE="c:\path name\ojdbc8.jar"

if NOT "%ORACLE_JDBC_DRIVER_FILE%"=="" goto :after_oracle
set ORACLE_JDBC_DRIVER_FILE=%START_DIR%\oracle\ojdbc8.jar
:after_oracle

if NOT "%SQLSERVER_JDBC_DRIVER_FILE%"=="" goto :after_sqlserver
set SQLSERVER_JDBC_DRIVER_FILE=%START_DIR%\sqlserver\sqljdbc41.jar
:after_sqlserver

if "%DB2I_ABSPATH%"=="" goto :default_db2i
set DB2I_JDBC=%DB2I_ABSPATH%
goto :after_db2i
:default_db2i
set DB2I_JDBC=%START_DIR%\db2i
:after_db2i

if "%DB2Z_ABSPATH%"=="" goto :default_db2z
set DB2Z_JDBC=%DB2Z_ABSPATH%
goto :after_db2z
:default_db2z
set DB2Z_JDBC=%START_DIR%\db2z
:after_db2z

set COGNOS_SDK=%START_DIR%\CognosSDK

rem Convert the current working directory
rem to a format that is valid for use in a
rem a file URL
set CUR_PATH=%START_DIR%
set DRIVE=%START_DIR:~0,1%
set SHORT_PATH=%~sp0%
set SHORT_PATH=%SHORT_PATH:\=/%
set PATH_URL=%DRIVE%%%3a%SHORT_PATH%

set JAVA_OPTS=%JAVA_OPTS% -Djava.awt.headless=true
set JAVA_OPTS=%JAVA_OPTS% -DSQLSERVER_JDBC_DRIVER_FILE="%SQLSERVER_JDBC_DRIVER_FILE%"
set JAVA_OPTS=%JAVA_OPTS% -DORACLE_JDBC_DRIVER_FILE="%ORACLE_JDBC_DRIVER_FILE%"
set JAVA_OPTS=%JAVA_OPTS% -DDB2I_JDBC="%DB2I_JDBC%"
set JAVA_OPTS=%JAVA_OPTS% -DDB2Z_JDBC="%DB2Z_JDBC%"
if "%DB2_ABSPATH%"=="" goto :after_db2
set JAVA_OPTS=%JAVA_OPTS% -DDB2_ABSPATH="%DB2_ABSPATH%/"
:after_db2
set JAVA_OPTS=%JAVA_OPTS% -Dorg.eclipse.emf.ecore.plugin.EcorePlugin.doNotLoadResourcesPlugin=true
set JAVA_OPTS=%JAVA_OPTS% -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
set JAVA_OPTS=%JAVA_OPTS% -Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true
set JAVA_OPTS=%JAVA_OPTS% -DJAZZ_HOME=file:///%PATH_URL%conf
set JAVA_OPTS=%JAVA_OPTS% -Dcom.ibm.team.repository.tempDir="%TEMP%"
rem Using TLS only protocols protects against CVE-2014-3566 vulnerability
set JAVA_OPTS=%JAVA_OPTS% -Djazz.connector.sslEnabledProtocols="TLSv1,TLSv1.1,TLSv1.2"
set JAVA_OPTS=%JAVA_OPTS% -Djazz.connector.algorithm=IbmX509
set JAVA_OPTS=%JAVA_OPTS% -Xmx4G
set JAVA_OPTS=%JAVA_OPTS% -Xms4G
set JAVA_OPTS=%JAVA_OPTS% -Xmn1G
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxDirectMemorySize=1G
set JAVA_OPTS=%JAVA_OPTS% -Xgcpolicy:gencon
set JAVA_OPTS=%JAVA_OPTS% -Xcompressedrefs -Xgc:preferredHeapBase=0x100000000
set JAVA_OPTS=%JAVA_OPTS% -Dlog4j.configuration=file:///%PATH_URL%conf/startup_log4j.properties
set JAVA_OPTS=%JAVA_OPTS% -Dderby.locks.waitTimeout=1200
set JAVA_OPTS=%JAVA_OPTS% -Dderby.locks.deadlockTimeout=1140
set JAVA_OPTS=%JAVA_OPTS% -verbose:gc "-Xverbosegclog:verbosegc.%%y%%m%%d.%%pid.txt,5,100000"

if "%CLEAN%" == "true" (
   set JAVA_OPTS=%JAVA_OPTS% -Djazz.clean=true
)
if "%ACTION%" == "debug" (
   set JAVA_OPTS=%JAVA_OPTS% -Dcom.ibm.team.repository.debug.enabled=true
   set JAVA_OPTS=%JAVA_OPTS% -Dcom.ibm.team.repository.debug.users=*
)

rem *** Debug service properties ***

rem Give access to restricted areas to all JazzAdmins users.
rem set JAVA_OPTS=%JAVA_OPTS% -Dcom.ibm.team.repository.debug.users=JazzAdmins

rem Expose /repodebug/access service.
rem set JAVA_OPTS=%JAVA_OPTS% -Dcom.ibm.team.repository.debug.accessServiceEnabled=true

rem Patch service options.
rem set JAVA_OPTS=%JAVA_OPTS% -Dcom.ibm.team.osgi.patch.disable=true
rem set JAVA_OPTS=%JAVA_OPTS% -Dcom.ibm.team.osgi.patch.directory=patch

rem Required for CLM Monitoring
rem set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote=true
rem set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=1099
rem set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false
rem set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.authenticate=false

rem BEGIN app-specific options section
rem END app-specific options section

rem Unset JAVA_HOME because we really want to use the JRE that is bundled.
rem Also, Tomcat will complain if JAVA_HOME is set to a JRE instead of a JDK
rem and that should be avoided
set JAVA_HOME=
set JRE_HOME=%START_DIR%\jre
if "%CATALINA_HOME%" == "" (
    set CATALINA_HOME=%START_DIR%\tomcat
)

if "%LIBERTY%" == "true" (
    call "%START_DIR%"\liberty.server.bat %ACTION%
) else (
    if exist "%CATALINA_HOME%"\bin (
    rem health center currently disabled by default; see work item 413691
    rem set JAVA_OPTS=%JAVA_OPTS% -agentlib:healthcenter -Dcom.ibm.java.diagnostics.healthcenter.agent.port=1972 -Dsun.rmi.registry.registryFilter=javax.rmi.CORBA.Stub
        if "%ACTION%" == "debug" (
            call "%CATALINA_HOME%"\bin\catalina.bat jpda run
        ) else (
            call "%CATALINA_HOME%"\bin\startup.bat
        )
    ) else (
        echo ERROR:  There is no Liberty or Tomcat application server to start.
    )
)

endlocal

vowner

unread,
Sep 28, 2018, 4:19:07 AM9/28/18
to Ansible Project
Please find my current yaml file to execute the startup batch fille and could you please advise me what modification needed to do for using async here in this yaml.

--- 
 - name: start liberty server
   hosts: win
   tasks: 
     - name: start server
       Win_commad: D:\IBM\JazzTeamServer\server.startup.bat


Jordan Borean

unread,
Sep 28, 2018, 7:51:23 AM9/28/18
to Ansible Project
Have a look at the async docs https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html. You want to use the async keyword and set ‘poll: 0’ as task directives.

As I said though, async is not the right tool for what you are looking for. You should be using a scheduled task or Windows service to run this. Using async will have lots of issues as;

* You can not run an async task indefinitely, you must set a max timeout value for each async task that Ansible spawns
* If the process ends abruptly, you need to use Ansible to start the task again, scheduled tasks and services can have more thourough error handling and can even restart the service if you want
* adding to the above, Ansible is on a separate host if you need to restart the process a service/task can be controlled using PowerShell on that same host
* You have limited visibility over the process apart from seeing if it is still running by checking all the currently running processes

Do this the right way now or else you will regret it in the future.
Reply all
Reply to author
Forward
0 new messages