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
<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
============
Note manually ssh into the system as cliadmin and run the ps command works fine so the password should be correct.
playbooks.yml:
---
- name: First playbook
hosts: all
gather_facts: no
tasks:
- name: run ps command in restricted environment as user cliadmin
raw: ps
Hosts inventory file:
172.20.5.25 ansible_user=cliadmin ansible_password=XXX
172.20.5.25 ansible_use=root ansible_password=YYY
ansible.cfg:
host_key_checking=false
deprecation_warnings=false
inventory=hosts
interpreter_python = auto_silent
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?
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/edeccb1079de619e2cd554056e26e09d%40olstad.com.