You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to connect to a juniper device via console port. The console port is directly connected to a console server. The Connection Mode I want to use is documented in juniper.net as "SSH through a console server".
The console server that I have does not require any user/password to logon. That is, when I run the command "ssh x.x.x.x -p 1111", I will be returned Login and Password prompt of the device. Upon entering "admin" as login user and password, I will be connected to the device. Example:
ssh x.x.x.x -p 1111
Welcome to the MRV Communications' LX Series Console Server
Port 1 Speed 9600
X11 forwarding request failed on channel 0
▒M▒EXIT IMMEDIATELY
device_host_name (ttyu0)
login:
where device_host_name is the previously configured device host name and x.x.x.x is the console server ip address.
However, using ansible playbook and the juniper.device module does not work for me. I got cnx_err exception.
Steps to reproduce
Playbook
======
- name: Test console connection via teminal server
hosts: eas_console
collections:
- juniper.device
connection: local
gather_facts: no
tasks:
- name: Execute show command
command:
host: "{{ ansible_ssh_host }}"
user: "{{ juniper_user }}"
passwd: "{{ juniper_passwd }}"
port: "{{ ansible_port }}"
commands:
- "show version"
register: response
- name: Show response
debug:
var: response
Inventory file
========
[terminal_server]
eas_console ansible_ssh_host=x.x.x.x ansible_ssh_port=1111 juniper_user=admin juniper_passwd=valid_device_password_here
[all:vars]
ansible_python_interpreter=/usr/bin/python3
Note that I did not specify cs_user and cs_passwd parameters in the playbook since the console server doen not require logon credential.
Expected results
I am expecting the juniper.device module can connect to the device via console port and the playbook will then execute the "show version" task.
Actual results
Running ansible-playbook -vvv playbooks/connect_eas.yaml -i inventory/console
ansible-playbook [core 2.17.3]
config file = /home/ansible/project/ansible.cfg
configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/ansible/.local/lib/python3.10/site-packages/ansible
ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections
executable location = /home/ansible/.local/bin/ansible-playbook
python version = 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.0.3
libyaml = True
Using /home/ansible/project/ansible.cfg as config file
host_list declined parsing /home/ansible/project/inventory/console as it did not pass its verify_file() method
script declined parsing /home/ansible/project/inventory/console as it did not pass its verify_file() method
auto declined parsing /home/ansible/project/inventory/console as it did not pass its verify_file() method
Parsed /home/ansible/project/inventory/console inventory source with ini plugin
redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
PLAYBOOK: connect_eas.yaml **************************************************************************************************************************************************
1 plays in playbooks/connect_eas.yaml
PLAY [Test console connection via teminal server] ***************************************************************************************************************************
<x.x.x.x> ESTABLISH LOCAL CONNECTION FOR USER: ansible
<x.x.x.x> EXEC /bin/sh -c 'echo ~ansible && sleep 0'
<x.x.x.x> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ansible/.ansible/tmp `"&& mkdir "` echo /home/ansible/.ansible/tmp/ansible-tmp-1724615606.0557683-27636-126618754267988 `" && echo ansible-tmp-1724615606.0557683-27636-126618754267988="` echo /home/ansible/.ansible/tmp/ansible-tmp-1724615606.0557683-27636-126618754267988 `" ) && sleep 0'
Using module file /home/ansible/.ansible/collections/ansible_collections/juniper/device/plugins/modules/command.py
<x.x.x.x> PUT /home/ansible/.ansible/tmp/ansible-local-27633r6ac6ee1/tmpziz8jjz3 TO /home/ansible/.ansible/tmp/ansible-tmp-1724615606.0557683-27636-126618754267988/AnsiballZ_command.py
<x.x.x.x> EXEC /bin/sh -c 'chmod u+x /home/ansible/.ansible/tmp/ansible-tmp-1724615606.0557683-27636-126618754267988/ /home/ansible/.ansible/tmp/ansible-tmp-1724615606.0557683-27636-126618754267988/AnsiballZ_command.py && sleep 0'
<x.x.x.x> EXEC /bin/sh -c '/usr/bin/python3 /home/ansible/.ansible/tmp/ansible-tmp-1724615606.0557683-27636-126618754267988/AnsiballZ_command.py && sleep 0'
<x.x.x.x> EXEC /bin/sh -c 'rm -f -r /home/ansible/.ansible/tmp/ansible-tmp-1724615606.0557683-27636-126618754267988/ > /dev/null 2>&1 && sleep 0'
TASK [Execute show command] *************************************************************************************************************************************************
task path: /home/ansible/project/playbooks/connect_eas.yaml:11
The full traceback is:
File "/tmp/ansible_command_payload_m8so3hwh/ansible_command_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 1097, in open
self.dev.open()
File "/usr/local/lib/python3.10/dist-packages/jnpr/junos/device.py", line 1429, in open
raise cnx_err
fatal: [eas_console]: FAILED! => changed=false
invocation:
module_args:
attempts: null
baud: null
commands:
- show version
console: null
cs_passwd: null
cs_user: null
dest: null
dest_dir: null
formats: null
host: x.x.x.x
huge_tree: false
ignore_warning: null
level: null
logdir: null
logfile: null
mode: null
passwd: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
port: 1111
return_output: true
ssh_config: null
ssh_private_key_file: null
timeout: 20
user: admin
msg: 'Unable to make a PyEZ connection: ConnectError(host: x.x.x.x, msg: Unexpected session close)'
PLAY RECAP ******************************************************************************************************************************************************************
eas_console : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
The text was updated successfully, but these errors were encountered:
ntchilo
changed the title
Unable to connect via console port when using juniper.device module
Unable to make a PyEZ connection: ConnectError(host: x.x.x.x, msg: Unexpected session close
Aug 25, 2024
Issue Type
Module Name
juniper.device collection and Python libraries version
ansible [core 2.17.3]
config file = /home/ansible/project/ansible.cfg
configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/ansible/.local/lib/python3.10/site-packages/ansible
ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections
executable location = /home/ansible/.local/bin/ansible
python version = 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.0.3
libyaml = True
/home/ansible/.ansible/collections/ansible_collections
Collection Version
juniper.device 1.0.5
OS / Environment
Model: ex4300-48t
Junos: 20.4R3-S3.4
Summary
I am trying to connect to a juniper device via console port. The console port is directly connected to a console server. The Connection Mode I want to use is documented in juniper.net as "SSH through a console server".
The console server that I have does not require any user/password to logon. That is, when I run the command "ssh x.x.x.x -p 1111", I will be returned Login and Password prompt of the device. Upon entering "admin" as login user and password, I will be connected to the device. Example:
ssh x.x.x.x -p 1111
Welcome to the MRV Communications' LX Series Console Server
Port 1 Speed 9600
X11 forwarding request failed on channel 0
▒M▒EXIT IMMEDIATELY
device_host_name (ttyu0)
login:
where device_host_name is the previously configured device host name and x.x.x.x is the console server ip address.
However, using ansible playbook and the juniper.device module does not work for me. I got cnx_err exception.
Steps to reproduce
Expected results
Actual results
The text was updated successfully, but these errors were encountered: