shell - 如何在ansible中为运行命令添加密码
问题描述
我的任务是运行密码加密密码工具。
tags: encrypting
command: sh {{ansible_env.HOME}}/wso2/apim/{{item}}/wso2am-2.6.0/bin/ciphertool.sh -Dconfigure
with_sequence: start=1 end={{ no_of_nodes }}
此任务需要密码。但它失败了,因为没有提供提示密码来发送密码。如何解决这个问题?
解决方案
- name: Case insensitive password string match
expect:
command: passwd username
responses:
(?i)password: "MySekretPa$$word"
# you don't want to show passwords in your logs
no_log: true
在您的情况下,该任务可能与此类似。使password
提示符符合您的需求
- expect:
command: sh {{ansible_env.HOME}}/wso2/apim/{{item}}/wso2am-2.6.0/bin/ciphertool.sh -Dconfigure
responses:
(?i)password: "MySekretPassword"
loop: "{{ range(1, no_of_nodes)|list }}"
no_log: true
tags: encrypting
推荐阅读
- pytorch - PyTorch VAE 无法转换为 onnx
- azure-logic-apps - 我如何从逻辑应用程序中读取 CloudQueueMessage.DequeueCount
- python - 从 CSV 列表中选择到表中
- spring-integration - 无法在 Spring Integration Flow 的建议中删除文件资源
- python - 谷歌 colab python3 名称 cv2 未定义
- node.js - 如何在 node-oidc-provider 中重定向失败的登录尝试
- curve-fitting - MATLAB - 指数(exp2)曲线拟合函数在使用原始方程中的拟合值时不给出与绘图相同的输出
- python - 更简单的 python 等价于 R 风格的 grep,包括多个要匹配的东西
- azure - HDInsight 上的 Ambari API 返回 404
- google-sheets - 使用 SUMIF 函数时,有没有办法接受时间戳值(例如 2/12/2019 19:56:16)作为测试标准的范围?