【问题标题】:ansible django deploy permission denied pip packagesansible django deploy 权限被拒绝 pip 包
【发布时间】:2018-05-10 04:22:33
【问题描述】:

我正在尝试使用 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'

以下是其他一些相关代码:

requirements/production.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/

【问题讨论】:

    标签: django ubuntu ansible permission-denied


    【解决方案1】:

    sudo 添加到 pip 安装部分:

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

    【讨论】:

    • 成功了!但 sudo 实际上要求输入密码,所以我通过在 cmd 行使用 --ask-sudo-pass 来解决它
    猜你喜欢
    • 1970-01-01
    • 2015-06-18
    • 2016-03-12
    • 1970-01-01
    • 1970-01-01
    • 2016-02-12
    • 1970-01-01
    • 2021-05-21
    • 1970-01-01
    相关资源
    最近更新 更多