Pexpect as a tool of last resort
嗯,用户让我总结一篇文章,控制在100字以内,而且不需要特定的开头。首先,我得通读文章内容。文章讲的是作者过去20年在自动化任务上的经历,从Expect到Pexpect的使用,再到现在为EVE-NG预配置模板的过程。里面提到了Ansible、脚本和Pytest的使用。 接下来,我需要提炼关键点:自动化工具的发展、预配置模板的具体步骤、使用的工具如Ansible、脚本和Pytest。然后,把这些信息浓缩到100字以内,确保涵盖主要部分,同时语言简洁明了。 可能的结构是:作者回顾过去20年自动化工具的发展,从Expect到Pexpect;现在专注于EVE-NG模板预配置;使用Ansible、脚本和Pytest进行验证。这样既涵盖了时间线,又说明了当前的工作内容和使用的工具。 最后检查一下字数是否符合要求,并确保没有使用任何不需要的开头语句。这样应该就能满足用户的需求了。 </think> 作者回顾了过去20年自动化工具的发展,并分享了如何利用Expect和Pexpect进行系统自动化。目前专注于为EVE-NG预配置模板,包括导入模板、管理接口设置、用户配置及验证过程,并通过Ansible、脚本和Pytest实现自动化测试与验证。 2026-2-16 15:18:30 Author: www.adainese.it(查看原文) 阅读量:10 收藏

Post cover

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