Deploy: OSError: [Errno 13] Permission denied

So I set up a new staging Ubuntu Server 18.04.2 LTS system on Hyper-V and
successfully provisioned it as trellis system with ansible.

However, deploying a site to it results in an error message very early during deploy:

MODULE FAILURE
Traceback (most recent call last):
File "/tmp/ansible_oJ2ASV/ansible_module_deploy_helper.py", line 529, in
<module>
main()
File "/tmp/ansible_oJ2ASV/ansible_module_deploy_helper.py", line 491, in
main
changes += deploy_helper.create_path(facts['releases_path'])
File "/tmp/ansible_oJ2ASV/ansible_module_deploy_helper.py", line 352, in
create_path
os.makedirs(path)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/srv/www/example.com/releases'
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: OSError: [Errno 13] Permission denied: '/srv/www/example.com/releases'
fatal: [staging-1]: FAILED! => {"changed": false, "module_stdout": "", "rc": 1}

I found similar issues on the internet, so I list them here:





So from what I learned from these discussions is that this kind of error can happen:

  • When provisioning hadn’t ran yet, either never had, or for the site to be deployed.
    However, the initial provisioning including that site in config, ran successfully.
  • Ownership and permissions of /srv and its subfolders are somehow off.
    These look correct for me, also I can manually create the directory /srv/www/example.com/releases as user web, hence ansible should be able, too.
  • In some rare cases something went wrong with the provisioned server and
    the only way fixing is to completely recreate it from scratch.

    This I did after the first occurence of this issue and
    I can do this repeatedly with the same error as result.

I can reproduce this issue each time with a new VM from scratch:

  • Create new minimal Ubuntu Server 18.04.2 LTS system (with OpenSSH server) on Hyper-V.
    • Disable IPv6 in Ubuntu because it caused many issues, also for other users.
      So we are using only IPv4 here.
  • Install ansible tested with trellis,
    Installed the ansible package available on Ubuntu workstation (ansible 2.4.3.0).
  • Clone trellis from GitHub: git clone https://github.com/roots/trellis
    • Set up some example site in group_vars/staging/wordpress_sites.yml
  • Run (initial) provisioning, it should complete just fine.
  • Now try to deploy the example site,
    it should fail very early during deploy with the error shown above.

How can I find out the reason for (and hopefully fix) this strange issue?

For devs that encounter this issue in the future:

In hosts/staging ansible_user=admin was set for the host,
this caused the issue. This also seems to be a bug because not a single source of truth is used for the username, or at least the username can be partly influenced by ansible_user.

This topic was automatically closed after 42 days. New replies are no longer allowed.