Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use virtualenv instead of user pip #44

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pretalx_database_port: 5432
pretalx_staticfiles_directory: /usr/share/webapps/pretalx{{ pretalx_instance_identifier }}/static/
pretalx_data_dir: /usr/share/webapps/pretalx{{ pretalx_instance_identifier }}/data/
pretalx_media_dir: /usr/share/webapps/pretalx{{ pretalx_instance_identifier }}/media/
pretalx_virtualenv: /usr/share/webapps/pretalx{{ pretalx_instance_identifier }}/venv/
pretalx_webserver_group: http
pretalx_domain: localhost
pretalx_url: https://{{ pretalx_domain }}
Expand Down
19 changes: 13 additions & 6 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,45 @@
systemd:
daemon_reload: true

- name: Install pretalx plugins

Check failure on line 6 in handlers/main.yml

View workflow job for this annotation

GitHub Actions / lint

no-changed-when

Commands should not change things if nothing needs doing.
shell: cd {{ pretalx_system_home }}/plugins/{{ item.name }} && python{{ pretalx_system_python_version }} setup.py develop --user
shell: cd ~/plugins/{{ item.name }} && {{ pretalx_python }} setup.py develop --user
with_items: "{{ pretalx_plugins }}"
become: true
become_user: "{{ pretalx_system_user }}"

- name: Compile messages for plugins

Check failure on line 12 in handlers/main.yml

View workflow job for this annotation

GitHub Actions / lint

no-changed-when

Commands should not change things if nothing needs doing.
shell: cd {{ pretalx_system_home }}/plugins/{{ item.name }} && make
with_items: "{{ pretalx_plugins }}"
become: true
become_user: "{{ pretalx_system_user }}"

- name: Run pretalx migrations

Check failure on line 18 in handlers/main.yml

View workflow job for this annotation

GitHub Actions / lint

no-changed-when

Commands should not change things if nothing needs doing.
command: python{{ pretalx_system_python_version }} -m pretalx migrate
command: "{{ pretalx_python }} -m pretalx migrate"
become: true
become_user: "{{ pretalx_system_user }}"

- name: Compile pretalx messages

Check failure on line 23 in handlers/main.yml

View workflow job for this annotation

GitHub Actions / lint

no-changed-when

Commands should not change things if nothing needs doing.
command: python{{ pretalx_system_python_version }} -m pretalx compilemessages
command: "{{ pretalx_python }} -m pretalx compilemessages"
become: true
become_user: "{{ pretalx_system_user }}"

- name: Compile pretalx styles

Check failure on line 28 in handlers/main.yml

View workflow job for this annotation

GitHub Actions / lint

no-changed-when

Commands should not change things if nothing needs doing.
command: python{{ pretalx_system_python_version }} -m pretalx regenerate_css
command: "{{ pretalx_python }} -m pretalx regenerate_css"
become: true
become_user: "{{ pretalx_system_user }}"

- name: Compile pretalx javascript

Check failure on line 33 in handlers/main.yml

View workflow job for this annotation

GitHub Actions / lint

no-changed-when

Commands should not change things if nothing needs doing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't think this is quite correct. Instead, we can just replace the collectstatic and compress commands with rebuild – rebuild runs collectstatic, compress and also compilemessages.

command: "{{ pretalx_python }} -m pretalx rebuild --npm-install"
become: true
become_user: "{{ pretalx_system_user }}"

- name: Collect static pretalx files

Check failure on line 38 in handlers/main.yml

View workflow job for this annotation

GitHub Actions / lint

no-changed-when

Commands should not change things if nothing needs doing.
command: python{{ pretalx_system_python_version }} -m pretalx collectstatic --noinput
command: "{{ pretalx_python }} -m pretalx collectstatic --noinput"
become: true
become_user: "{{ pretalx_system_user }}"

- name: Compress static pretalx files

Check failure on line 43 in handlers/main.yml

View workflow job for this annotation

GitHub Actions / lint

no-changed-when

Commands should not change things if nothing needs doing.
command: python{{ pretalx_system_python_version }} -m pretalx compress
command: "{{ pretalx_python }} -m pretalx compress"
become: true
become_user: "{{ pretalx_system_user }}"

Expand Down Expand Up @@ -66,3 +71,5 @@
service:
name: pretalx@{{ pretalx_instance_identifier }}.socket
state: restarted


Check failure on line 75 in handlers/main.yml

View workflow job for this annotation

GitHub Actions / lint

yaml[empty-lines]

Too many blank lines (2 > 0)
22 changes: 11 additions & 11 deletions tasks/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
- "{{ pretalx_staticfiles_directory }}"
- "{{ pretalx_data_dir }}"
- "{{ pretalx_media_dir }}"
- "{{ pretalx_virtualenv }}"
tags:
- pretalx

