Created role docker-compose and refactored attendize, akauntin, openproject

This commit is contained in:
Kevin Veen-Birkenbach 2023-12-30 15:22:18 +01:00
parent 3581db27aa
commit 8e5487bf8f
18 changed files with 122 additions and 146 deletions

View File

@ -18,6 +18,8 @@ This guide details the process of setting up Akaunting, a free and online accoun
## Installation Steps ## Installation Steps
@ATTENTION Variable ```#AKAUNTING_SETUP: true``` needs to be set
### New Manual Setup ### New Manual Setup
1. **Navigate to Docker Compose Directory**: Change to the directory containing your Docker Compose files for Akaunting. 1. **Navigate to Docker Compose Directory**: Change to the directory containing your Docker Compose files for Akaunting.

View File

@ -1,2 +1,2 @@
dependencies: dependencies:
- nginx-docker-reverse-proxy - docker-compose

View File

@ -2,43 +2,13 @@
- name: "include tasks nginx-docker-proxy-domain.yml" - name: "include tasks nginx-docker-proxy-domain.yml"
include_tasks: nginx-docker-proxy-domain.yml include_tasks: nginx-docker-proxy-domain.yml
- name: register directory - name: "include tasks update-repository-with-docker-compose.yml"
stat: include_tasks: update-repository-with-docker-compose.yml
path: "{{docker_compose_instance_directory}}"
register: docker_compose_instance_directory_register
- name: checkout repository
ansible.builtin.shell: git checkout .
become: true
args:
chdir: "{{docker_compose_instance_directory}}"
when: docker_compose_instance_directory_register.stat.exists
- name: pull docker repository
git:
repo: "https://github.com/akaunting/docker.git"
dest: "{{docker_compose_instance_directory}}"
update: yes
notify: setup akaunting
become: true
register: git_result
ignore_errors: true
- name: Warn if repo is not reachable
debug:
msg: "Warning: Repository is not reachable."
when: git_result.failed
- name: set akaunting version
ansible.builtin.shell: find . -type f -exec sed -i 's/akaunting:latest/akaunting:{{version_akaunting}}/' {} + && find . -type f -exec sed -i 's/version=latest/version={{version_akaunting}}/' {} +
become: true
args:
chdir: "{{docker_compose_instance_directory}}"
- name: configure db.env - name: configure db.env
template: src=db.env.j2 dest={{docker_compose_instance_directory}}/env/db.env template: src=db.env.j2 dest={{docker_compose_instance_directory}}/env/db.env
notify: setup akaunting notify: docker compose project setup
- name: configure run.env - name: configure run.env
template: src=run.env.j2 dest={{docker_compose_instance_directory}}/env/run.env template: src=run.env.j2 dest={{docker_compose_instance_directory}}/env/run.env
notify: setup akaunting notify: docker compose project setup

View File

@ -0,0 +1,24 @@
version: '3.7'
services:
application:
image: docker.io/akaunting/akaunting:{{version_akaunting}}
build:
context: .
ports:
- 127.0.0.1:{{http_port}}:80
volumes:
- data:/var/www/html
restart: unless-stopped
env_file:
- env/run.env
environment:
- AKAUNTING_SETUP
depends_on:
- database
{% include 'templates/docker-mariadb-service.yml.j2' %}
volumes:
data:
database:

View File

@ -1,6 +1,10 @@
docker_compose_instance_directory: "{{path_docker_compose_instances}}akaunting/" docker_compose_project_name: "akaunting"
database_instance: "akaunting" docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/"
database_host: "akaunting-db" docker_compose_file_path: "{{docker_compose_instance_directory}}docker-compose.yml"
database_databasename: "{{database_instance}}" docker_compose_backup_path: "/tmp/{{docker_compose_project_name}}-docker-compose-backup.yml"
database_username: "admin" database_instance: "{{docker_compose_project_name}}"
database_password: "{{akaunting_database_password}}" database_host: "database"
database_databasename: "{{database_instance}}"
database_username: "admin"
database_password: "{{akaunting_database_password}}"
repository_address: "https://github.com/akaunting/docker.git"

View File

@ -1,4 +1,6 @@
# Role: docker-attendize @TODO @ATTENTION THIS ROLE IS WORK IN PROGRESS
# Role: docker-attendize (WIP)
This Ansible role sets up Attendize, an open-source ticket selling and event management platform. This Ansible role sets up Attendize, an open-source ticket selling and event management platform.

View File

@ -1,2 +1,2 @@
dependencies: dependencies:
- nginx-docker-reverse-proxy - docker-compose

View File

