diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..d54bee6 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,6 @@ +skip_list: + - fqcn-builtins + - fqcn[action] + - fqcn[action-core] + - fqcn[canonical] + - name[casing] diff --git a/Playbooks/libretranslate.yml b/Playbooks/libretranslate.yml index 70b1014..ceabd7c 100644 --- a/Playbooks/libretranslate.yml +++ b/Playbooks/libretranslate.yml @@ -1,9 +1,10 @@ --- -- hosts: libretranslate +- name: 'Libretranslate playbook' + hosts: 'libretranslate' roles: - - nginx - - libretranslate + - 'nginx' + - 'libretranslate' vars_files: - ../defaults/main.yml diff --git a/defaults/main.yml b/defaults/main.yml index 1a22159..6f119fe 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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' diff --git a/handlers/main.yml b/handlers/main.yml index 17c1716..226e0f9 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,6 +1,6 @@ --- -- name: restart libretranslate +- name: 'Restart libretranslate' systemd: - name: libretranslate - state: restarted + name: 'libretranslate' + state: 'restarted' diff --git a/tasks/installapp.yml b/tasks/installapp.yml index d851e51..88c5836 100644 --- a/tasks/installapp.yml +++ b/tasks/installapp.yml @@ -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' diff --git a/tasks/installdeps.yml b/tasks/installdeps.yml index 4cbc519..376f860 100644 --- a/tasks/installdeps.yml +++ b/tasks/installdeps.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index 777469c..a563951 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 \ No newline at end of file +- name: '[Main] - Deploy systemd' + include_tasks: 'systemd.yml' + tags: + - 'systemd' diff --git a/tasks/systemd.yml b/tasks/systemd.yml index 14349fc..c19da7d 100644 --- a/tasks/systemd.yml +++ b/tasks/systemd.yml @@ -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' diff --git a/tasks/user.yml b/tasks/user.yml index b4c65bb..693c513 100644 --- a/tasks/user.yml +++ b/tasks/user.yml @@ -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'