Skip to content

Commit 52e7c70

Browse files
committed
feat: always install libretime in a python venv
1 parent d74692a commit 52e7c70

14 files changed

+50
-37
lines changed

defaults/main.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ libretime_log_dir: /var/log/libretime
1919
libretime_config_dir: /etc/libretime
2020
libretime_config_filepath: "{{ libretime_config_dir }}/config.yml"
2121
libretime_storage_dir: /srv/libretime
22-
23-
# Experimental !
24-
# libretime_venv:
22+
libretime_venv_dir: /opt/libretime
2523

2624
# > Analyzer
2725
########################################################################################

molecule/default/molecule.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ provisioner:
3232
instance2:
3333
libretime_public_url: http://localhost:{{ libretime_listen_port }}/
3434
libretime_listen_port: 9002
35-
libretime_venv: /opt/libretime
3635

3736
verifier:
3837
name: testinfra

tasks/analyzer.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,19 @@
1010
libretime-analyzer[{{ libretime_analyzer_pip_extras | join(',') }}]
1111
@ file://{{ libretime_checkout_dest }}/analyzer
1212
state: latest # noqa package-latest
13-
virtualenv: "{{ libretime_venv | default(omit) }}"
13+
virtualenv: "{{ libretime_venv_dir }}"
1414
notify: Restart libretime
1515
when: libretime_checkout is changed
1616

17+
- name: Create analyzer entrypoint symlinks
18+
ansible.builtin.file:
19+
src: "{{ libretime_venv_dir }}/bin/libretime-analyzer"
20+
dest: /usr/local/bin/libretime-analyzer
21+
owner: root
22+
group: root
23+
state: link
24+
force: true
25+
1726
- name: Create analyzer home directory
1827
ansible.builtin.file:
1928
path: "{{ libretime_home }}/analyzer"

tasks/api.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,19 @@
1010
libretime-api[{{ (['prod'] + libretime_api_pip_extras) | join(',') }}]
1111
@ file://{{ libretime_checkout_dest }}/api
1212
state: latest # noqa package-latest
13-
virtualenv: "{{ libretime_venv | default(omit) }}"
13+
virtualenv: "{{ libretime_venv_dir }}"
1414
notify: Restart libretime
1515
when: libretime_checkout is changed
1616

17+
- name: Create api entrypoint symlinks
18+
ansible.builtin.file:
19+
src: "{{ libretime_venv_dir }}/bin/libretime-api"
20+
dest: /usr/local/bin/libretime-api
21+
owner: root
22+
group: root
23+
state: link
24+
force: true
25+
1726
- name: Setup api systemd socket
1827
ansible.builtin.import_tasks: _systemd.yml
1928
vars:

tasks/api_client.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
libretime-api-client
66
@ file://{{ libretime_checkout_dest }}/api-client
77
state: latest # noqa package-latest
8-
virtualenv: "{{ libretime_venv | default(omit) }}"
8+
virtualenv: "{{ libretime_venv_dir }}"
99
notify: Restart libretime
1010
when: libretime_checkout is changed

tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
ansible.builtin.pip:
108108
name: [pip, setuptools, wheel]
109109
state: latest # noqa package-latest
110-
virtualenv: "{{ libretime_venv | default(omit) }}"
110+
virtualenv: "{{ libretime_venv_dir }}"
111111
virtualenv_command: python3 -m venv
112112
virtualenv_site_packages: true
113113

@@ -155,7 +155,7 @@
155155
- name: Run database migration
156156
become: true
157157
become_user: "{{ libretime_user }}"
158-
ansible.builtin.command: "{{ libretime_venv | default('/usr/local') }}/bin/libretime-api migrate"
158+
ansible.builtin.command: "{{ libretime_venv_dir }}/bin/libretime-api migrate"
159159
register: migration
160160
changed_when: >
161161
"No migrations to apply." not in migration.stdout

tasks/playout.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,23 @@
1010
libretime-playout[{{ libretime_playout_pip_extras | join(',') }}]
1111
@ file://{{ libretime_checkout_dest }}/playout
1212
state: latest # noqa package-latest
13-
virtualenv: "{{ libretime_venv | default(omit) }}"
13+
virtualenv: "{{ libretime_venv_dir }}"
1414
notify: Restart libretime
1515
when: libretime_checkout is changed
1616

17+
- name: Create playout entrypoint symlinks
18+
ansible.builtin.file:
19+
src: "{{ libretime_venv_dir }}/bin/{{ item }}"
20+
dest: /usr/local/bin/{{ item }}
21+
owner: root
22+
group: root
23+
state: link
24+
force: true
25+
with_items:
26+
- libretime-liquidsoap
27+
- libretime-playout
28+
- libretime-playout-notify
29+
1730
- name: Create playout home directory
1831
ansible.builtin.file:
1932
path: "{{ libretime_home }}/playout"

tasks/shared.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
libretime-shared
66
@ file://{{ libretime_checkout_dest }}/shared
77
state: latest # noqa package-latest
8-
virtualenv: "{{ libretime_venv | default(omit) }}"
8+
virtualenv: "{{ libretime_venv_dir }}"
99
notify: Restart libretime
1010
when: libretime_checkout is changed

tasks/worker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
libretime-worker[{{ libretime_worker_pip_extras | join(',') }}]
66
@ file://{{ libretime_checkout_dest }}/worker
77
state: latest # noqa package-latest
8-
virtualenv: "{{ libretime_venv | default(omit) }}"
8+
virtualenv: "{{ libretime_venv_dir }}"
99
notify: Restart libretime
1010
when: libretime_checkout is changed
1111

