Merge pull request 'update to 1.6.2' (#14) from 1.6.2 into staging

Reviewed-on: #14
Reviewed-by: muppeth <muppeth@no-reply@disroot.org>
This commit is contained in:
meaz 2024-11-24 08:06:03 +01:00
commit 25c890039c
9 changed files with 83 additions and 73 deletions

6
.ansible-lint Normal file
View file

@ -0,0 +1,6 @@
skip_list:
- fqcn-builtins
- fqcn[action]
- fqcn[action-core]
- fqcn[canonical]
- name[casing]

View file

@ -1,9 +1,10 @@
---
- hosts: libretranslate
- name: 'Libretranslate playbook'
hosts: 'libretranslate'
roles:
- nginx
- libretranslate
- 'nginx'
- 'libretranslate'
vars_files:
- ../defaults/main.yml

View file

@ -1,6 +1,6 @@
---
libretranslate_version: '1.6.1'
libretranslate_version: '1.6.2'
libretranslate_user: 'libretranslate'
libretranslate_group: 'libretranslate'
@ -21,27 +21,26 @@ libretranslate_environment:
## The following need to be uncommented and parameters to be set
- 'LT_HOST={{ libretranslate_host }}'
- 'LT_PORT=5000'
#- 'LT_CHAR_LIMIT='
#- 'LT_REQ_LIMIT='
#- 'LT_BATCH_LIMIT='
# - 'LT_CHAR_LIMIT='
# - 'LT_REQ_LIMIT='
# - 'LT_BATCH_LIMIT='
- 'LT_FRONTEND_LANGUAGE_SOURCE=auto'
- 'LT_FRONTEND_LANGUAGE_TARGET=locale'
- 'LT_FRONTEND_TIMEOUT=500'
#- 'LT_LOAD_ONLY='
# - 'LT_LOAD_ONLY='
- 'LT_THREADS=4'
#- 'LT_URL_PREFIX='
## The following just need to be uncommented, it doesn't need parameters
#- 'LT_DEBUG'
#- 'LT_SSL'
#- 'LT_SUGGESTIONS'
#- 'LT_DISABLE_FILES_TRANSLATION'
#- 'LT_DISABLE_WEB_UI'
#- 'LT_METRICS'
# - 'LT_URL_PREFIX='
## The following just need to be uncommented, it doesn't need parameters
# - 'LT_DEBUG'
# - 'LT_SSL'
# - 'LT_SUGGESTIONS'
# - 'LT_DISABLE_FILES_TRANSLATION'
# - 'LT_DISABLE_WEB_UI'
# - 'LT_METRICS'
- 'LT_UPDATE_MODELS'
#- 'LT_FORCE_UPDATE_MODELS' # uncomment this if you want to force the update of all languages.
# - 'LT_FORCE_UPDATE_MODELS' # uncomment this if you want to force the update of all languages.
#nginx vhosts
# nginx vhosts
nginx_default_vhost: 'libretranslate'
nginx_gen_dh: 'false'
ssl_src_path: '/etc/letsencrypt/live'
@ -54,10 +53,10 @@ nginx_vhosts:
upstream_name: '127.0.0.1'
proto: 'http'
listen: '80'
#ssl_name: 'libretranslate.localhost'
# ssl_name: 'libretranslate.localhost'
secure_site: 'true'
secure_cookie: 'true'
#header_sameorigin: 'true'
# header_sameorigin: 'true'
use_error_log: 'true'
nginx_error_log_level: 'warn'
use_access_log: 'false'

View file

@ -1,6 +1,6 @@
---
- name: restart libretranslate
- name: 'Restart libretranslate'
systemd:
name: libretranslate
state: restarted
name: 'libretranslate'
state: 'restarted'

View file

@ -1,40 +1,41 @@
---
- name: "[INSTALL] - Get version installed"
shell: "{{ libretranslate_venv_path }}/bin/pip show libretranslate | grep Version: | cut -d' ' -f2"
become: yes
- name: '[INSTALL] - Get version installed'
command:
cmd: "{{ libretranslate_venv_path }}/bin/pip show libretranslate | grep Version: | cut -d' ' -f2"
become: true
become_user: '{{ libretranslate_user }}'
register: libretranslate_installed
register: 'libretranslate_installed'
ignore_errors: true # for first install, it doesn't exist...
- name: "[INSTALL] - add sh file"
- name: '[INSTALL] - add sh file'
template:
src: etc/profile.d/libretranslate.sh.j2
dest: "/etc/profile.d/libretranslate.sh"
src: 'etc/profile.d/libretranslate.sh.j2'
dest: '/etc/profile.d/libretranslate.sh'
mode: '0644'
- name: "[INSTALL] - Source the libretranslate.sh"
shell: "source /etc/profile.d/libretranslate.sh"
- name: '[INSTALL] - Source the libretranslate.sh'
shell:
cmd: 'source /etc/profile.d/libretranslate.sh'
args:
executable: /bin/bash
become: yes
executable: '/bin/bash'
become: true
become_user: '{{ libretranslate_user }}'
- name: '[INSTALL] - Create the initial virtualenv, install and update pip and setuptools'
pip:
name: "{{ libretranslate_pip_pkgs }}"
name: '{{ libretranslate_pip_pkgs }}'
virtualenv: '{{ libretranslate_venv_path }}/'
virtualenv_site_packages: yes
state: "latest"
become: yes
virtualenv_site_packages: true
become: true
become_user: '{{ libretranslate_user }}'
- name: '[INSTALL] - Install libretranslate'
pip:
name: libretranslate
name: 'libretranslate'
virtualenv: '{{ libretranslate_venv_path }}'
state: "latest"
become: yes
become: true
become_user: '{{ libretranslate_user }}'
when: libretranslate_installed.stdout != libretranslate_version
notify: restart libretranslate
notify:
- 'Restart libretranslate'

View file

@ -1,6 +1,6 @@
---
- name: '[INSTALLDEP] - Install Dependencies'
apt:
name: "{{ libretranslate_pkg }}"
update_cache: yes
- name: '[INSTALLDEP] - Install Dependencies'
apt:
name: '{{ libretranslate_pkg }}'
update_cache: true

View file

@ -1,14 +1,15 @@
---
- name: Add user
include_tasks: user.yml
- name: '[Main] - Add user'
include_tasks: 'user.yml'
- name: Install dependencies
include_tasks: installdeps.yml
- name: '[Main] - Install dependencies'
include_tasks: 'installdeps.yml'
- name: Install the app
include_tasks: installapp.yml
- name: '[Main] - Install the app'
include_tasks: 'installapp.yml'
- name: Deploy systemd
include_tasks: systemd.yml
tags: systemd
- name: '[Main] - Deploy systemd'
include_tasks: 'systemd.yml'
tags:
- 'systemd'

View file

@ -1,20 +1,22 @@
---
- name: "[SYSTEMD] - Deploy Systemd config"
- name: '[SYSTEMD] - Deploy Systemd config'
template:
src: etc/systemd/system/libretranslate.service.j2
dest: /etc/systemd/system/libretranslate.service
owner: root
group: root
mode: 0644
register: libretranslate
tags: systemd
src: 'etc/systemd/system/libretranslate.service.j2'
dest: '/etc/systemd/system/libretranslate.service'
owner: 'root'
group: 'root'
mode: '0644'
register: 'libretranslate'
tags:
- 'systemd'
- name: "[SYSTEMD] - Enable systemd"
- name: '[SYSTEMD] - Enable systemd'
service:
name: libretranslate
state: restarted
enabled: yes
name: 'libretranslate'
state: 'restarted'
enabled: true
daemon_reload: true
when: libretranslate.changed
tags: systemd
tags:
- 'systemd'

View file

@ -1,14 +1,14 @@
---
- name: "[USER] - Add group"
- name: '[USER] - Add group'
group:
name: '{{ libretranslate_group }}'
state: present
state: 'present'
- name: "[USER] - Add user libretranslate"
- name: '[USER] - Add user libretranslate'
user:
name: '{{ libretranslate_user }}'
shell: /bin/bash
shell: '/bin/bash'
group: '{{ libretranslate_group }}'
- name: '[USER] - Make sure right permissions are set to the user home dir'