community.general.machinectl become – Systemd 的 machinectl 权限提升
注意
此 become 插件是 community.general 集合 (版本 10.1.0) 的一部分。
如果您使用的是 ansible
包,则可能已经安装了此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install community.general
。
要在 playbook 中使用它,请指定: community.general.machinectl
。
概要
此 become 插件允许您的远程/登录用户通过 machinectl 实用程序以另一个用户的身份执行命令。
参数
参数 |
注释 |
---|---|
Machinectl 可执行文件。 默认值: 配置
|
|
传递给 machinectl 的选项。 默认值: 配置
|
|
machinectl 的密码。 配置
|
|
您“成为”以执行任务的用户。 默认值: 配置
|
备注
注意
当不与用户
root
一起使用此插件时,它仅与将更改 machinectl 行为的 polkit 规则一起正常工作。此规则必须更改提示行为以直接询问用户凭据,如果允许用户执行操作(请查看示例部分)。如果不存在此类规则,则只有在与 root 用户一起使用时,插件才能工作,因为那时 machinectl 将不会显示任何其他提示。
示例
# A polkit rule needed to use the module with a non-root user.
# See the Notes section for details.
/etc/polkit-1/rules.d/60-machinectl-fast-user-auth.rules: |
polkit.addRule(function(action, subject) {
if(action.id == "org.freedesktop.machine1.host-shell" &&
subject.isInGroup("wheel")) {
return polkit.Result.AUTH_SELF_KEEP;
}
});