Closed ahussey-redhat closed 9 months ago
Hello,
Please provide further information/references on how to install and use conserver in ansible along with the type of device used in the inventory file.
Hello @apurvaraghu,
Would you like me to provide an Ansible playbook which installs and configures conserver
?
With regards to the device used in the inventory file, I'm using SRX320 and QFX3500 via console over USB
conserver
is just providing a centralised way to manage the USB/serial access
"I can connect perfectly fine using console
From the conserver doc & manpage:
" adds logging, and multi-user access for remote administration of serial ports, using locally-installed multi-port serial interfaces, and/or "reverse-telnet" to console servers
The console(1) client program communicates with the master console server process to find the port (and host, in a multi-server configuration) on which the appropriate child is listening.
From the Pyez baseline func tty_serial.py
self._ser = serial.Serial()
Sound like when you type console console-name the damn thing use a custom-made tcp-based protocol to for client-server access (while the actual serial device is used by the server). Meanwhile PyEZ will attempt to use the actual serial console device itself, with all the baud rate parameter and other sh!t. Asking PyEZ to connect to this server sound like trying to plug oil pipe into water pipe to me.
That makes sense.
My objective was to be able to connect to conserver
remotely (probably via SSH), to be able to run my Ansible config on my devices from a different host
This could still be achieved without using conserver, and just using delegate_to
for the host which has the console/serial connections
I was also looking at how this could be used with something like Raritan's serial console (https://www.raritan.com/products/kvm-serial/serial-console-servers) to enable out-of-band management of network devices
I was using conserver as way to see if I could have similar functionality.
Admittedly this issue is fairly old, I actually had to install conserver to refresh myself on how I was using it
Hello @apurvaraghu, Would you like me to provide an Ansible playbook which installs and configures
conserver
? With regards to the device used in the inventory file, I'm using SRX320 and QFX3500 via console over USB
conserver
is just providing a centralised way to manage the USB/serial access
That would be great. Thanks!
Note
This playbook is designed to be run on Fedora/RHEL
---
- name: Install and configure conserver
hosts: localhost
connection: local
become: true
gather_facts: false
tasks:
- name: Install the conserver application
ansible.builtin.dnf:
name:
- conserver
- conserver-client
state: latest
- name: Configure conserver application
ansible.builtin.template:
src: templates/conserver.cf
dest: /etc/conserver.cf
- name: Configure conserver connections
ansible.builtin.copy:
src: files/conserver.passwd
dest: /etc/conserver.passwd
- name: Configure conserver client console
ansible.builtin.copy:
src: files/console.cf
dest: /etc/console.cf
- name: Configure conserver systemd service
ansible.builtin.copy:
src: files/conserver.service
dest: /etc/systemd/system/conserver.service
- name: Ensure conserver service is enable and running
ansible.builtin.systemd_service:
name: conserver.service
enabled: true
state: started
daemon_reload: true
default full {
host defaultmaster;
}
config * {
sslrequired no;
}
{% for host in groups.network_devices %}
console {{ hostvars[host]['inventory_hostname'] }} {
type device;
device {{ hostvars[host]['port'] }};
parity none;
baud 9600;
idlestring "#";
idletimeout 5m; # send a '#' every 5 minutes of idle
timestamp ""; # no timestamps on this console
rw *;
master defaultmaster;
}
{% endfor %}
access * {
trusted 127.0.0.1;
}
*any*:*password*
[Unit]
Description=Conserver Serial-Port Console Daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/sbin/conserver -d -i -u -M 127.0.0.1
[Install]
WantedBy=multi-user.target
config * {
master 127.0.0.1;
sslrequired no;
}
---
all:
children:
srx:
hosts:
fw01_0:
fw01_1:
qfx:
hosts:
sw01_0:
sw01_1:
network_devices:
children:
qfx:
srx:
# fw01_0
---
port: /dev/ttyUSB0
# fw01_1
---
port: /dev/ttyUSB1
# sw01_0
---
port: /dev/ttyUSB2
# sw01_1
---
port: /dev/ttyUSB3
Issue Type
Module Name
juniper.device.pyez
juniper.device collection and Python libraries version
OS / Environment
Fedora release 36 (Thirty Six) 5.17.13-300.fc36.x86_64
Summary
I am trying to run my playbooks (which definitely work with direct serial access) via a console server. For the purposes of this testing, I'm just using
conserver
, and have deployed a single console which uses device/dev/ttyUSB0
. I can connect perfectly fine usingconsole <console-name>
. I'm just a bit confused as to how I specify which console I want to connect to. Do I specifyport: "{{ inventory_hostname }}"
whereinventory_hostname
is the same name as the console I want to connect to?Steps to reproduce
Expected results
Actual results