- name: Install redis client
pip:
name: django_redis
executable: pip3
extra_args: --user
state: latest # noqa package-latest
virtualenv: "{{ pretalx_virtualenv }}"
become: true
become_user: "{{ pretalx_system_user }}"
when: pretalx_redis or pretalx_celery
Expand All @@ -38,9 +38,8 @@
- name: Install gunicorn
pip:
name: gunicorn
executable: pip3
extra_args: --user
state: latest # noqa package-latest
virtualenv: "{{ pretalx_virtualenv }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're using |default(omit) in some places but not in others, is that intentional?

become: true
become_user: "{{ pretalx_system_user }}"
tags:
Expand Down Expand Up @@ -93,14 +92,14 @@
- name: Install pretalx (latest)
pip:
name: "pretalx{{ pretalx_extra }}"
executable: pip3
extra_args: --user
state: latest # noqa package-latest
virtualenv: "{{ pretalx_virtualenv | default(omit) }}"
notify:
- Restart pretalx service
- Restart worker service
- Run pretalx migrations
- Collect static pretalx files
- Compile pretalx javascript
- Compress static pretalx files
- Compile pretalx messages
- Compile pretalx styles
Expand All @@ -114,13 +113,13 @@
- name: Install pretalx (versioned)
pip:
name: "pretalx{{ pretalx_extra }}"
executable: pip3
extra_args: --user
version: "{{ pretalx_version }}"
version: "{{ pretalx_version }}" # noqa package-lastest
virtualenv: "{{ pretalx_virtualenv | default(omit) }}"
notify:
- Restart pretalx service
- Restart worker service
- Run pretalx migrations
- Compile pretalx javascript
- Collect static pretalx files
- Compress static pretalx files
- Compile pretalx messages
Expand All @@ -135,14 +134,14 @@
- name: Install pretalx (git)
pip:
name: "git+{{ pretalx_git_url }}@{{ pretalx_git_version }}#egg=pretalx{{ pretalx_extra }}"
executable: pip3
extra_args: --user
state: latest # noqa package-latest
virtualenv: "{{ pretalx_virtualenv | default(omit) }}"
notify:
- Restart pretalx service
- Restart worker service
- Run pretalx migrations
- Collect static pretalx files
- Compile pretalx javascript
- Compress static pretalx files
- Compile pretalx messages
- Compile pretalx styles
Expand Down Expand Up @@ -181,6 +180,7 @@
- Run pretalx migrations
- Collect static pretalx files
- Compress static pretalx files
- Compile pretalx javascript
- Compile pretalx messages
- Compile pretalx styles
- Install pretalx plugins
Expand Down
1 change: 1 addition & 0 deletions tasks/requirements_debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- gcc
- gettext
- git
- npm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Included this in a separate commit, just to get it merged while we talk about the rest here.

state: present
tags:
- pretalx
Expand Down
5 changes: 2 additions & 3 deletions templates/pretalx-worker.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ After=network.target
[Service]
User={{ pretalx_system_user_prefix }}%i
Group={{ pretalx_system_user_prefix }}%i
WorkingDirectory=/home/{{ pretalx_system_user_prefix }}%i/.local/lib/python{{ pretalx_system_python_version }}/site-packages/pretalx
ExecStart=/home/{{ pretalx_system_user_prefix }}%i/.local/bin/celery -A pretalx.celery_app worker -l info
WorkingDirectory=/home/{{ pretalx_system_user_prefix }}%i
ExecStart={{ pretalx_virtualenv }}/bin/celery -A pretalx.celery_app worker -l info
WorkingDirectory={{ pretalx_virtualenv }}/lib/python{{ pretalx_system_python_version }}/site-packages/pretalx
Restart=on-failure
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
Expand Down
6 changes: 3 additions & 3 deletions templates/pretalx.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ After=network.target
[Service]
User={{ pretalx_system_user_prefix }}%i
Group={{ pretalx_system_user_prefix }}%i
WorkingDirectory=/home/{{ pretalx_system_user_prefix }}%i/.local/lib/python{{ pretalx_system_python_version }}/site-packages/pretalx
ExecStart=/home/{{ pretalx_system_user_prefix }}%i/.local/bin/gunicorn --bind unix:/run/gunicorn/pretalx_%i --workers {{ pretalx_service_workers }} --max-requests {{ pretalx_service_workers_max_requests }} --max-requests-jitter {{ pretalx_service_workers_max_requests_jitter }} pretalx.wsgi
WorkingDirectory={{ pretalx_virtualenv }}/lib/python{{ pretalx_system_python_version }}/site-packages/pretalx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've removed the parametrisation (%i) in this service file, fundamentally changing how it's used. I don't think that's a good idea – while I personally don't run this ansible role anymore (in favour of something already using venvs, albeit more customized ones), changing the behaviour like that doesn't seem great.

ExecStart={{ pretalx_virtualenv }}/bin/gunicorn --bind unix:/run/gunicorn/pretalx_%i --workers {{ pretalx_service_workers }} --max-requests {{ pretalx_service_workers_max_requests }} --max-requests-jitter {{ pretalx_service_workers_max_requests_jitter }} pretalx.wsgi
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
Loading