title: Ansible failed to transfer file to /command
body: <p>Recently I have been using ansible for a wide variety of automation. However, during testing for automatic tomcat6 restart on specific webserver boxes. I came across this new error that I can't seem to fix. </p>
  
  <pre><code>FAILED =&gt; failed to transfer file to /command
  </code></pre>
  
  <p>Looking at documentation said its because of sftp-server not being in the sshd_config, however it is there.</p>
  
  <p>Below is the command I am running to my webserver hosts.</p>
  
  <pre><code>ansible all -a "/usr/bin/sudo /etc/init.d/tomcat6 restart" -u user --ask-pass --sudo --ask-sudo-pass
  </code></pre>
  
  <p>There is a .ansible hidden folder on each of the boxes so I know its making to them but its not executing the command.</p>
  
  <p>Running -vvvv gives me this after:</p>
  
  <pre><code>EXEC ['sshpass', '-d10', 'ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o',    'ControlPersist=60s', '-o', 'ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'GSSAPIAuthentication=no', '-o', 'PubkeyAuthentication=no', '-o', 'User=user', '-o', 'ConnectTimeout=10', '10.10.10.103', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1400791384.19-262170576359689 &amp;&amp; chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1400791384.19-262170576359689 &amp;&amp; echo $HOME/.ansible/tmp/ansible-tmp-1400791384.19-262170576359689'"]
  </code></pre>
  
  <p>then</p>
  
  <pre><code>10.10.10.103 | FAILED =&gt; failed to transfer file to /home/user/.ansible/tmp/ansible-tmp-1400791384.19-262170576359689/command
  </code></pre>
  
  <p>Any help on this issue is much appreciated.</p>
  
  <p>Thanks,</p>
  
  <hr>
  
  <p><em>Edit:</em></p>
  
  <p>To increase Googleability, here is another manifestation of the error that the chosen answer fixes.</p>
  
  <p>Running the command <code>ansible-playbook -i inventory hello_world.yml</code> gives this warning for every host.</p>
  
  <pre><code>[WARNING]: sftp transfer mechanism failed on [host.example.com]. Use ANSIBLE_DEBUG=1 to see detailed information
  </code></pre>
  
  <p>And when you rerun the command as <code>ANSIBLE_DEBUG=1 ansible-playbook -i inventory hello_world.yml</code> the only extra information you get is:</p>
  
  <pre><code>&gt;&gt;&gt;sftp&gt; put /var/folders/nc/htqkfk6j6h70hlxrr43rm4h00000gn/T/tmpxEWCe5 /home/ubuntu/.ansible/tmp/ansible-tmp-1487430536.22-28138635532013/command.py
  </code></pre>