首页 > 解决方案 > 如何在 Ansible 中加密剧本中的变量?

问题描述

我正在运行一本剧本,其中我从外部 hashcorp 保险库传递密码。问题是当我运行 playbook 时,密码以纯文本形式显示在 ansible 提供的输出中。

我希望日志可见,所以我不喜欢 no_logs 作为解决方案

例子

changed: [Server IP] => {
    "changed": true,
    "cmd": "config.cmd --windowsLogonPassword **Password is passed here but displayed in plain text** ,
    "delta": "0:00:06.218698",
    "end": "2021-07-16 05:32:07.845560"...

有没有办法直接在剧本中加密密码,所以这个输出上不会显示纯文本?

标签: ansibleansible-2.xansible-vault

解决方案


no_log: true

在任务或整个剧本上。这会抑制在编写剧本时对调试有用的信息,但应该在需要 IMO 的生产剧本上。


推荐阅读