Compare commits
4 Commits
656de03cc9
...
ed0c1845e1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed0c1845e1 | ||
|
|
d89f21a775 | ||
|
|
e61972fd4b | ||
|
|
dc48543177 |
@@ -1,10 +1,12 @@
|
|||||||
---
|
---
|
||||||
|
description: Roles for installing software on shared hosting servers
|
||||||
namespace: uumas
|
namespace: uumas
|
||||||
name: multihost
|
name: multihost
|
||||||
version: 0.0.1
|
version: 0.0.2
|
||||||
readme: README.md
|
readme: README.md
|
||||||
authors:
|
authors:
|
||||||
- uumas
|
- uumas
|
||||||
license_file: 'LICENSE'
|
license_file: 'LICENSE'
|
||||||
repository: 'https://git.uumas.fi/uumas/ansible-multihost'
|
repository: 'https://git.uumas.fi/uumas/ansible-multihost'
|
||||||
|
tags:
|
||||||
|
- linux
|
||||||
|
|||||||
@@ -1,4 +1,2 @@
|
|||||||
---
|
---
|
||||||
|
requires_ansible: ">=2.17.0"
|
||||||
requires_ansible: ">=2.10"
|
|
||||||
|
|
||||||
|
|||||||
2
roles/composer/defaults/main.yaml
Normal file
2
roles/composer/defaults/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
composer_upgrade: false
|
||||||
10
roles/composer/meta/argument_specs.yaml
Normal file
10
roles/composer/meta/argument_specs.yaml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
argument_specs:
|
||||||
|
main:
|
||||||
|
description: Installs composer if not already installed system-wide
|
||||||
|
options:
|
||||||
|
composer_upgrade:
|
||||||
|
description: Whether to upgrade composer to the latest version if already installed
|
||||||
|
type: bool
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
24
roles/composer/tasks/main.yaml
Normal file
24
roles/composer/tasks/main.yaml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
- name: Test if composer is installed system-wide
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /usr/bin/composer
|
||||||
|
register: _composer_global_executable
|
||||||
|
|
||||||
|
- name: Install composer for user
|
||||||
|
when: not _composer_global_executable.stat.exists
|
||||||
|
block:
|
||||||
|
- name: Check if composer installed
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ ansible_user_dir }}/.local/bin/composer"
|
||||||
|
register: _composer_user_executable
|
||||||
|
|
||||||
|
- name: Download latest version of composer locally
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: https://getcomposer.org/download/latest-stable/composer.phar
|
||||||
|
dest: "{{ ansible_user_dir }}/.local/bin/composer"
|
||||||
|
mode: "0755"
|
||||||
|
when: (not _composer_user_executable.stat.exists) or composer_upgrade
|
||||||
|
|
||||||
|
- name: Set composer path to use local installation
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
composer_path: "{{ ansible_user_dir }}/.local/bin/composer"
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
6
roles/kimai/defaults/main.yaml
Normal file
6
roles/kimai/defaults/main.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
kimai_db_user: "{{ kimai_db }}"
|
||||||
|
kimai_db_host: localhost
|
||||||
|
|
||||||
|
kimai_php_executable: php
|
||||||
|
kimai_upgrade: false
|
||||||
46
roles/kimai/meta/argument_specs.yaml
Normal file
46
roles/kimai/meta/argument_specs.yaml
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
---
|
||||||
|
argument_specs:
|
||||||
|
main:
|
||||||
|
description: Installs kimai if not already installed system-wide
|
||||||
|
options:
|
||||||
|
kimai_installdir:
|
||||||
|
description: Directory to install kimai in
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
kimai_webroot:
|
||||||
|
description: Directory of kimai webroot
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
|
||||||
|
kimai_db:
|
||||||
|
description: Kimai mysql database name
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
kimai_db_user:
|
||||||
|
description: Kimai mysql database user. Defaults to database name.
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
kimai_db_pw:
|
||||||
|
description: Kimai mysql database password
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
kimai_db_host:
|
||||||
|
description: Kimai mysql database host
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
default: localhost
|
||||||
|
kimai_db_server_version:
|
||||||
|
description: Kimai mysql server version. You can check this with `mysql --version`.
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
|
||||||
|
kimai_php_executable:
|
||||||
|
description: Php executable to use for kimai install scripts
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
default: php
|
||||||
|
kimai_upgrade:
|
||||||
|
description: Whether to upgrade kimai to the latest version if already installed
|
||||||
|
type: bool
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
---
|
---
|
||||||
dependencies:
|
dependencies:
|
||||||
- composer
|
- role: composer
|
||||||
|
composer_upgrade: "{{ kimai_upgrade }}"
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Clone kimai git repo
|
- name: Clone kimai git repo
|
||||||
ansible.builtin.git:
|
ansible.builtin.git:
|
||||||
repo: "https://github.com/kevinpapst/kimai2.git"
|
repo: "https://github.com/kevinpapst/kimai2.git"
|
||||||
dest: "{{ kimai_installdir }}"
|
dest: "{{ kimai_installdir }}"
|
||||||
version: main
|
version: main
|
||||||
|
update: "{{ kimai_upgrade }}"
|
||||||
|
|
||||||
- name: Install kimai dependencies using composer
|
- name: Install kimai dependencies using composer
|
||||||
community.general.composer:
|
community.general.composer:
|
||||||
working_dir: "{{ kimai_installdir }}"
|
working_dir: "{{ kimai_installdir }}"
|
||||||
composer_executable: "{{ composer_path | default(omit) }}"
|
composer_executable: "{{ composer_path | default(omit) }}"
|
||||||
executable: "{{ kimai_php_executable | default(omit) }}"
|
executable: "{{ kimai_php_executable }}"
|
||||||
|
|
||||||
- name: Configure kimai database
|
- name: Configure kimai database
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ kimai_installdir }}/.env"
|
path: "{{ kimai_installdir }}/.env"
|
||||||
regexp: "^DATABASE_URL=.*$"
|
regexp: "^DATABASE_URL=.*$"
|
||||||
line: "\
|
line: "\
|
||||||
DATABASE_URL=mysql://{{ kimai_db_user | default(kimai_db) }}:{{ kimai_db_pw }}\
|
DATABASE_URL=mysql://{{ kimai_db_user }}:{{ kimai_db_pw }}\
|
||||||
@{{ kimai_db_host | default('localhost') }}:3306/{{ kimai_db }}\
|
@{{ kimai_db_host | default('localhost') }}:3306/{{ kimai_db }}\
|
||||||
?charset=utf8&serverVersion={{ kimai_db_server }}"
|
?charset=utf8&serverVersion={{ kimai_db_server_version }}"
|
||||||
|
|
||||||
- name: Run kimai install script
|
- name: Run kimai install script
|
||||||
ansible.builtin.command: "{{ kimai_php_executable + ' ' if kimai_php_executable is defined else '' }}bin/console kimai:install -n"
|
ansible.builtin.command: "{{ kimai_php_executable ~ ' ' }}bin/console kimai:install -n"
|
||||||
args:
|
args:
|
||||||
chdir: "{{ kimai_installdir }}"
|
chdir: "{{ kimai_installdir }}"
|
||||||
register: kimai_install
|
register: kimai_install
|
||||||
changed_when: "'[OK] Already at the latest version' not in kimai_install.stdout"
|
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"
|
failed_when: "'[OK] Successfully installed Kimai' not in kimai_install.stdout"
|
||||||
|
|
||||||
- name: Add symlink to kimai public in webroot
|
- name: Add symlink to kimai public in webroot
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user