To avoid an XY problem: I have three devices (Master, Jumphost, Endpoint) , and I want to ensure Jumphost attempts to login with a default root/root user:password on Endpoint.
- Master is an Ubuntu Full-featured linux.
- Jumphost is a limited distribution linux.
- Endpoint is a limited distribution linux.
For that I have a simple playbook like that.
- name: Check default user/password (root/root)
expect:
command: ssh -o StrictHostKeyChecking=no [email protected]
responses:
(?i)password: "root"
register: result_5154
when: "'jumphost' in inventory_hostname"
The problem with expect is that pexect is not installed
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pexpect
fatal: [jumphost -> None]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (pexpect) on jumphost's Python /usr/bin/python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}
So I'm trying with Ansible raw module, but it hangs forever (or timeouts to 10s) because while trying to send password, it's awaiting to further input.
I know there is another problem here which is how to send ssh password without applications installed like sshpass, but it could be any other command which is expecting an input after the initial command. How can it be managed?
- name: Check default user/password (root/root)
raw: ssh -o StrictHostKeyChecking=no [email protected]
timeout: 10
register: result_default_password
when: "'jumphost' in inventory_hostname"
Multiline in raw does not work aswell
- name: Check default user/password (root/root)
raw: |
ssh -o StrictHostKeyChecking=no [email protected]
root
timeout: 10
register: result_default_password
when: "'jumphost' in inventory_hostname"
PS: While writing this, I realised I could create a SSH tunnel and test the login credentials?