ansible django 部署权限被拒绝 pip 包

艾克西尔

我正在尝试使用 ansible 将我的 django 部署到 aws ubuntu 机器。但是,我一直在我的包裹上拒绝此权限。我该如何解决这个问题?谢谢。

这是错误:

$ ./ansible.sh deploy.yaml
.....

  Downloading from URL https://pypi.python.org/packages/a6/1c/72a18c8c7502ee1b38a604a5c5243aa8c2a64f4bba4e6631b1b8972235dd/futures-3.1.1-py2-none-any.whl#md5=61a88f749eb3655042f95d198f783ef3 (from https://pypi.python.org/simple/futures/)
Installing collected packages: boto3, botocore, certifi, cffi, chardet, coreapi, coreschema, cryptography, Django, django-bootstrap3, django-countries, django-datatable, django-rest-swagger, django-storages, djangorestframework, docutils, gunicorn, idna, itypes, Jinja2, jmespath, MarkupSafe, olefile, openapi-codec, paramiko, Pillow, psycopg2, pyasn1, pycparser, PyNaCl, python-dateutil, python-decouple, pytz, PyYAML, requests, s3transfer, simplejson, six, sorl-thumbnail, uritemplate, urllib3, dj-database-url, asn1crypto, bcrypt, futures
Cleaning up...
  Removing temporary dir /tmp/pip_build_deploy...
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1436, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 672, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 902, in move_wheel_files
    pycompile=self.pycompile,
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 206, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 193, in clobber
    os.makedirs(destsubdir)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/boto3-1.4.7.dist-info'

下面是一些其他相关的代码:

需求/生产.txt

https://gist.github.com/anonymous/79f4d0b43f39fc317d33e09dbd1c58ba

部署.yaml

https://gist.github.com/anonymous/02f68f05dab3f6858ab6aa10c89f5e09

Ubuntu:14.04

我检查了我用来访问 ubuntu 的用户组,它在组中有 sudo。我们需要以 root 身份运行吗?

$ groups deployuser
deployuser : deployuser sudo

我根据这个说明建立了我的 ansible:

https://baxeico.wordpress.com/2017/05/02/how-to-deploy-a-django-project-in-15-minutes-with-ansible/

康斯坦丁·苏沃洛夫

添加sudo到 pip install 部分:

- hosts: all
  become: yes # <- here
  gather_facts: no
  tasks:
  - name: install python requirements
    pip: requirements={{ repo_dir }}/requirements/production.txt extra_args=--upgrade

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章