linux - 使用ansible提示读取密码时出现问题

标签 linux ansible

我有一个代码如下,它要求用户输入密码。

---
- name: read password
  hosts: all
  vars_prompt:
   - name: admin_password
     prompt: "enter password for admin"
  tasks:
   - name: echo password to a file
     shell: echo {{admin_password}} >> /root/admin_password

我已输入密码:cPUtnZjn$s2O 但在/root/admin_password 中只得到了 cPUtnZjn

如何解决?

最佳答案

远程计算机上的 shell 将密码的 $s2O 部分解释为变量(该部分为空,因此该部分没有输出)。

使用单个引号将输出字符串括起来:

     shell: echo '{{admin_password}}' >> /root/admin_password

关于linux - 使用ansible提示读取密码时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58060513/

相关文章:

linux - ansible 启动进程,如果没有使用 ps 运行

shell - Ansible执行命令

python - 想要隐藏 "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" } from ping module output?

linux - rsync 仅存在的目录?

c++ - 如果没有公开任何标准符号,则让最近的 C++ 编译 .so 在旧系统上运行

linux - ld86 编译时出现 auto_start 错误

linux - 无法与服务器建立 TCP 连接

linux - 递归调用sh脚本的安全方法

image - 如何使用 ansible docker_image 模块标记本地 docker 镜像?

Ansible 从文件中获取一个字符串并使用该输出注册一个变量