如何在正在运行的命令中添加密码

问题描述 投票:0回答:1

我有一个运行密码加密密码工具的任务。

  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 }}

此任务需要密码。但是失败,因为没有提供提示密码来发送密码。如何解决这个问题?

shell ansible wso2 wso2-am
1个回答
1
投票
使用expect模块。引用example方法为command提供密码

- 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

© www.soinside.com 2019 - 2024. All rights reserved.