Error deploying using Trellis

Hey guys,

I have my deployment set up and have been deploying regularly to my staging environment. However now when I run:

ansible-playbook deploy.yml -e env=staging -e site=staging.mydomain.com -vvv

I get the following error

rmtree failed: [Errno 13] Permission denied: '/srv/www/staging.mydomain
.com/releases/20190409141126/web/app/themes/sage/vendor/illuminate/view/Vie
wName.php'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_deploy_helper_payload_bV3pdc/__main__.py", line 332, in delete_path
    shutil.rmtree(path, ignore_errors=False)
  File "/usr/lib/python2.7/shutil.py", line 261, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/lib/python2.7/shutil.py", line 261, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/lib/python2.7/shutil.py", line 261, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/lib/python2.7/shutil.py", line 261, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/lib/python2.7/shutil.py", line 261, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/lib/python2.7/shutil.py", line 261, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/lib/python2.7/shutil.py", line 261, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/lib/python2.7/shutil.py", line 266, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File "/usr/lib/python2.7/shutil.py", line 264, in rmtree
    os.remove(fullname)
OSError: [Errno 13] Permission denied: '/srv/www/staging.mydomain.com/releases/20190409141126/web/app/themes/sage/vendor/illuminate/view/ViewName.php'

fatal: [178.62.107.48]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "attributes": null,
            "backup": null,
            "clean": true,
            "content": null,
            "current_path": "current",
            "delimiter": null,
            "directory_mode": null,
            "follow": false,
            "force": null,
            "group": null,
            "keep_releases": 5,
            "mode": null,
            "owner": null,
            "path": "/srv/www/staging.mydomain.com",
            "regexp": null,
            "release": "20190418122736",
            "releases_path": "releases",
            "remote_src": null,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "shared_path": "shared",
            "src": null,
            "state": "finalize",
            "unfinished_filename": "DEPLOY_UNFINISHED",
            "unsafe_writes": null
        }
    }
}

I had gotten this error once before, retried the deploy and it worked. However now, no amount of retries will fix the issue.

I have also re-provisioned the server by running ansible-playbook server.yml -e env=staging. WIth no luck.

Any ideas?

Thanks,

Ian

Hi there,

There should be a solution in one of the existing threads for this error:

https://discourse.roots.io/search?q=%5BErrno%2013%5D%20Permission%20denied

See:

https://discourse.roots.io/t/rmtree-failed-errno-13-permission-denied-at-finalize-the-deploy/11123/4

Thanks @ben

I have solved the issue by:

ssh staging.mydomain.com 
sudo su -
cd /srv/www/staging.mydomain.com
ls -l # take note of the `current` symlink and which directory it points to
cd releases
rm -rf foldername # remove all the folders except the one which matches the symlink

Note, I assume that this will break any rollbacks, so be cautious just in case.

1 Like