ansible/ansible — pull request #1437 by lorin (2012-10-24 15:34:09+00:00)
Title: Fix chmod occurring as wrong user when sudo as non-root

If you sudo to a non-root user, you get a permission denied error.

Here's an example:

$ ansible myserver.example.com -m postgresql_db -a "db=mydatabase" -u ubuntu -s -U postgres
myserver.example.com | FAILED >> {
"failed": true,
"msg": "chmod: changing permissions of `/tmp/ansible-
1351092257.96-157699143369671/postgresql_db': Operation not
permitted\n/usr/bin/python: can't open file '/tmp/ansible-
1351092257.96-157699143369671/postgresql_db': [Errno 13]
Permission denied\n",
"parsed": false
}

The problem is that ansible is doing the chmod as the sudo user when it should be doing it as the remote user.