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
On Friday, September 28, 2018 at 1:45:52 PM UTC+5:30, vowner wrote:
>
> 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
>
>
> On Friday, September 28, 2018 at 1:14:39 AM UTC+5:30, Jordan Borean wrote:
>>
>> 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
>>
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/cdf08e54-599c-4def-9ddb-ebfeca1ec14b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.