You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ansible使用变量传递密码执行realm加入AD域失败

Ubuntu虚拟机通过Ansible+Realm加入AD域的密码传递问题

我正在使用Ansible Playbook通过realm工具将Ubuntu虚拟机加入AD域。在Playbook的vars中配置了名为ad_password的变量,该密码包含字母、数字和特殊字符。我尝试过用双引号包裹密码,也试过不加引号,任务代码如下:

- name: Join the computer to the realm
  command: realm join -v {{ domain_controller }} --computer-ou "{{ ad_computer_ou }}" -U {{ ad_join_user }}%{{ ad_password }}
  register: realm_join

但执行Playbook时,该任务会无限挂起。我尝试过多种方式让Playbook交互式提供ad_join_user账户的域加入密码,要么出现身份验证错误(推测是密码传递不正确),要么就像此例一样无限挂起。

当我将密码硬编码到任务中时,域加入操作可以正常完成,示例如下:

- name: Join the computer to the realm
  command: /bin/bash -c "echo MY_PASSWORD_PUT_HERE | realm join -v {{ domain_controller }} --computer-ou "{{ ad_computer_ou }}" -U {{ ad_join_user }}"
  register: realm_join

我试过使用command模块和shell模块,但都无法通过变量(或Ansible Vault中的加密变量)传递密码完成操作。


内容的提问来源于stack exchange,提问作者Michael

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 03:14:52