@ -20,32 +20,5 @@
# domain: "{{ mail_interface_domain }}" # domain: "{{ mail_interface_domain }}"
# notify: restart nginx # notify: restart nginx
- name: register directory - name: "include tasks update-repository-with-docker-compose.yml"
stat: include_tasks: update-repository-with-docker-compose.yml
path: "{{docker_compose_instance_directory}}"
register: docker_compose_instance_directory_register
- name: checkout repository
ansible.builtin.shell: git checkout .
become: true
args:
chdir: "{{docker_compose_instance_directory}}"
when: docker_compose_instance_directory_register.stat.exists
- name: checkout Attendize repository
ansible.builtin.git:
repo: "https://github.com/Attendize/Attendize.git"
dest: "{{docker_compose_instance_directory}}"
version: master
become: true
- name: Warn if repo is not reachable
debug:
msg: "Warning: Repository is not reachable."
when: git_result.failed
- name: create docker-compose.yml file from template
template:
src: docker-compose.yml.j2
dest: "{{docker_compose_instance_directory}}/docker-compose.yml"
mode: 0644

View File

@ -1,8 +1,12 @@
--- ---
docker_compose_project_name: "attendize"
docker_compose_instance_directory: "{{path_docker_compose_instances}}attendize/" docker_compose_instance_directory: "{{path_docker_compose_instances}}attendize/"
docker_compose_file_path: "{{docker_compose_instance_directory}}docker-compose.yml"
docker_compose_backup_path: "/tmp/attendize-docker-compose-backup.yml"
mail_interface_domain: "mail.{{domain}}" mail_interface_domain: "mail.{{domain}}"
database_instance: "attendize" database_instance: "{{docker_compose_project_name}}"
database_host: "database" database_host: "database"
database_databasename: "{{database_instance}}" database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}" database_username: "{{database_instance}}"
database_password: "{{attendize_database_password}}" database_password: "{{attendize_database_password}}"
repository_address: "https://github.com/Attendize/Attendize.git"

View File

@ -1,9 +1,8 @@
--- ---
- name: setup akaunting - name: docker compose project setup
command: command:
cmd: docker-compose -p akaunting up -d --force-recreate cmd: docker-compose -p "{{docker_compose_project_name}}" up -d --force-recreate
chdir: "{{docker_compose_instance_directory}}" chdir: "{{docker_compose_instance_directory}}"
environment: environment:
#AKAUNTING_SETUP: true
COMPOSE_HTTP_TIMEOUT: 600 COMPOSE_HTTP_TIMEOUT: 600
DOCKER_CLIENT_TIMEOUT: 600 DOCKER_CLIENT_TIMEOUT: 600

View File

@ -0,0 +1,2 @@
dependencies:
- nginx-docker-reverse-proxy

View File

@ -1,8 +0,0 @@
---
- name: recreate openproject
command:
cmd: docker-compose -p openproject up -d --force-recreate
chdir: "{{ docker_compose_instance_directory }}"
environment:
COMPOSE_HTTP_TIMEOUT: 600
DOCKER_CLIENT_TIMEOUT: 600

View File

@ -1,2 +1,2 @@
dependencies: dependencies:
- nginx-docker-reverse-proxy - docker-compose

View File

@ -2,54 +2,11 @@
- name: "include tasks nginx-docker-proxy-domain.yml" - name: "include tasks nginx-docker-proxy-domain.yml"
include_tasks: nginx-docker-proxy-domain.yml include_tasks: nginx-docker-proxy-domain.yml
- name: "backup docker-compose.yml if it exists" - name: "include tasks update-repository-with-docker-compose.yml"
command: > include_tasks: update-repository-with-docker-compose.yml
mv "{{ docker_compose_file_path }}" "{{ docker_compose_backup_path }}"
args:
removes: "{{ docker_compose_file_path }}"
become: true
- name: register directory
stat:
path: "{{docker_compose_instance_directory}}"
register: docker_compose_instance_directory_register
- name: checkout repository
ansible.builtin.shell: git checkout .
become: true
args:
chdir: "{{docker_compose_instance_directory}}"
when: docker_compose_instance_directory_register.stat.exists
- name: pull docker repository
git:
repo: "https://github.com/opf/openproject-deploy"
dest: "{{ repository_directory }}"
update: yes
notify: recreate openproject
become: true
register: git_result
- name: "restore docker-compose.yml from backup"
command: >
mv "{{ docker_compose_backup_path }}" "{{ docker_compose_file_path }}"
args:
removes: "{{ docker_compose_backup_path }}"
become: true
- name: Warn if repo is not reachable
debug:
msg: "Warning: Repository is not reachable."
when: git_result.failed
- name: "copy .env" - name: "copy .env"
template: template:
src: env.j2 src: env.j2
dest: "{{ docker_compose_instance_directory }}.env" dest: "{{ docker_compose_instance_directory }}.env"
notify: recreate openproject notify: docker compose project setup
- name: "copy docker-compose.yml"
template:
src: docker-compose.yml.j2
dest: "{{ docker_compose_file_path }}"
notify: recreate openproject

