Save temporary ansible shell scripts instead of deleting

送分小仙女□ 提交于 2020-01-12 04:02:14

问题


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

Here is an example command:

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'

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')),)

回答1:


I found the environment variable -

export ANSIBLE_KEEP_REMOTE_FILES=1

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



来源:https://stackoverflow.com/questions/30060164/save-temporary-ansible-shell-scripts-instead-of-deleting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!