title: fabric sudo permission denied
body: <p>setup: </p>
  
  <ul>
  <li>fabric 1.9.1</li>
  <li>server is centOS 7</li>
  <li>user tester0 has admin privileges &amp; is in sudoers file </li>
  </ul>
  
  <p>Issue: When I'm trying to create folder under '/opt/' it returns "Permission denied".</p>
  
  <p>From my fabfile.py:</p>
  
  <pre><code>parent_code_dir = '/opt/deploy_dest'
  with settings(sudo_user=pt_root_user,warn_only=False):
       sudo("ls /opt/") #this works OK with the sudo command
       sudo("id") #this works OK with the sudo command
       sudo("mkdir -p %s" % parent_code_dir) #this returns the "Permission denied" 
  </code></pre>
  
  <p>In my terminal I see the output:</p>
  
  <pre><code>[192.168.1.108] sudo: ls
  [192.168.1.108] out: rh
  [192.168.1.108] out: 
  
  [192.168.1.108] sudo: id
  [192.168.1.108] out: uid=1000(tester0) gid=1000(tester0) groups=1000(tester0),10(wheel)   context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
  [192.168.1.108] out: 
  
  [192.168.1.108] sudo: mkdir -p /opt/deploy_dest/
  [192.168.1.108] out: mkdir: cannot create directory ‘/opt/deploy_dest/’: Permission denied
  Fatal error: sudo() received nonzero return code 1 while executing!
  Requested: mkdir -p /opt/pt_server/
  Executed: sudo -S -p 'sudo password:'  -u "tester0"  /bin/bash -l -c "mkdir -p /opt/pt_server/"
  </code></pre>
  
  <p>I was able to create the same folder manually <code>sudo mkdir -p /opt/deploy_dest</code> over ssh when accessing as tester0.
  Yet when I run the output <code>sudo -S -p 'sudo password:'  -u "tester0"  /bin/bash -l -c "mkdir -p /opt/pt_server/"</code> I get the same error so I guess I should change the fabric sudo_prefix.. </p>
  
  <p>Is there a better solution? have I missed somthing?</p>