# How to run Ansible from web server?

**URL:** <https://forum.ansible.com/t/how-to-run-ansible-from-web-server/17260>\
**Category:** Ansible Project\
**Created:** [January 14, 2015, 7:32am UTC](https://forum.ansible.com/t/how-to-run-ansible-from-web-server/17260 "2015-01-14T07:32:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Valeriy\_Solovyov](https://avatars.discourse-cdn.com/v4/letter/v/8e8cbc/32.png) [@Valeriy\_Solovyov](https://forum.ansible.com/u/Valeriy_Solovyov)\
**Post date:** [January 14, 2015, 7:32am UTC](https://forum.ansible.com/t/how-to-run-ansible-from-web-server/17260/1 "2015-01-14T07:32:52Z")

</div>

Hello  
I use apache2 + cgi. I enabled sudo for all users. But when I try run ansible throw apache2 cgi and I got:

> > { “dark”: { “127.0.0.1”: { “msg”: “Authentication or permission  
> > failure. In some cases, you may have been able to authenticate and did  
> > not have permissions on the remote directory. Consider changing the  
> > remote temp path in ansible.cfg to a path rooted in "/tmp". Failed  
> > command was: mkdir -p  
> > $HOME/.ansible/tmp/ansible-1420984254.94-125323999727459 && chmod a+rx  
> > $HOME/.ansible/tmp/ansible-1420984254.94-125323999727459 && echo  
> > $HOME/.ansible/tmp/ansible-1420984254.94-125323999727459, exited with  
> > result 1”, “failed”: true } }, “contacted”: {} }

If I change inside ansible.cfg temp path → all work.

When I run this script thew shell of www-data user it’s working:  
#su -l www-data  
$ /lxc/www/py/index.py

> > Content-type: text/html
> 
> ```auto
> <html><head>
> </head><body>
> {
> "dark": {},
> "contacted": {
> "127.0.0.1": {
> "invocation": {
> "module_name": "service",
> "module_args": "name=shoc-lxc-net state=started enabled=yes"
> },
> "state": "started",
> "changed": false,
> "enabled": true,
> "name": "shoc-lxc-net"
> }
> }
> }
> 127.0.0.1 >>> True
> 
> ```

When I cheack:

```auto
# ls -la /var/www/
<i>total 20
drwxrwxrwx 4 root root 4096 Jan 11 15:57 .
drwxr-xr-x 14 root root 4096 Jan 8 15:58 ..
drwxr-xr-x 2 root root 4096 Jan 11 14:54 etc
-rw-r--r-- 1 root root 177 Mar 18 2013 index.html
drwx------ 2 www-data www-data 4096 Jan 11 15:36 .ssh</i>

# su www-data
$ mkdir /var/www/.ansible/tmp -p
$
# ls -la /var/www/.ansible/
<i>total 12
drwxrwxr-x 3 www-data www-data 4096 Jan 11 15:57 .
drwxrwxrwx 5 root root 4096 Jan 11 15:57 ..
drwxrwxr-x 2 www-data www-data 4096 Jan 11 15:57 tmp</i>

```

my script:

---

<div class="post-metadata">

**Author:** ![James\_Couch](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@James\_Couch](https://forum.ansible.com/u/James_Couch)\
**Post date:** [December 9, 2016, 9:14pm UTC](https://forum.ansible.com/t/how-to-run-ansible-from-web-server/17260/2 "2016-12-09T21:14:53Z")

</div>

I’m having the same issue. We’re trying to run playbooks from Flask behind gunicorn as a non-root user and we’re getting that same error. I’ve confirmed that user has full r/w/x access to the directory it’s complaining about, but it still won’t work. I can also run playbooks from the command-line as that user and it works fine. It seems to only be an issue when running through the Python API.
