Thank you for the reply.

I ended up removing the TIMEOUTs from the vendor’s script and replaced them 
with pings.


> On Apr 19, 2023, at 2:10 PM, [email protected] <[email protected]> wrote:
> 
> Try just doing - win_command: '{{ install_app_download_dir 
> }}\Prerequisites\install_rabbitmq.bat'. You could also prefix that command 
> with cmd.exe /c path\to\install.bat and see if it helps. Another option is to 
> use '- win_shell: exit (Start-Process -FilePath ... -Wait 
> -PassThru).ExitCode' to spawn it in a new console. Unfortunately that will 
> mean you loose out on viewing any of the output.
> 
> There is no good answer here, the vendors script requires it to be run in an 
> environment that input can be redirected but Ansible doesn't allow that to 
> avoid things hanging if they do prompt for input.
> On Friday, April 14, 2023 at 6:47:18 AM UTC+10 Dick Visser wrote:
>> You could suggest your ping replacement to the vendor. If the vendor then 
>> updates their script with your changes, you can have the benefits of running 
>> unmodified vendor code.
>> 
>> On Thu, 13 Apr 2023 at 22:06, Joefrey <[email protected] <>> wrote:
>>> I'm able to workaround the issue by replacing the vendor's TIMEOUTs with 
>>> "ping -n X >NUL".
>>> 
>>> @jborean93, are there any Ansible flags or tricks that would allow this to 
>>> work without modifying the vendor's script?
>>> 
>>> On Thursday, April 13, 2023 at 12:26:58 PM UTC-5 Joefrey wrote:
>>>> Good day,
>>>> 
>>>> Struggling to find a way to run the below vendor-provided batch file via 
>>>> Ansible. The script works fine when run manually, but I receive dozens of 
>>>> the below error when executing via Ansible win_command or win_shell. I 
>>>> have also tried to execute the batch file interactively using become. When 
>>>> ran interactively it simply hangs. Hoping to find a solution that doesn't 
>>>> involve modifying vendor provided code.
>>>> 
>>>> Ansible:
>>>> 
>>>> - name: Upgrade RabbitMQ
>>>>   ansible.windows.win_shell: .\install_rabbitmq.bat
>>>>   args:
>>>>     chdir: '{{ install_app_download_dir }}\Prerequisites'
>>>> 
>>>> Error:
>>>> 
>>>> ERROR: Input redirection is not supported, exiting the process immediately.
>>>> 
>>>> install_rabbitmq.bat File:
>>>> 
>>>> CLS
>>>> @ECHO OFF
>>>> 
>>>> SET>>%Temp%\install_rabbitmq.log
>>>> 
>>>> CALL sc qc RabbitMQ > NUL
>>>> if errorlevel 1 (
>>>>    goto rabbitchecked
>>>> )
>>>> CALL sc qc RabbitMQ | findstr "erts-13.1.2" > NUL
>>>> if %errorlevel% equ 0 (
>>>>    ECHO RabbitMQ in the newest version detected. Aborting reinstall
>>>>    goto newestrabbit
>>>> )
>>>> 
>>>> :rabbitchecked
>>>> 
>>>> CALL SC QUERY AppNetStateService > NUL
>>>> if errorlevel 1060 (
>>>>    ECHO Services are stopped >>%Temp%\install_rabbitmq.log
>>>>    goto servicesstopped
>>>> )
>>>> ECHO Stopping Services... >>%Temp%\install_rabbitmq.log
>>>> CALL "%~dp0\App.ServiceManager.exe" /Mode:Stop 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> :servicesstopped
>>>> 
>>>> CALL SC QUERY RabbitMQ > NUL
>>>> if errorlevel 1060 (
>>>>    ECHO Rabbit is uninstalled >>%Temp%\install_rabbitmq.log
>>>>    goto rabbituninstalled
>>>> )
>>>> 
>>>> ECHO UNinstalling Rabbit >>%Temp%\install_rabbitmq.log
>>>> CALL sc stop RabbitMQ 2>>%Temp%\install_rabbitmq.log
>>>> :rabbitloop
>>>> CALL sc query RabbitMQ | find "STOPPED"
>>>> if errorlevel 1 (
>>>>   TIMEOUT 10
>>>>   goto rabbitloop
>>>> )
>>>> 
>>>> CALL sc config RabbitMQ binPath= "%ProgramW6432%\Erlang 
>>>> OTP\erts-13.1.2\bin\erlsrv.exe"
>>>> 
>>>> ECHO Uninstalling RabbitMQ...
>>>> CALL "%ProgramW6432%\RabbitMQ Server\uninstall.exe" /S 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> :LOOPUNINSTALL1
>>>> CALL "%~dp0\PSLIST" Un_A /accepteula 2>>%Temp%\install_rabbitmq.log
>>>> IF ERRORLEVEL 1 (
>>>>     ECHO RabbitMQ uninstallation finished.
>>>>     GOTO CONTINUEUNINSTALL1
>>>> ) ELSE (
>>>>     TIMEOUT 2
>>>>     GOTO LOOPUNINSTALL1
>>>> )
>>>> 
>>>> :CONTINUEUNINSTALL1
>>>> 
>>>> TIMEOUT 60 >nul 2>&1
>>>> 
>>>> :rabbituninstalled
>>>> 
>>>> ECHO Uninstalling Erlang OTP...
>>>> 
>>>> IF NOT DEFINED ERLANG_HOME (
>>>>    SET ERLANG_HOME=%ProgramW6432%\erl-24.2.1
>>>> )
>>>> 
>>>> CALL "%ERLANG_HOME%\uninstall.exe" /S 2>>%Temp%\install_rabbitmq.log
>>>> :LOOPUNINSTALL2
>>>> CALL "%~dp0\PSLIST" Un_A /accepteula >nul 2>>%Temp%\install_rabbitmq.log
>>>> IF ERRORLEVEL 1 (
>>>>     ECHO Erlang OTP uninstallation finished.
>>>>     GOTO CONTINUEUNINSTALL2
>>>> ) ELSE (
>>>>     TIMEOUT 2
>>>>     GOTO LOOPUNINSTALL2
>>>> )
>>>> 
>>>> :CONTINUEUNINSTALL2
>>>> 
>>>> TIMEOUT 60 >nul 2>&1
>>>> 
>>>> ECHO Removing cookies, old files and registries...
>>>> DEL /F "C:\Windows\System32\config\systemprofile\.erlang.cookie" 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> DEL /F "%SystemRoot%\.erlang.cookie" 2>>%Temp%\install_rabbitmq.log
>>>> DEL /F "%USERPROFILE%\.erlang.cookie" 2>>%Temp%\install_rabbitmq.log
>>>> 
>>>> DEL /S /Q /F "%AppData%\RabbitMQ\" 2>>%Temp%\install_rabbitmq.log
>>>> 
>>>> reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Ericsson\Erlang" /f
>>>> reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Ericsson\Erlang" /f
>>>> 
>>>> TIMEOUT 10 >nul 2>&1
>>>> 
>>>> ECHO Installing Erlang OTP 25...
>>>> CALL "%~dp0\otp_win64_25.1.2.exe" /S 2>>%Temp%\install_rabbitmq.log
>>>> 
>>>> :LOOP1
>>>> CALL "%~dp0\PSLIST" otp_win64_25.1.2 >nul 2>>%Temp%\install_rabbitmq.log
>>>> IF ERRORLEVEL 1 (
>>>>     ECHO Erlang OTP 25 installation finished.
>>>>     GOTO CONTINUE1
>>>> ) ELSE (
>>>>     TIMEOUT 2
>>>>     GOTO LOOP1
>>>> )
>>>> 
>>>> :CONTINUE1
>>>> SET ERLANG_HOME=%ProgramW6432%\Erlang OTP
>>>> SETX ERLANG_HOME "%ProgramW6432%\Erlang OTP"
>>>> 
>>>> ECHO Installing RabbitMQ Server 3.11.4...
>>>> CALL "%~dp0\rabbitmq-server-3.11.4.exe" /S 2>>%Temp%\install_rabbitmq.log
>>>> 
>>>> :LOOP2
>>>> CALL "%~dp0\PSLIST" rabbitmq-server-3.11.4 >nul 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> IF ERRORLEVEL 1 (
>>>>     ECHO RabbitMQ Server 3.11.4 installation finished.
>>>>     GOTO CONTINUE2
>>>> ) ELSE (
>>>>     TIMEOUT 2
>>>>     GOTO LOOP2
>>>> )
>>>> 
>>>> :CONTINUE2
>>>> 
>>>> ECHO Synchronising Erlang cookies...
>>>> 
>>>> :LOOP3
>>>> IF EXIST "%USERPROFILE%\.erlang.cookie" (
>>>>     GOTO CONTINUE3
>>>> ) ELSE (
>>>>     GOTO LOOP3
>>>> )
>>>> :CONTINUE3
>>>> 
>>>> TIMEOUT 10 >nul 2>&1
>>>> 
>>>> DEL /F "C:\Windows\System32\config\systemprofile\.erlang.cookie" 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> COPY /Y "%USERPROFILE%\.erlang.cookie" 
>>>> "C:\Windows\System32\config\systemprofile\.erlang.cookie" 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> 
>>>> DEL /F "%SystemRoot%\.erlang.cookie" 2>>%Temp%\install_rabbitmq.log
>>>> COPY /Y "%USERPROFILE%\.erlang.cookie" "%SystemRoot%\.erlang.cookie" 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> 
>>>> ECHO Configuring RabbitMQ...
>>>> 
>>>> TIMEOUT 10 >nul 2>&1
>>>> CALL "%ProgramW6432%\RabbitMQ 
>>>> Server\rabbitmq_server-3.11.4\sbin\rabbitmq-service" stop 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> TIMEOUT 10 >nul 2>&1
>>>> CALL "%ProgramW6432%\RabbitMQ 
>>>> Server\rabbitmq_server-3.11.4\sbin\rabbitmq-service" start 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> 
>>>> :LOOP4
>>>> CALL "%ProgramW6432%\RabbitMQ 
>>>> Server\rabbitmq_server-3.11.4\sbin\rabbitmqctl" status >nul 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> IF ERRORLEVEL 1 (
>>>>     TIMEOUT 5 >nul 2>&1
>>>>     GOTO LOOP4
>>>> ) ELSE (
>>>>     GOTO CONTINUE4
>>>> )
>>>> 
>>>> :CONTINUE4
>>>> 
>>>> TIMEOUT 30 >nul 2>&1
>>>> CALL "%ProgramW6432%\RabbitMQ 
>>>> Server\rabbitmq_server-3.11.4\sbin\rabbitmqctl" start_app 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> TIMEOUT 30 >nul 2>&1
>>>> CALL "%ProgramW6432%\RabbitMQ 
>>>> Server\rabbitmq_server-3.11.4\sbin\rabbitmqctl" add_user admin 9 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> TIMEOUT 5 >nul 2>&1
>>>> CALL "%ProgramW6432%\RabbitMQ 
>>>> Server\rabbitmq_server-3.11.4\sbin\rabbitmqctl" set_user_tags admin 
>>>> administrator 2>>%Temp%\install_rabbitmq.log
>>>> CALL "%ProgramW6432%\RabbitMQ 
>>>> Server\rabbitmq_server-3.11.4\sbin\rabbitmqctl" add_vhost / 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> CALL "%ProgramW6432%\RabbitMQ 
>>>> Server\rabbitmq_server-3.11.4\sbin\rabbitmqctl" set_permissions -p / admin 
>>>> .* .* .* 2>>%Temp%\install_rabbitmq.log
>>>> TIMEOUT 5 >nul 2>&1
>>>> 
>>>> :LOOP5
>>>> CALL "%ProgramW6432%\RabbitMQ 
>>>> Server\rabbitmq_server-3.11.4\sbin\rabbitmqctl" status >nul 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> IF ERRORLEVEL 1 (
>>>>     TIMEOUT 5 >nul 2>&1
>>>>     GOTO LOOP5
>>>> ) ELSE (
>>>>     GOTO CONTINUE5
>>>> )
>>>> 
>>>> :CONTINUE5
>>>> 
>>>> SC QUERY AppNetStateService > NUL
>>>> if errorlevel 1060 (
>>>>    goto servicesstarted
>>>> )
>>>> ECHO Restarting services...
>>>> CALL "%~dp0\App.ServiceManager.exe" /Mode:Start 
>>>> 2>>%Temp%\install_rabbitmq.log
>>>> :servicesstarted
>>>> 
>>>> :newestrabbit
>>>> 
>>>> Thank you for any and all assistance!
>>> 
>>> 
>> 
>>> -- 
>>> 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 view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/6c6707ad-2e14-4b7e-80e9-e78ea8cd0b7fn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/ansible-project/6c6707ad-2e14-4b7e-80e9-e78ea8cd0b7fn%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> -- 
>> Sent from Gmail Mobile
> 
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Ansible Project" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/ansible-project/2LMcxe-qMAY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/12dee36d-53bc-428f-b203-829e6ded9d7bn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/ansible-project/12dee36d-53bc-428f-b203-829e6ded9d7bn%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/699D4B63-7B89-4C20-8447-868699A60F72%40gmail.com.

Reply via email to