After a successful login, does Ansible automatically figures out what the remote prompt is before sending the command?
The remote system is Linux and supports ssh login as user root or cliadmin.
The difference is when logged in as cliadmin, a Java application is spawned to interact with the user.
When logged in as cliadmin the user is restricted set of commands such as “ps”.
Using Ansible I created a playbook that calls the raw module to run ps command and it hangs.
Note using Ansible as root works fine but that does not spawn that Java application.
Also manually ssh as cliadmin also works if Ansible is not involved.
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.
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
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
Thanks Kai for your response.
Just for clarification. Can Ansible support the following scenario?
Ansible ssh into a remote system using username/password.
Ansible waits for a specific prompt from the remote side.
Ansible than sends the command.
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.
That is not the remote prompt, but the local prompt where the ssh client ask for password.
What the OP is after is the remote prompt, after ssh is authenticated.