Skip to content
Snippets Groups Projects
Commit 15028fc0 authored by Gallenkamp, Fabian's avatar Gallenkamp, Fabian
Browse files

allow configurable home directory path

parent f1806711
No related branches found
No related tags found
No related merge requests found
......@@ -7,13 +7,13 @@
- name: remove old projects
file:
state: absent
path: "/home/{{ item.key }}/otree/"
path: "{{ home_path }}/{{ item.key }}/otree/"
with_dict: "{{ otree_users }}"
when: item.value.override
- name: add project folder again
file:
path: "/home/{{ item.key }}/otree/"
path: "{{ home_path }}/{{ item.key }}/otree/"
state: directory
owner: "{{ item.key }}"
group: "{{ item.key }}"
......@@ -24,14 +24,14 @@
- name: copy over ssh key files
synchronize:
src: "keys/{{ item.key }}/"
dest: "/home/{{ item.key }}/.ssh/"
dest: "{{ home_path }}/{{ item.key }}/.ssh/"
delete: yes
with_dict: "{{ otree_users }}"
when: item.value.override and item.value.app_repo is defined
- name: set owner and group permissions restricted for key files
file:
path: "/home/{{ item.key }}/.ssh/"
path: "{{ home_path }}/{{ item.key }}/.ssh/"
state: directory
owner: "{{ item.key }}"
group: "{{ item.key }}"
......@@ -42,7 +42,7 @@
- name: set owner and group permissions for folder
file:
path: "/home/{{ item.key }}/.ssh/"
path: "{{ home_path }}/{{ item.key }}/.ssh/"
state: directory
owner: "{{ item.key }}"
group: "{{ item.key }}"
......@@ -53,10 +53,10 @@
- name: clone projects accordingly
git:
repo: "{{ item.value.app_repo }}"
dest: "/home/{{ item.key }}/otree/"
dest: "{{ home_path }}/{{ item.key }}/otree/"
accept_hostkey: yes
recursive: yes
key_file: "/home/{{ item.key }}/.ssh/id"
key_file: "{{ home_path }}/{{ item.key }}/.ssh/id"
become: yes
become_user: "{{ item.key }}"
with_dict: "{{ otree_users }}"
......@@ -65,14 +65,14 @@
- name: copy over project files
synchronize:
src: "files/{{ item.key }}/"
dest: "/home/{{ item.key }}/otree/"
dest: "{{ home_path }}/{{ item.key }}/otree/"
delete: yes
with_dict: "{{ otree_users }}"
when: item.value.override and item.value.app_repo is not defined
- name: set owner and group permissions
file:
path: "/home/{{ item.key }}/otree/"
path: "{{ home_path }}/{{ item.key }}/otree/"
state: directory
owner: "{{ item.key }}"
group: "{{ item.key }}"
......@@ -84,7 +84,7 @@
- name: remove old venv
file:
state: absent
path: "/home/{{ item.key }}/.venv_otree/"
path: "{{ home_path }}/{{ item.key }}/.venv_otree/"
become: yes
become_user: "{{ item.key }}"
with_dict: "{{ otree_users }}"
......@@ -96,7 +96,7 @@
pip:
name: psycopg2
state: present
virtualenv: "/home/{{ item.key }}/.venv_otree"
virtualenv: "{{ home_path }}/{{ item.key }}/.venv_otree"
virtualenv_command: "{{ item.value.python_binary_path }} -m venv"
become: yes
become_user: "{{ item.key }}"
......@@ -108,7 +108,7 @@
# name: otree
# state: present
# extra_args: "{{ '--pre' if item.value.pre_release else '' }}"
# virtualenv: "/home/{{ item.key }}/.venv_otree"
# virtualenv: "{{ home_path }}/{{ 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 }}"
......@@ -118,20 +118,20 @@
- name: install requirements if exists
pip:
state: present
requirements: "/home/{{ item.key }}/otree/requirements.txt"
virtualenv: "/home/{{ item.key }}/.venv_otree"
requirements: "{{ home_path }}/{{ item.key }}/otree/requirements.txt"
virtualenv: "{{ home_path }}/{{ item.key }}/.venv_otree"
virtualenv_command: "{{ item.value.python_binary_path }} -m venv"
become: yes
become_user: "{{ item.key }}"
with_dict: "{{ otree_users }}"
when: item.value.override
ignore_errors: yes
#ignore_errors: yes
# reset and prepare otree
- name: reset otree database
shell: "source /home/{{ item.key }}/.venv_otree/bin/activate && otree resetdb --noinput"
shell: "source {{ home_path }}/{{ item.key }}/.venv_otree/bin/activate && otree resetdb --noinput"
args:
chdir: "/home/{{ item.key }}/otree/"
chdir: "{{ home_path }}/{{ item.key }}/otree/"
executable: /bin/bash
environment:
DATABASE_URL: "{{ item.value.database }}"
......
......@@ -2,6 +2,8 @@
ansible_user: "mylinuxuser"
ansible_connection: "local"
home_path: "/home"
nginx_config_path: "/etc/nginx"
nginx_sites_available: "{{ nginx_config_path }}/sites-available"
nginx_sites_enabled: "{{ nginx_config_path }}/sites-enabled"
......@@ -19,8 +21,8 @@ otree_users:
# should a existing otree environment be overriden
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"
# which database should be used. Examples: "postgres://USER:PASSWORD@HOST:PORT/NAME" or "sqlite:////home/user/db.sqlite3"
database: "sqlite:///{{ home_path }}/otree1/db.sqlite3"
# which database should be used. Examples: "postgres://USER:PASSWORD@HOST:PORT/NAME" or "sqlite:///{{ home_path }}/user/db.sqlite3"
admin_pw: "mysecretpw1"
# otree admin password
auth_level: "STUDY"
......@@ -41,7 +43,7 @@ otree_users:
# for ssh: git@domain:project-group/project.git
pre_release: yes
redis: "redis://localhost:6379/2"
database: "sqlite:////home/otree2/db.sqlite3"
database: "sqlite:///{{ home_path }/otree2/db.sqlite3"
admin_pw: "mysecretpw2"
auth_level: "DEMO"
secret_key: "sdfunlidsgjndrsgf"
......
......@@ -42,6 +42,8 @@
name: "{{ item.key }}"
shell: /bin/bash
groups: ["{{ otree_group_name }}"]
home: "{{ home_path }}/{{ item.key }}"
move_home: yes
state: present
with_dict: "{{ otree_users }}"
......
[program:{{ item.key }}]
directory=/home/{{ item.key }}/otree/
command=/bin/bash -c "source /home/{{ item.key }}/.venv_otree/bin/activate && otree runprodserver"
directory={{ home_path }}/{{ item.key }}/otree/
command=/bin/bash -c "source {{ home_path }}/{{ item.key }}/.venv_otree/bin/activate && otree runprodserver"
environment=DATABASE_URL="{{ item.value.database }}",REDIS_URL="{{ item.value.redis }}",OTREE_ADMIN_PASSWORD="{{ item.value.admin_pw }}",OTREE_AUTH_LEVEL="{{ item.value.auth_level }}",OTREE_SECRET_KEY="{{ item.value.secret_key }}",OTREE_PRODUCTION="{{ item.value.production }}",PORT={{ item.value.port }}
autostart=true
autorestart=true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment