Merge pull request 'Better installation and update' (#2) from update2 into master

Reviewed-on: #2
Reviewed-by: antilopa <antilopa@no-reply@disroot.org>
Reviewed-by: muppeth <muppeth@no-reply@disroot.org>
This commit is contained in:
meaz 2021-04-13 06:44:14 +00:00
commit 3dd39726eb
6 changed files with 43 additions and 16 deletions

11
tasks/check.yml Normal file
View File

@ -0,0 +1,11 @@
---
- name: "[Check] - Check what cryptpad version is already installed"
shell:
cmd: awk '/cryptpad/{getline; print $2}' {{ cryptpad_path }}/package-lock.json | awk -F\" '{print $2}'
register: cryptpad_version_installed
- name: "[Check] - Bower folder exists"
stat:
path: "{{ cryptpad_path }}/www/bower_components"
register: bower_folder

View File

@ -1,10 +1,5 @@
---
- name: "[Version] - Check what cryptpad version is already installed"
shell:
cmd: awk '/cryptpad/{getline; print $2}' {{ cryptpad_path }}/package-lock.json | awk -F\" '{print $2}'
register: cryptpad_version_installed
- name: '[GIT] - Clone git repo'
git:
repo: https://github.com/xwiki-labs/cryptpad.git
@ -13,3 +8,7 @@
version: "{{ cryptpad_version}}"
become: yes
become_user: "{{ cryptpad_user }}"
register: result
retries: 3
delay: 15
until: result is not failed

View File

@ -1,11 +1,15 @@
---
- name: "[Install] - Cryptpad via npm"
npm:
path: "{{ cryptpad_path }}"
become_user: "{{ cryptpad_user }}"
- name: "[Install] - Cryptpad dependencies via bower"
bower:
path: "{{ cryptpad_path }}"
- name: "[Install] - Cryptpad via npm"
command: npm install
args:
chdir: "{{ cryptpad_path }}"
become_user: "{{ cryptpad_user }}"
register: result
retries: 3
delay: 15
until: result is not failed

View File

@ -20,3 +20,4 @@
npm:
name: bower
global: yes
state: latest

View File

@ -1,5 +1,8 @@
---
- name: Check version installed
include: check.yml
- name: Create user
include: user.yml
@ -11,6 +14,7 @@
- name: Install cryptpad
include: install.yml
when: not bower_folder.stat.exists
- name: Deploy config
include: config.yml
@ -20,3 +24,4 @@
- name: Update cryptpad
include: update.yml
when: (cryptpad_version not in cryptpad_version_installed.stdout) and (bower_folder.stat.exists)

View File

@ -4,12 +4,19 @@
service:
name: cryptpad
state: stopped
when: cryptpad_version not in cryptpad_version_installed.stdout
- name: "[Update] - npm"
npm:
name: npm
global: yes
state: latest
- name: "[Update] - bower"
command: bower update
args:
chdir: "{{ cryptpad_path }}"
become_user: "{{ cryptpad_user }}"
when: cryptpad_version not in cryptpad_version_installed.stdout
bower:
state: latest
path: "{{ cryptpad_path }}"
register: result
retries: 3
delay: 15
until: result is not failed
notify: restart cryptpad