
Twenty years ago, when I started automating tasks on the distributed network I was managing, there were practically no automation tools available. I started with
Expect
, which is still my lifesaving tool today. When I have no other way to interact with a system, Expect is my last resort.
Since I’ve now moved all my development to Python, I use
Pexpect
, which allows me to integrate automation into an ecosystem I already know well.
Preconfiguring templates for EVE-NG
The goal I set for myself, part of a larger project, is to preconfigure templates for EVE-NG. Specifically, I need to:
- import new templates;
- preconfigure each template so that the first interface always belongs to a management VRF, receives an IP address via DHCP, has a privileged user preconfigured, and has SSH enabled;
- verify that the generated images work as expected (ping, login);
- verify the entire process in CI/CD mode after every significant change.
The problem was divided into four parts:
- Ansible searches for the required files and prepares the environments under /opt/unetlab/addons/qemu;
- a script configures each image;
- a script runs an instance and verifies network reachability (ping) and login;
- Pytest takes care of creating temporary instances, configuring them, and verifying them.+
Continue reading
the post on Patreon
.
文章来源: https://www.adainese.it/blog/2026/02/15/pexpect-as-a-tool-of-last-resort/
如有侵权请联系:admin#unsafe.sh