From d103c43b5618192884990d60ba5d8b091fbb8ab1 Mon Sep 17 00:00:00 2001
From: bax1489 <fabian.gallenkamp@uni-hamburg.de>
Date: Thu, 5 Sep 2019 16:48:29 +0200
Subject: [PATCH] allow customizing python version used, remove pre-release (->
 use --pre in requirements.txt instead)

---
 configure_otree.yml                  | 28 ++++++++++++++--------------
 group_vars/otree_servers.yml.example |  6 ++++--
 site.yml                             |  6 +++---
 3 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/configure_otree.yml b/configure_otree.yml
index 9a09c17..496355f 100644
--- a/configure_otree.yml
+++ b/configure_otree.yml
@@ -61,36 +61,36 @@
       when: item.value.override
 
 
-    # install python dependencies, otree and
+    # install python dependencies and
     - name: install psycopg2
       pip:
         name: psycopg2
         state: present
         virtualenv: "/home/{{ item.key }}/.venv_otree"
-        virtualenv_command: "/usr/bin/python{{ '3.7' if item.value.pre_release else '3'}} -m venv"
+        virtualenv_command: "{{ item.value.python_binary_path }} -m venv"
       become: yes
       become_user: "{{ item.key }}"
       with_dict: "{{ otree_users }}"
       when: item.value.override
 
-    - name: install otree
-      pip:
-        name: otree
-        state: present
-        extra_args: "{{ '--pre' if item.value.pre_release else '' }}"
-        virtualenv: "/home/{{ item.key }}/.venv_otree"
-        virtualenv_command: "/usr/bin/python{{ '3.7' if item.value.pre_release else '3'}} -m venv"
-      become: yes
-      become_user: "{{ item.key }}"
-      with_dict: "{{ otree_users }}"
-      when: item.value.override
+    #- name: install otree
+    #  pip:
+    #    name: otree
+    #    state: present
+    #    extra_args: "{{ '--pre' if item.value.pre_release else '' }}"
+    #    virtualenv: "/home/{{ item.key }}/.venv_otree"
+    #    virtualenv_command: "/usr/bin/python{{ '3.7' if item.value.pre_release else '3'}} -m venv"
+    #  become: yes
+    #  become_user: "{{ item.key }}"
+    #  with_dict: "{{ otree_users }}"
+    #  when: item.value.override
 
     - name: install requirements if exists
       pip:
         state: present
         requirements: "/home/{{ item.key }}/otree/requirements.txt"
         virtualenv: "/home/{{ item.key }}/.venv_otree"
-        virtualenv_command: "/usr/bin/python{{ '3.7' if item.value.pre_release else '3'}} -m venv"
+        virtualenv_command: "{{ item.value.python_binary_path }} -m venv"
       become: yes
       become_user: "{{ item.key }}"
       with_dict: "{{ otree_users }}"
diff --git a/group_vars/otree_servers.yml.example b/group_vars/otree_servers.yml.example
index be821da..9396cfa 100644
--- a/group_vars/otree_servers.yml.example
+++ b/group_vars/otree_servers.yml.example
@@ -21,8 +21,6 @@ otree_users:
   # linux username
     override: yes
     # should a existing otree environment be overriden
-    pre_release: no
-    # should the pre release version of otree be installed
     redis: "redis://localhost:6379/1"
     # redis queue. Note don't use a slot twice, there are 16 slots available (0-15)
     database: "sqlite:////home/otree1/db.sqlite3"
@@ -37,10 +35,13 @@ otree_users:
     # LOG-LEVEL, set to None ("production: ") to enable further debug messages.
     port: 8005
     # port which is used by this instance
+    python_binary_path: "/usr/bin/python3.7"
+    # python binary used for otree installation
 
   otree2:
     override: no
     app_repo: "https://github.com/oTree-org/oTree.git"    
+    # optional: if set clone provided git repository instead of provided directory
     pre_release: yes
     redis: "redis://localhost:6379/2"
     database: "sqlite:////home/otree2/db.sqlite3"
@@ -49,6 +50,7 @@ otree_users:
     secret_key: "sdfunlidsgjndrsgf"
     production:
     port: 8006
+    python_binary_path: "/usr/bin/python3.7"
 
 ssl_certificate_path: "/etc/ssl/certs/{{ otree_domain }}.crt"
 ssl_certificate_key_path: "/etc/ssl/private/{{ otree_domain }}.key"
diff --git a/site.yml b/site.yml
index 301b99c..ac94a32 100644
--- a/site.yml
+++ b/site.yml
@@ -10,9 +10,9 @@
       - python3-pip 
       - python3-dev
       - python3-venv
-      - python3.7
-      - python3.7-dev
-      - python3.7-venv
+#      - python3.7
+#      - python3.7-dev
+#      - python3.7-venv
       - python-psycopg2
       - libpq-dev
       - redis-server
-- 
GitLab