Setting up a python virtual environment using Salt virtualenv.managed or pip.installed?

I am trying to use either state pip.installedor virtualenv.managedto configure a virtual file using a requirements file that lives on a minion (previously set state git.latest). Here is the version using pip.installed:

mysite-env:
  virtualenv.managed:
    - name: /opt/django/mysite
    - cwd: /opt/django/mysite
    - user: mysite
    - runas: mysite
    - system_site_packages: True

mysite-reqs:
  pip.installed:
    - no_index: True
    - find_links: http://pypi.mysite.com/
    - requirements: /opt/django/mysite/requirements/production.txt
    - pip_exists_action: switch
    - cwd: /opt/django/mysite
    - pip_bin: /opt/django/mysite/bin/pip
    - bin_env: /opt/django/mysite
    - user: mysite
    - watch:
      - git: mysite-project

When I try to run this state, I get this error:

          ID: mysite-reqs
    Function: pip.installed
      Result: False
     Comment: Unable to process requirements file /opt/django/mysite/requirements/production.txt. Error: Ignoring indexes: https://pypi.python.org/simple/
              Could not open requirements file: [Errno 2] No such file or directory: '/tmp/requirements.txt'
              Storing debug log for failure in /home/mysite/.pip/pip.log

But this is not the way that I pass on the requirements. It looks like an error, for example, /tmp/requirements.txthard-coded because it expects me to use the URL salt://instead of the local file path.

Am I doing something wrong? This is a mistake, and is there a good way around it?

+4
1

, Saltstack Python, .

, , , SaltStack /tmp chowning.

, :

no_chown: True

, .

+4

Source: https://habr.com/ru/post/1535085/


All Articles