title: Ansible and Wget
body: <p>I am trying to wget a file from a web server from within an Ansible playbook. </p>
  
  <p>Here is the Ansible snippet:</p>
  
  <pre><code>---
  - hosts: all
    sudo: true
    tasks:
    - name: Prepare Install folder
      sudo: true
      action: shell sudo mkdir -p /tmp/my_install/mysql/ &amp;&amp; cd /tmp/my_install/mysql/
    - name: Download MySql
      sudo: true
      action: shell sudo wget http://{{ repo_host }}/MySQL-5.6.15-1.el6.x86_64.rpm-bundle.tar 
  </code></pre>
  
  <p>Invoking it via:</p>
  
  <pre><code>ansible-playbook my_3rparties.yml -l vsrv644 --extra-vars "repo_host=vsrv656" -K -f 10 
  </code></pre>
  
  <p>It fails with the following:</p>
  
  <pre><code>Cannot write to `MySQL-5.6.15-1.el6.x86_64.rpm-bundle.tar' (Permission denied).
  FATAL: all hosts have already failed -- aborting
  
  PLAY RECAP ******************************************************************** 
             to retry, use: --limit @/usr2/ihazan/vufroria_3rparties.retry
  
  vsrv644                : ok=2    changed=1    unreachable=0    failed=1   
  </code></pre>
  
  <p>When trying to do the command that fail via regular remote ssh to mimic what ansible would do, it doesn't work as follows:</p>
  
  <pre><code>-bash-4.1$ ssh ihazan@vsrv644 'cd /tmp/my_install/mysql &amp;&amp; sudo wget http://vsrv656/MySQL-5.6.15-1.el6.x86_64.rpm-bundle.tar'
  Enter passphrase for key '/usr2/ihazan/.ssh/id_rsa': 
  sudo: sorry, you must have a tty to run sudo
  </code></pre>
  
  <p>But I can solve it using -t as follows:</p>
  
  <pre><code>-bash-4.1$ ssh -t ihazan@vsrv644 'cd /tmp/my_install/mysql &amp;&amp; sudo wget http://vsrv656/MySQL-5.6.15-1.el6.x86_64.rpm-bundle.tar'
  </code></pre>
  
  <p>Then it works.</p>
  
  <p>Is there a way to set the -t (pseudo tty option) on ansible? </p>
  
  <p>P.S: I could solve it by editing the sudoers file as others propose but that is a manual step I am trying to avoid.</p>