kimai
This commit is contained in:
21
docs/kimai.md
Normal file
21
docs/kimai.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Required variables
|
||||||
|
These variables are required by multiple roles. Example values included.
|
||||||
|
|
||||||
|
```
|
||||||
|
timezone: 'Europe/Helsinki'
|
||||||
|
admin_email: 'admin@domain.tld'
|
||||||
|
|
||||||
|
smtp_server: smtp.domain.tld
|
||||||
|
smtp_from: sender@domain.tld
|
||||||
|
```
|
||||||
|
|
||||||
|
# Optional variables
|
||||||
|
These variables are used by multiple roles and have the following default values:
|
||||||
|
|
||||||
|
```
|
||||||
|
reverse_proxy_type: caddy # Allowed values: caddy, traefik, none
|
||||||
|
|
||||||
|
smtp_from: # not defined, no smtp login by default
|
||||||
|
smtp_pw: # not defined, see above
|
||||||
|
|
||||||
|
```
|
||||||
20
roles/composer/tasks/main.yml
Normal file
20
roles/composer/tasks/main.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Test if composer is installed system-wide
|
||||||
|
stat:
|
||||||
|
path: /usr/bin/composer
|
||||||
|
register: global_composer
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Download latest version of composer locally
|
||||||
|
get_url:
|
||||||
|
url: https://getcomposer.org/download/latest-stable/composer.phar
|
||||||
|
dest: "{{ ansible_user_dir }}/.local/bin/composer"
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: Set composer path to use local installation
|
||||||
|
set_fact:
|
||||||
|
composer_path: "{{ ansible_user_dir }}/.local/bin/composer"
|
||||||
|
|
||||||
|
when: not global_composer.stat.exists
|
||||||
|
|
||||||
4
roles/kimai/meta/main.yml
Normal file
4
roles/kimai/meta/main.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- composer
|
||||||
55
roles/kimai/tasks/main.yml
Normal file
55
roles/kimai/tasks/main.yml
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Clone kimai git repo
|
||||||
|
git:
|
||||||
|
repo: 'https://github.com/kevinpapst/kimai2.git'
|
||||||
|
dest: "{{ kimai_installdir }}"
|
||||||
|
version: 'master'
|
||||||
|
|
||||||
|
- name: Install kimai dependencies using composer
|
||||||
|
composer:
|
||||||
|
working_dir: "{{ kimai_installdir }}"
|
||||||
|
composer_executable: "{{ composer_path | default(omit) }}"
|
||||||
|
|
||||||
|
- name: Configure kimai database
|
||||||
|
lineinfile:
|
||||||
|
path: "{{ kimai_installdir }}/.env"
|
||||||
|
regexp: "^DATABASE_URL=.*$"
|
||||||
|
line: "DATABASE_URL=mysql://{{ kimai_db_user | default(kimai_db) }}:{{ kimai_db_pw }}@{{ kimai_db_host | default('localhost') }}:3306/{{ kimai_db }}?charset=utf8&serverVersion={{ kimai_db_server }}"
|
||||||
|
|
||||||
|
- name: Run kimai install script
|
||||||
|
command: "bin/console kimai:install -n"
|
||||||
|
args:
|
||||||
|
chdir: "{{ kimai_installdir }}"
|
||||||
|
register: kimai_install
|
||||||
|
changed_when: "'[OK] Already at the latest version' not in kimai_install.stdout"
|
||||||
|
failed_when: "'[OK] Congratulations! Successfully installed Kimai' not in kimai_install.stdout"
|
||||||
|
|
||||||
|
- name: Get webroot stat
|
||||||
|
stat:
|
||||||
|
path: "{{ kimai_webroot }}"
|
||||||
|
register: kimai_webroot_stat
|
||||||
|
|
||||||
|
- name: Delete kimai webroot if it's a directory
|
||||||
|
file:
|
||||||
|
path: "{{ kimai_webroot }}"
|
||||||
|
state: absent
|
||||||
|
when: kimai_webroot_stat.stat.isdir
|
||||||
|
|
||||||
|
- name: Symlink webroot to public
|
||||||
|
file:
|
||||||
|
src: "{{ kimai_installdir }}/public"
|
||||||
|
dest: "{{ kimai_webroot }}"
|
||||||
|
state: link
|
||||||
|
force: yes
|
||||||
|
|
||||||
|
- name: Set https redirect
|
||||||
|
blockinfile:
|
||||||
|
path: "{{ kimai_webroot }}/.htaccess"
|
||||||
|
marker: "# {mark} ANSIBLE MANAGED BLOCK http -> https"
|
||||||
|
block: |
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteCond %{ENV:HTTPS} !on
|
||||||
|
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
|
||||||
|
insertbefore: BOF
|
||||||
|
|
||||||
Reference in New Issue
Block a user