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.



On Wednesday, July 31, 2019 at 9:48:02 AM UTC-7, Kai Stian Olstad wrote:
>
> On 31.07.2019 15:55, Kenneth Wong wrote: 
> >   
> > 
> > After a successful login, does Ansible automatically figures out what 
> the 
> > remote prompt is before sending the command? 
>
> Ansible doesn't login it run commands in non-interactive fashion. 
>
>
> > In Ansible is there support for providing what the remote prompt is? 
> > 
> > Is there a way to provide some delay before Ansible sends the command? 
> > 
> > I wonder if my issue is with Ansible sends the command before the remote 
> > end is ready to accept the command. 
>
> Since Ansible is using ssh it doesn't do anything about this, since that 
> is something ssh handles. 
>
>
> > Here is how it hangs as user cliadmin: 
> > 
> > TASK [run ps command in restricted environment as user cliadmin] 
> > 
> ********************************************************************************************************
>  
>
> > 
> > task path: /Users/kwong/ansibles/playbooks.yml:6 
> > 
> > <172.20.5.21> ESTABLISH SSH CONNECTION FOR USER: cliadmin 
> > 
> > <172.20.5.21> SSH: EXEC sshpass -d42 ssh -vvv -C -o ControlMaster=auto 
> -o 
> > ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="cliadmin"' -o 
> > ConnectTimeout=10 -o ControlPath=/Users/kwong/.ansible/cp/0bea8f5a62 -tt 
> > 172.20.5.21 ps 
>
> As you can see here ansible is basicly running 
>
>   ssh [email protected] <javascript:> ps 
>
>
> So to find out what happens you need to research how ssh handles runing 
> command non-interactive or use the expect module that can handles this. 
>
>
> -- 
> 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/3383c3a7-f1f3-4614-b932-51516d66a67a%40googlegroups.com.

Reply via email to