On 02.08.2019 01:57, Kenneth Wong wrote:
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?

Yes


From what I can gather, the Expect Module

1. Connects to remote device and immediately sends the command

The point here is that the command is the ssh.


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?

Pseudocode:

- expect:
    command: ssh user@host
    responses:
      remote prompt:
        - ps
        - exit
  delegate_to: localhost


Exit is the command that logs you out.

If you need more help that this you need to provide output of all the manual step including ssh to the end where you exit.

--
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c4184e184134be5b7817b6989b856595%40olstad.com.

Reply via email to