Ansible Win_command

51 views
Skip to first unread message

sindhu shree

unread,
Jun 27, 2019, 12:32:02 AM6/27/19
to Ansible Project
Hi All,
I need help in executing batch file which has some prompts.
Am using following lines of script

 - name: run an executable with custom working dir
            win_command: pisrvstop.bat /argument1 "/argument 2 with space"
            args:
               chdir: F:\Program Files\PI\adm
            async: 120
            poll: 5


it works fine but it will not answer  for the prompts. How do i set the answers for prompt?

Angel Rengifo Cancino

unread,
Jun 27, 2019, 2:48:07 PM6/27/19
to ansible...@googlegroups.com
May the expect module be useful for you?

--
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/3e4238f5-b9c5-4bb5-bada-0c8e90de8ed1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jordan Borean

unread,
Jun 27, 2019, 4:18:36 PM6/27/19
to Ansible Project
Ansible modules are designed to be run in a non-interactive fashion, you won't receive the prompt on the controller as that's just not how Ansible works. You also won't be able to use expect for Windows as that is a Python module. Your best bet is to the use stdin option for win_command to send data over the stdin pipe. This is a very basic mechanism but if all you need to do is type 'y' then send y over stdin.

Thanks

Jordan
Message has been deleted

sindhu shree

unread,
Jul 5, 2019, 1:24:28 AM7/5/19
to Ansible Project

Jordan,

Thanks for the detailed description.  Actually am working on stopping services which has dependencies just like service A dependent on Service B, am having issue in this scenario. Can you please give some info on stopping dependencies as well?

sindhu shree

unread,
Jul 5, 2019, 1:26:12 AM7/5/19
to Ansible Project
Thanks for the info. I look into it.




On Friday, June 28, 2019 at 12:18:07 AM UTC+5:30, Angel Rengifo Cancino wrote:
May the expect module be useful for you?

On Wed, Jun 26, 2019 at 11:32 PM sindhu shree <sindhu...@gmail.com> wrote:
Hi All,
I need help in executing batch file which has some prompts.
Am using following lines of script

 - name: run an executable with custom working dir
            win_command: pisrvstop.bat /argument1 "/argument 2 with space"
            args:
               chdir: F:\Program Files\PI\adm
            async: 120
            poll: 5


it works fine but it will not answer  for the prompts. How do i set the answers for prompt?

--
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...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages