I am confused how Ansible Expect Module will work in my use case.

https://docs.ansible.com/ansible/latest/modules/expect_module.html

Is this the Expect Module you mentioned?

>From what I can gather, the Expect Module

1. Connects to remote device and immediately sends the command

2. Look for a set of responses

3. When a response is matched, it sends the corresponding response value

What I need is:

1. Connect to remote device

2. Look for the remote prompt

3. Sends the command

4. Return the command result to the caller

Can you please provive a short example of sending a "ps" command that runs
on the remote device using Ansible Expect Module?

On Wed, Jul 31, 2019 at 10:58 PM Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On 01.08.2019 00:24, Kenneth Wong wrote:
> > Thanks Kai  for your response.
> > Just for clarification. Can Ansible support the following scenario?
> > 1. Ansible ssh into a remote system using username/password.
> > 2. Ansible waits for a specific prompt from the remote side.
> > 3. Ansible than sends the command.
> > 4. Ansible wait for the command response and return the output to the
> > caller.
> > I have a simple Python script using the Paramiko library to perform the
> > above operations.
> > But I am hoping I can use Ansible directly for this to interact with
> > number
> > of remote servers.
> > I looked at the Ansible expect module example and seems like it first
> > sends
> > the command and than look for some response and sends the corresponding
> > response.
> > I also saw the cli_command and that seems to have the interaction I
> > needed
> > but it seemed to be only for network devices.
>
> The expect module is perfect for this.
>
> Instead of letting Ansible do ssh you, you set the task to "delegate_to:
> localhost" and let expect do ssh as the command.
>
> --
> Kai Stian Olstad
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/edeccb1079de619e2cd554056e26e09d%40olstad.com
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAA2Oruy1MqhxJqdQLuD1Dq_2muJwTa0UTzFvfZJwPFtc5Zc2%2Bw%40mail.gmail.com.

Reply via email to