View File

@ -21,7 +21,7 @@ x-op-app: &app
RAILS_CACHE_STORE: "memcache" RAILS_CACHE_STORE: "memcache"
OPENPROJECT_CACHE__MEMCACHE__SERVER: "cache:11211" OPENPROJECT_CACHE__MEMCACHE__SERVER: "cache:11211"
OPENPROJECT_RAILS__RELATIVE__URL__ROOT: "${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}" OPENPROJECT_RAILS__RELATIVE__URL__ROOT: "${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}"
DATABASE_URL: "${DATABASE_URL:-postgres://postgres:p4ssw0rd@db/openproject?pool=20&encoding=unicode&reconnect=true}" DATABASE_URL: "${DATABASE_URL}"
RAILS_MIN_THREADS: ${RAILS_MIN_THREADS:-4} RAILS_MIN_THREADS: ${RAILS_MIN_THREADS:-4}
RAILS_MAX_THREADS: ${RAILS_MAX_THREADS:-16} RAILS_MAX_THREADS: ${RAILS_MAX_THREADS:-16}
# set to true to enable the email receiving feature. See ./docker/cron for more options # set to true to enable the email receiving feature. See ./docker/cron for more options
@ -31,7 +31,7 @@ x-op-app: &app
- "${PGDATA}:/var/openproject/pgdata" - "${PGDATA}:/var/openproject/pgdata"
services: services:
db: database:
image: postgres:13 image: postgres:13
<<: *restart_policy <<: *restart_policy
stop_grace_period: "3s" stop_grace_period: "3s"
@ -72,7 +72,7 @@ services:
- frontend - frontend
- backend - backend
depends_on: depends_on:
- db - database
- cache - cache
- seeder - seeder
labels: labels:
@ -99,7 +99,7 @@ services:
networks: networks:
- backend - backend
depends_on: depends_on:
- db - database
- cache - cache
- seeder - seeder
@ -109,7 +109,7 @@ services:
networks: networks:
- backend - backend
depends_on: depends_on:
- db - database
- cache - cache
- seeder - seeder

View File

@ -1,9 +1,11 @@
repository_directory: "{{ path_docker_compose_instances }}openproject/" docker_compose_project_name: "openproject"
docker_compose_instance_directory: "{{repository_directory}}compose/" repository_directory: "{{ path_docker_compose_instances }}{{docker_compose_project_name}}/"
docker_compose_file_path: "{{docker_compose_instance_directory}}docker-compose.yml" docker_compose_instance_directory: "{{repository_directory}}compose/"
docker_compose_backup_path: "/tmp/openproject-docker-compose-backup.yml" docker_compose_file_path: "{{docker_compose_instance_directory}}docker-compose.yml"
database_instance: "openproject" docker_compose_backup_path: "/tmp/{{docker_compose_project_name}}-docker-compose-backup.yml"
database_host: "db" database_instance: "{{docker_compose_project_name}}"
database_databasename: "{{database_instance}}" database_host: "database"
database_username: "postgres" database_databasename: "{{database_instance}}"
database_password: "{{openproject_database_password}}" database_username: "postgres"
database_password: "{{openproject_database_password}}"
repository_address: "https://github.com/opf/openproject-deploy"

View File

@ -246,7 +246,7 @@
- role: docker-akaunting - role: docker-akaunting
vars: vars:
domain: "{{domain_akaunting}}" domain: "{{domain_akaunting}}"
http_port: 8080 http_port: 8025
# Native Webserver Roles # Native Webserver Roles
- name: setup nginx-homepages - name: setup nginx-homepages

View File

@ -0,0 +1,45 @@
- name: "backup docker-compose.yml if it exists"
command: >
mv "{{ docker_compose_file_path }}" "{{ docker_compose_backup_path }}"
args:
removes: "{{ docker_compose_file_path }}"
become: true
- name: register directory
stat:
path: "{{docker_compose_instance_directory}}"
register: docker_compose_instance_directory_register
- name: checkout repository
ansible.builtin.shell: git checkout .
become: true
args:
chdir: "{{docker_compose_instance_directory}}"
when: docker_compose_instance_directory_register.stat.exists
- name: pull docker repository
git:
repo: "{{ repository_address }}"
dest: "{{ repository_directory }}"
update: yes
notify: docker compose project setup
become: true
register: git_result
- name: "restore docker-compose.yml from backup"
command: >
mv "{{ docker_compose_backup_path }}" "{{ docker_compose_file_path }}"
args:
removes: "{{ docker_compose_backup_path }}"
become: true
- name: Warn if repo is not reachable
debug:
msg: "Warning: Repository is not reachable."
when: git_result.failed
- name: "copy docker-compose.yml"
template:
src: docker-compose.yml.j2
dest: "{{ docker_compose_file_path }}"
notify: docker compose project setup