mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Build release archive when version is not avail
Default ansible installation version to "latest" (pulls the latest published release archive).
This commit is contained in:
parent
f95fd4ced2
commit
eca1289ce2
@ -1,5 +1,5 @@
|
||||
---
|
||||
paperlessng_version: 0.9.14
|
||||
paperlessng_version: latest # 'latest', release number, or github branch/tag/commit/ref
|
||||
|
||||
# Required services
|
||||
paperlessng_redis_host: localhost
|
||||
|
6
ansible/tasks/install-release.yml
Normal file
6
ansible/tasks/install-release.yml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: extract paperless-ng
|
||||
unarchive:
|
||||
src: "https://github.com/jonaswinkler/paperless-ng/releases/download/ng-{{ paperlessng_version }}/paperless-ng-{{ paperlessng_version }}.tar.xz"
|
||||
remote_src: yes
|
||||
dest: "{{ tempdir.path }}"
|
133
ansible/tasks/install-source.yml
Normal file
133
ansible/tasks/install-source.yml
Normal file
@ -0,0 +1,133 @@
|
||||
---
|
||||
# https://github.com/jonaswinkler/paperless-ng/blob/dev/.github/workflows/ci.yml
|
||||
- name: install dev dependencies
|
||||
apt:
|
||||
pkg:
|
||||
- git
|
||||
- npm
|
||||
- libqpdf-dev
|
||||
|
||||
- name: create temporary git directory
|
||||
tempfile:
|
||||
state: directory
|
||||
register: gitdir
|
||||
|
||||
- name: pull paperless-ng
|
||||
git:
|
||||
repo: https://github.com/jonaswinkler/paperless-ng.git
|
||||
dest: "{{ gitdir.path }}"
|
||||
version: "{{ paperlessng_version }}"
|
||||
refspec: "+refs/pull/*:refs/pull/*"
|
||||
when: '"No such file or directory" in paperlessng_current_version.stderr or paperlessng_current_version.stdout != paperlessng_version | string'
|
||||
|
||||
- name: compile frontend
|
||||
command:
|
||||
cmd: "{{ item }}"
|
||||
args:
|
||||
chdir: "{{ gitdir.path }}/src-ui"
|
||||
failed_when: false
|
||||
with_items:
|
||||
- npm install -g @angular/cli
|
||||
- npm install
|
||||
- ./node_modules/.bin/ng build --prod
|
||||
|
||||
- name: install pipenv
|
||||
pip:
|
||||
name:
|
||||
- pipenv
|
||||
- pybind11 # building pikepdf for <0.9.14
|
||||
extra_args: --upgrade
|
||||
|
||||
- name: allow building with any Python 3 release
|
||||
lineinfile:
|
||||
path: "{{ gitdir.path }}/Pipfile"
|
||||
regexp: '^python_version = ".+"$'
|
||||
line: python_version = "3"
|
||||
|
||||
# TODO run dev in separate virtualenv
|
||||
- name: install Pipfile dependencies
|
||||
command:
|
||||
cmd: pipenv install --dev
|
||||
args:
|
||||
chdir: "{{ gitdir.path }}"
|
||||
|
||||
- name: clean output directory
|
||||
file:
|
||||
path: "{{ gitdir.path }}/dist"
|
||||
state: absent
|
||||
|
||||
- name: create output directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
with_items:
|
||||
- "{{ gitdir.path }}/dist"
|
||||
- "{{ gitdir.path }}/dist/paperless-ng"
|
||||
- "{{ gitdir.path }}/dist/paperless-ng/scripts"
|
||||
|
||||
- name: copy application into place
|
||||
copy:
|
||||
src: "{{ gitdir.path }}/{{ item.src }}"
|
||||
remote_src: yes
|
||||
dest: "{{ gitdir.path }}/dist/paperless-ng/{{ item.dest | default('') }}"
|
||||
with_items:
|
||||
- src: CONTRIBUTING.md
|
||||
- src: LICENSE
|
||||
- src: Pipfile
|
||||
- src: Pipfile.lock
|
||||
- src: README.md
|
||||
- src: paperless.conf.example
|
||||
dest: "paperless.conf"
|
||||
|
||||
# TODO can be copied for >=0.9.14
|
||||
- name: generate requirements.txt
|
||||
command:
|
||||
cmd: pipenv lock --keep-outdated -r
|
||||
args:
|
||||
chdir: "{{ gitdir.path }}"
|
||||
register: requirements
|
||||
|
||||
- name: write requirements.txt
|
||||
copy:
|
||||
content: "{{ requirements.stdout }}"
|
||||
dest: "{{ gitdir.path }}/dist/paperless-ng/requirements.txt"
|
||||
|
||||
- name: glob all scripts
|
||||
find:
|
||||
paths: "{{ gitdir.path }}/scripts/"
|
||||
patterns:
|
||||
- "*.service"
|
||||
- "*.sh"
|
||||
register: glob
|
||||
|
||||
- name: copy scripts
|
||||
copy:
|
||||
src: "{{ item.path }}"
|
||||
remote_src: yes
|
||||
dest: "{{ gitdir.path }}/dist/paperless-ng/scripts/"
|
||||
with_items:
|
||||
- "{{ glob.files }}"
|
||||
|
||||
- name: copy sources
|
||||
command:
|
||||
cmd: "cp -r src/ dist/paperless-ng/src"
|
||||
args:
|
||||
chdir: "{{ gitdir.path }}"
|
||||
|
||||
- name: package app
|
||||
archive:
|
||||
path: "{{ gitdir.path }}/dist/"
|
||||
dest: "{{ gitdir.path }}/paperless-ng-{{ paperlessng_version }}.tar.xz"
|
||||
format: xz
|
||||
|
||||
- name: extract paperless-ng
|
||||
unarchive:
|
||||
src: "{{ gitdir.path }}/paperless-ng-{{ paperlessng_version }}.tar.xz"
|
||||
remote_src: yes
|
||||
dest: "{{ tempdir.path }}"
|
||||
when: '"No such file or directory" in paperlessng_current_version.stderr or paperlessng_current_version.stdout != paperlessng_version | string'
|
||||
|
||||
- name: remove temporary git directory
|
||||
file:
|
||||
path: "{{ gitdir.path }}"
|
||||
state: absent
|
@ -34,7 +34,13 @@
|
||||
- build-essential
|
||||
- python3-setuptools
|
||||
- python3-wheel
|
||||
- python3-virtualenv
|
||||
|
||||
# upstream virtualenv in Ubuntu 20.04 is broken
|
||||
# https://github.com/pypa/virtualenv/issues/1873
|
||||
- name: install python virtualenv
|
||||
pip:
|
||||
name: virtualenv
|
||||
extra_args: --upgrade
|
||||
|
||||
- name: install ocr languages
|
||||
apt:
|
||||
@ -97,6 +103,18 @@
|
||||
# GNUPG_HOME required due to paperless db.py
|
||||
create_home: yes
|
||||
|
||||
- block:
|
||||
- name: get latest release version
|
||||
uri:
|
||||
url: https://api.github.com/repos/jonaswinkler/paperless-ng/releases/latest
|
||||
method: GET
|
||||
register: latest_release
|
||||
- name: parse latest release version
|
||||
set_fact:
|
||||
paperlessng_version: "{{ latest_release.json['tag_name'] | regex_replace('^ng-(.+)$', '\\1') }}"
|
||||
when: paperlessng_version == "latest"
|
||||
|
||||
# TODO store commit hash of installed version, use instead of version number
|
||||
- name: check for paperless-ng installation
|
||||
command:
|
||||
cmd: 'grep -Po "(?<=Paperless-ng )\d+\.\d+\.\d+" {{ paperlessng_directory }}/docs/changelog.html'
|
||||
@ -109,59 +127,58 @@
|
||||
set_fact:
|
||||
fresh_installation: '{{ "No such file or directory" in paperlessng_current_version.stderr }}'
|
||||
update_installation: '{{ "No such file or directory" not in paperlessng_current_version.stderr and paperlessng_current_version.stdout != paperlessng_version | string }}'
|
||||
reconfigure_only: '{{ paperlessng_current_version.stdout == paperlessng_version | string }}'
|
||||
reconfigure_only: "{{ paperlessng_current_version.stdout == paperlessng_version | string }}"
|
||||
|
||||
- name: backup current paperless-ng installation
|
||||
copy:
|
||||
src: "{{ paperlessng_directory }}"
|
||||
remote_src: yes
|
||||
dest: "{{ paperlessng_directory }}-{{ ansible_date_time.iso8601 }}/"
|
||||
- block:
|
||||
- name: backup current paperless-ng installation
|
||||
copy:
|
||||
src: "{{ paperlessng_directory }}"
|
||||
remote_src: yes
|
||||
dest: "{{ paperlessng_directory }}-{{ ansible_date_time.iso8601 }}/"
|
||||
- name: remove current paperless sources
|
||||
file:
|
||||
path: "{{ paperlessng_directory }}/{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- docker
|
||||
- docs
|
||||
- scripts
|
||||
- src
|
||||
- static
|
||||
when: update_installation
|
||||
|
||||
- name: remove current paperless sources
|
||||
file:
|
||||
path: "{{ paperlessng_directory }}/{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- docker
|
||||
- docs
|
||||
- scripts
|
||||
- src
|
||||
- static
|
||||
when: update_installation
|
||||
|
||||
- name: create temporary directory
|
||||
tempfile:
|
||||
state: directory
|
||||
register: tempdir
|
||||
when: not reconfigure_only
|
||||
|
||||
- name: extract paperless-ng
|
||||
unarchive:
|
||||
src: "https://github.com/jonaswinkler/paperless-ng/releases/download/ng-{{ paperlessng_version }}/paperless-ng-{{ paperlessng_version }}.tar.xz"
|
||||
remote_src: yes
|
||||
dest: "{{ tempdir.path }}"
|
||||
when: not reconfigure_only
|
||||
|
||||
- name: change owner and permissions of paperless-ng
|
||||
command:
|
||||
cmd: "{{ item }}"
|
||||
warn: false
|
||||
with_items:
|
||||
- "chown -R {{ paperlessng_system_user }}:{{ paperlessng_system_group }} {{ tempdir.path }}"
|
||||
- "find {{ tempdir.path }} -type d -exec chmod 0750 {} ;"
|
||||
- "find {{ tempdir.path }} -type f -exec chmod 0640 {} ;"
|
||||
when: not reconfigure_only
|
||||
|
||||
- name: move paperless-ng
|
||||
command:
|
||||
cmd: "cp -a {{ tempdir.path }}/paperless-ng/. {{ paperlessng_directory }}"
|
||||
when: not reconfigure_only
|
||||
|
||||
- name: remove temporary directory
|
||||
file:
|
||||
path: "{{ tempdir.path }}"
|
||||
state: absent
|
||||
- block:
|
||||
- name: create temporary directory
|
||||
tempfile:
|
||||
state: directory
|
||||
register: tempdir
|
||||
- name: check if version is available as release archive
|
||||
uri:
|
||||
url: "https://github.com/jonaswinkler/paperless-ng/releases/download/ng-{{ paperlessng_version }}/paperless-ng-{{ paperlessng_version }}.tar.xz"
|
||||
method: GET
|
||||
status_code: [200, 302, 404]
|
||||
register: release_archive
|
||||
- name: install paperless-ng from source
|
||||
include_tasks: install-source.yml
|
||||
when: release_archive.status == 404
|
||||
- name: install paperless-ng from release archive
|
||||
include_tasks: install-release.yml
|
||||
when: release_archive.status != 404
|
||||
- name: change owner and permissions of paperless-ng
|
||||
command:
|
||||
cmd: "{{ item }}"
|
||||
warn: false
|
||||
with_items:
|
||||
- "chown -R {{ paperlessng_system_user }}:{{ paperlessng_system_group }} {{ tempdir.path }}"
|
||||
- "find {{ tempdir.path }} -type d -exec chmod 0750 {} ;"
|
||||
- "find {{ tempdir.path }} -type f -exec chmod 0640 {} ;"
|
||||
- name: move paperless-ng
|
||||
command:
|
||||
cmd: "cp -a {{ tempdir.path }}/paperless-ng/. {{ paperlessng_directory }}"
|
||||
- name: remove temporary directory
|
||||
file:
|
||||
path: "{{ tempdir.path }}"
|
||||
state: absent
|
||||
when: not reconfigure_only
|
||||
|
||||
- name: create paperless-ng directories and set permissions
|
||||
@ -310,21 +327,20 @@
|
||||
creates: "{{ paperlessng_virtualenv }}"
|
||||
register: venv
|
||||
|
||||
- name: install paperlessng requirements
|
||||
become: yes
|
||||
become_user: "{{ paperlessng_system_user }}"
|
||||
pip:
|
||||
requirements: "{{ paperlessng_directory }}/requirements.txt"
|
||||
executable: "{{ paperlessng_virtualenv }}/bin/pip3"
|
||||
extra_args: --upgrade
|
||||
when: not reconfigure_only
|
||||
|
||||
- name: migrate database schema
|
||||
become: yes
|
||||
become_user: "{{ paperlessng_system_user }}"
|
||||
command: "{{ paperlessng_virtualenv }}/bin/python3 {{ paperlessng_directory }}/src/manage.py migrate"
|
||||
register: database_schema
|
||||
changed_when: '"No migrations to apply." not in database_schema.stdout'
|
||||
- block:
|
||||
- name: install paperlessng requirements
|
||||
become: yes
|
||||
become_user: "{{ paperlessng_system_user }}"
|
||||
pip:
|
||||
requirements: "{{ paperlessng_directory }}/requirements.txt"
|
||||
executable: "{{ paperlessng_virtualenv }}/bin/pip3"
|
||||
extra_args: --upgrade
|
||||
- name: migrate database schema
|
||||
become: yes
|
||||
become_user: "{{ paperlessng_system_user }}"
|
||||
command: "{{ paperlessng_virtualenv }}/bin/python3 {{ paperlessng_directory }}/src/manage.py migrate"
|
||||
register: database_schema
|
||||
changed_when: '"No migrations to apply." not in database_schema.stdout'
|
||||
when: not reconfigure_only
|
||||
|
||||
- name: configure paperless superuser
|
||||
|
Loading…
x
Reference in New Issue
Block a user