Save temporary ansible shell scripts instead of de

2020-05-30 03:34发布

问题:

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.