From afe7c9e51c07479d77a8fe909f5186dbd81c893c Mon Sep 17 00:00:00 2001 From: Eliot Berriot <contact@eliotberriot.com> Date: Fri, 10 May 2019 11:33:18 +0200 Subject: [PATCH] Virtual env --- molecule/default/molecule.yml | 3 ++- molecule/default/tests/test_default.py | 11 +++++++++++ tasks/funkwhale.yml | 15 +++++++++++++-- tasks/main.yml | 6 +++--- tasks/packages.yml | 3 ++- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index f52748f..e9b1cf4 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -6,7 +6,7 @@ driver: lint: name: yamllint platforms: - - name: instance + - name: debian-stretch image: alehaa/debian-systemd:stretch command: /sbin/init tmpfs: @@ -19,6 +19,7 @@ provisioner: name: ansible lint: name: ansible-lint + verifier: name: testinfra lint: diff --git a/molecule/default/tests/test_default.py b/molecule/default/tests/test_default.py index 0f4439c..14b1ebb 100644 --- a/molecule/default/tests/test_default.py +++ b/molecule/default/tests/test_default.py @@ -97,3 +97,14 @@ def test_api_download(host): assert f.exists is True assert f.contains('__version__ = "0.19.0-rc2"') is True + + +def test_virtualenv(host): + expected_packages = {"Django", "djangorestframework", "celery"} + packages = host.pip_package.get_packages( + pip_path="/srv/funkwhale/virtualenv/bin/pip" + ) + names = set(packages.keys()) + + intersection = expected_packages & names + assert intersection == expected_packages diff --git a/tasks/funkwhale.yml b/tasks/funkwhale.yml index 4327615..44e3e61 100644 --- a/tasks/funkwhale.yml +++ b/tasks/funkwhale.yml @@ -1,7 +1,5 @@ --- - - - name: "Create funkwhale user" user: name: "{{ funkwhale_username }}" @@ -48,3 +46,16 @@ src: https://dev.funkwhale.audio/funkwhale/funkwhale/-/jobs/artifacts/{{ funkwhale_version }}/download?job=build_api dest: "{{ funkwhale_install_path }}" remote_src: true + +- name: "Setup virtualenv" + pip: + name: wheel + virtualenv: "{{ funkwhale_install_path }}/virtualenv" + virtualenv_python: python3 + + +- name: "Install python dependencies" + pip: + requirements: "{{ funkwhale_install_path }}/api/requirements.txt" + virtualenv: "{{ funkwhale_install_path }}/virtualenv" + virtualenv_python: python3 diff --git a/tasks/main.yml b/tasks/main.yml index f22e3ac..1f5d635 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,6 +1,6 @@ --- -# - include: packages.yml -# - include: db.yml -# - include: redis.yml +- include: packages.yml +- include: db.yml +- include: redis.yml - include: funkwhale.yml - include: nginx.yml diff --git a/tasks/packages.yml b/tasks/packages.yml index f71a2ac..82bbeae 100644 --- a/tasks/packages.yml +++ b/tasks/packages.yml @@ -6,7 +6,8 @@ - "python3" - "python3-dev" - "python3-pip" - - "python3-venv" + - "python-virtualenv" # for ansible + - "python3-virtualenv" - "libldap2-dev" - "libsasl2-dev" - "git" -- GitLab