templates/systemd/libretime-analyzer.service.j2

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ ProtectKernelTunables=true
1717
ProtectProc=invisible
1818
ProtectSystem=full
1919

20-
{% if libretime_venv is defined %}
21-
Environment=PATH={{ libretime_venv }}/bin:/usr/local/bin:/usr/bin:/bin
22-
{% endif %}
23-
20+
Environment=PATH={{ libretime_venv_dir }}/bin:/usr/local/bin:/usr/bin:/bin
2421
Environment=LIBRETIME_CONFIG_FILEPATH={{ libretime_config_filepath }}
2522
Environment=LIBRETIME_LOG_FILEPATH={{ libretime_log_dir }}/analyzer.log
2623
WorkingDirectory={{ libretime_home }}/analyzer
2724

28-
ExecStart={{ libretime_venv | default('/usr/local') }}/bin/libretime-analyzer
25+
ExecStart={{ libretime_venv_dir }}/bin/libretime-analyzer
2926
Restart=always
3027

3128
User={{ libretime_user }}

templates/systemd/libretime-api.service.j2

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ ProtectKernelTunables=true
1818
ProtectProc=invisible
1919
ProtectSystem=full
2020

21-
{% if libretime_venv is defined %}
22-
Environment=PATH={{ libretime_venv }}/bin:/usr/local/bin:/usr/bin:/bin
23-
{% endif %}
24-
21+
Environment=PATH={{ libretime_venv_dir }}/bin:/usr/local/bin:/usr/bin:/bin
2522
Environment=LIBRETIME_CONFIG_FILEPATH={{ libretime_config_filepath }}
2623
Environment=LIBRETIME_LOG_FILEPATH={{ libretime_log_dir }}/api.log
2724

2825
Type=notify
2926
KillMode=mixed
30-
ExecStart={{ libretime_venv | default('/usr') }}/bin/python3 -m gunicorn \
27+
ExecStart={{ libretime_venv_dir }}/bin/python3 -m gunicorn \
3128
--workers 4 \
3229
--worker-class uvicorn.workers.UvicornWorker \
3330
--log-file - \

templates/systemd/libretime-liquidsoap.service.j2

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ ProtectKernelTunables=true
1717
ProtectProc=invisible
1818
ProtectSystem=full
1919

20-
{% if libretime_venv is defined %}
21-
Environment=PATH={{ libretime_venv }}/bin:/usr/local/bin:/usr/bin:/bin
22-
{% endif %}
23-
20+
Environment=PATH={{ libretime_venv_dir }}/bin:/usr/local/bin:/usr/bin:/bin
2421
Environment=LIBRETIME_CONFIG_FILEPATH={{ libretime_config_filepath }}
2522
Environment=LIBRETIME_LOG_FILEPATH={{ libretime_log_dir }}/liquidsoap.log
2623
WorkingDirectory={{ libretime_home }}/playout
2724

28-
ExecStart={{ libretime_venv | default('/usr/local') }}/bin/libretime-liquidsoap
25+
ExecStart={{ libretime_venv_dir }}/bin/libretime-liquidsoap
2926
Restart=always
3027

3128
User={{ libretime_user }}

templates/systemd/libretime-playout.service.j2

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@ ProtectKernelTunables=true
1919
ProtectProc=invisible
2020
ProtectSystem=full
2121

22-
{% if libretime_venv is defined %}
23-
Environment=PATH={{ libretime_venv }}/bin:/usr/local/bin:/usr/bin:/bin
24-
{% endif %}
25-
22+
Environment=PATH={{ libretime_venv_dir }}/bin:/usr/local/bin:/usr/bin:/bin
2623
Environment=LIBRETIME_CONFIG_FILEPATH={{ libretime_config_filepath }}
2724
Environment=LIBRETIME_LOG_FILEPATH={{ libretime_log_dir }}/playout.log
2825
WorkingDirectory={{ libretime_home }}/playout
2926

30-
ExecStart={{ libretime_venv | default('/usr/local') }}/bin/libretime-playout
27+
ExecStart={{ libretime_venv_dir }}/bin/libretime-playout
3128
Restart=always
3229

3330
User={{ libretime_user }}

templates/systemd/libretime-worker.service.j2

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ ProtectKernelTunables=true
1717
ProtectProc=invisible
1818
ProtectSystem=full
1919

20-
{% if libretime_venv is defined %}
21-
Environment=PATH={{ libretime_venv }}/bin:/usr/local/bin:/usr/bin:/bin
22-
{% endif %}
23-
20+
Environment=PATH={{ libretime_venv_dir }}/bin:/usr/local/bin:/usr/bin:/bin
2421
Environment=LIBRETIME_CONFIG_FILEPATH={{ libretime_config_filepath }}
2522
Environment=LIBRETIME_LOG_FILEPATH={{ libretime_log_dir }}/worker.log
2623
WorkingDirectory={{ libretime_home }}/worker
2724

28-
ExecStart=/usr/bin/sh -c '{{ libretime_venv | default('/usr/local') }}/bin/celery worker \
25+
ExecStart=/usr/bin/sh -c '{{ libretime_venv_dir }}/bin/celery worker \
2926
--app=libretime_worker.tasks:worker \
3027
--config=libretime_worker.config \
3128
--time-limit=1800 \

0 commit comments

Comments
 (0)