保存临时的 ansible shell 脚本而不是删除 [英] Save temporary ansible shell scripts instead of deleting

查看:26
本文介绍了保存临时的 ansible shell 脚本而不是删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到 Ansible 删除了使用分号分隔 bash 命令的临时脚本.

I noticed Ansible removes the temporary script using a semi-colon to separate the bash commands.

这是一个示例命令:

EXEC ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o 
ControlPath="/Users/devuser/.ansible/cp/ansible-ssh-%h-%p-%r" -o
KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o ConnectTimeout=10 build /bin/sh -c
'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python
/home/ec2-user/.ansible/tmp/ansible-tmp-1430847489.81-75617096172775/docker;
rm -rf
/home/ec2-user/.ansible/tmp/ansible-tmp-1430847489.81-75617096172775/
>/dev/null 2>&1'

有没有办法告诉ansible在运行ansible-playbook时用双与号替换分号或告诉它保存脚本或输出内容?

Is there a way to tell ansible to replace the semi-colon with a double ampersand or to tell it to save the script or output the contents when running ansible-playbook?

我正在尝试调试此脚本中的错误,现在唯一出现的是:

I'm trying to debug an error in this script and right now the only thing that appears is this:

failed: [build] => {"changed": false, "failed": true}
msg: ConnectionError(ProtocolError('Connection aborted.', error(2, 'No such file or directory')),)

推荐答案

我找到了环境变量 -

export ANSIBLE_KEEP_REMOTE_FILES=1

设置此项,然后重新运行 ansible-playbook,然后 ssh 和 cd 到 ~/.ansible/tmp/以查找文件.

Set this, then re-run ansible-playbook, and then ssh and cd over to ~/.ansible/tmp/ to find the files.

这篇关于保存临时的 ansible shell 脚本而不是删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