AIFeed

Ansible 在 Ubuntu 26 上等待权限提升时失败

Translation(model translation, not the source's own text)

文章标题:Ansible 在 Ubuntu 26 上等待权限提升时失败

正文: 今年我一直在慢慢地把服务器从 Ubuntu 22 和 24 迁移到 26,结果发现如果 sudo 使用了密码保护,我的 Ansible 自动化就开始失败了:


        $ ansible-playbook main.yml -K
BECOME password:

PLAY [Security] *******************************************************

TASK [Gathering Facts] ***********************************************************************
fatal: [my-server.local]: FAILED! =>
    msg: 'Timeout (12s) waiting for privilege escalation prompt: '
      

显然 Ubuntu 正在用 Rust 重写系统工具,而 Ubuntu 26.04 上附带的 sudo-rs 版本与我在服务器上用了 20 多年的 sudo 存在一些不兼容之处。

它会在密码提示符之前打印一个额外的字符串,而 sudo 并不会这样做,这会迷惑像 Ansible 这样等待特定提示符的自动化工具。

Ansible 项目中有一个讨论此问题的帖子:validate sudo become plugin against sudo-rs 。修复已进入 Ansible Core 2.22.0,并正在向后移植到 2.16、2.18、2.19、2.20 的更新中,可能还包括 2.21(这个问题相当具有破坏性!)。看起来它也破坏了 pyinfra,他们的修复在最新的 3.11 版本中。

我更新了 Ansible(pip install -U ansible),现在 -K(--ask-become-pass)又能正常工作了。

另一个替代方案是使用 Ubuntu 26 仍然附带的传统版 sudo。为此,最简单的方法是在你的 hosts 文件中设置 become_exe:


        dell-precision.local ansible_become_exe=sudo.ws
      

或者你甚至可以在 Ubuntu 主机上全局回退 sudo:


        update-alternatives --config sudo
      

我不确定为什么 Ubuntu 认为有必要用 Rust 重写常见的 Linux 工具。我不反感 Rust,但这些是每个 Linux 系统都依赖的基础工具。这不是窗口管理器,在那种场景下试验还比较可以接受1。

如果其他发行版也打算转向 sudo-rs,那是一回事,但如果只有 Ubuntu 这么做,也许我应该把一切都迁回 Debian,而不只是我的云服务器。

  • 是的,我知道这让我听起来像“老头对着 [rust] 大吼”,但在我看来,对 Linux 结构性组件的重大变更应该花更长时间。至少在 Red Hat 这边,我们有 Fedora,它更前沿,然后到它进入“生产”系统之前至少还有几年的间隔。而在 Ubuntu 这边,没有一个前沿的上游,让这类问题在进入生产之前被修复或绕过!(而且,不,我不认为非 LTS 的 Ubuntu 版本算得上同一回事。) ↩︎

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by Lobsters
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