diff --git a/roles/docker-akaunting/README.md b/roles/docker-akaunting/README.md index 32bd0ae0..0946f5b2 100644 --- a/roles/docker-akaunting/README.md +++ b/roles/docker-akaunting/README.md @@ -18,6 +18,8 @@ This guide details the process of setting up Akaunting, a free and online accoun ## Installation Steps +@ATTENTION Variable ```#AKAUNTING_SETUP: true``` needs to be set + ### New Manual Setup 1. **Navigate to Docker Compose Directory**: Change to the directory containing your Docker Compose files for Akaunting. diff --git a/roles/docker-akaunting/meta/main.yml b/roles/docker-akaunting/meta/main.yml index d3606e63..ec2a6059 100644 --- a/roles/docker-akaunting/meta/main.yml +++ b/roles/docker-akaunting/meta/main.yml @@ -1,2 +1,2 @@ dependencies: -- nginx-docker-reverse-proxy +- docker-compose \ No newline at end of file diff --git a/roles/docker-akaunting/tasks/main.yml b/roles/docker-akaunting/tasks/main.yml index 5e6ecc0a..d5f921e3 100644 --- a/roles/docker-akaunting/tasks/main.yml +++ b/roles/docker-akaunting/tasks/main.yml @@ -2,43 +2,13 @@ - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- 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/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: "include tasks update-repository-with-docker-compose.yml" + include_tasks: update-repository-with-docker-compose.yml - name: configure 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 template: src=run.env.j2 dest={{docker_compose_instance_directory}}/env/run.env - notify: setup akaunting + notify: docker compose project setup diff --git a/roles/docker-akaunting/templates/docker-compose.yml.j2 b/roles/docker-akaunting/templates/docker-compose.yml.j2 new file mode 100644 index 00000000..3a5cfce1 --- /dev/null +++ b/roles/docker-akaunting/templates/docker-compose.yml.j2 @@ -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: \ No newline at end of file diff --git a/roles/docker-akaunting/vars/main.yml b/roles/docker-akaunting/vars/main.yml index d9e15d6d..f744b439 100644 --- a/roles/docker-akaunting/vars/main.yml +++ b/roles/docker-akaunting/vars/main.yml @@ -1,6 +1,10 @@ -docker_compose_instance_directory: "{{path_docker_compose_instances}}akaunting/" -database_instance: "akaunting" -database_host: "akaunting-db" -database_databasename: "{{database_instance}}" -database_username: "admin" -database_password: "{{akaunting_database_password}}" +docker_compose_project_name: "akaunting" +docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" +docker_compose_file_path: "{{docker_compose_instance_directory}}docker-compose.yml" +docker_compose_backup_path: "/tmp/{{docker_compose_project_name}}-docker-compose-backup.yml" +database_instance: "{{docker_compose_project_name}}" +database_host: "database" +database_databasename: "{{database_instance}}" +database_username: "admin" +database_password: "{{akaunting_database_password}}" +repository_address: "https://github.com/akaunting/docker.git" diff --git a/roles/docker-attendize/README.md b/roles/docker-attendize/README.md index 5a887b40..b3578060 100644 --- a/roles/docker-attendize/README.md +++ b/roles/docker-attendize/README.md @@ -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. diff --git a/roles/docker-attendize/meta/main.yml b/roles/docker-attendize/meta/main.yml index d3606e63..ec2a6059 100644 --- a/roles/docker-attendize/meta/main.yml +++ b/roles/docker-attendize/meta/main.yml @@ -1,2 +1,2 @@ dependencies: -- nginx-docker-reverse-proxy +- docker-compose \ No newline at end of file diff --git a/roles/docker-attendize/tasks/main.yml b/roles/docker-attendize/tasks/main.yml index 96d8c432..ab7bacc1 100644 --- a/roles/docker-attendize/tasks/main.yml +++ b/roles/docker-attendize/tasks/main.yml @@ -20,32 +20,5 @@ # domain: "{{ mail_interface_domain }}" # notify: restart nginx -- 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: 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 \ No newline at end of file +- name: "include tasks update-repository-with-docker-compose.yml" + include_tasks: update-repository-with-docker-compose.yml \ No newline at end of file diff --git a/roles/docker-attendize/vars/main.yml b/roles/docker-attendize/vars/main.yml index 44ce6b96..778c8f28 100644 --- a/roles/docker-attendize/vars/main.yml +++ b/roles/docker-attendize/vars/main.yml @@ -1,8 +1,12 @@ --- +docker_compose_project_name: "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}}" -database_instance: "attendize" +database_instance: "{{docker_compose_project_name}}" database_host: "database" database_databasename: "{{database_instance}}" database_username: "{{database_instance}}" database_password: "{{attendize_database_password}}" +repository_address: "https://github.com/Attendize/Attendize.git" \ No newline at end of file diff --git a/roles/docker-akaunting/handlers/main.yml b/roles/docker-compose/handlers/main.yml similarity index 53% rename from roles/docker-akaunting/handlers/main.yml rename to roles/docker-compose/handlers/main.yml index 60c283cd..db613935 100644 --- a/roles/docker-akaunting/handlers/main.yml +++ b/roles/docker-compose/handlers/main.yml @@ -1,9 +1,8 @@ --- -- name: setup akaunting +- name: docker compose project setup 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}}" environment: - #AKAUNTING_SETUP: true COMPOSE_HTTP_TIMEOUT: 600 DOCKER_CLIENT_TIMEOUT: 600 diff --git a/roles/docker-compose/meta/main.yml b/roles/docker-compose/meta/main.yml new file mode 100644 index 00000000..d3606e63 --- /dev/null +++ b/roles/docker-compose/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: +- nginx-docker-reverse-proxy diff --git a/roles/docker-openproject/handlers/main.yml b/roles/docker-openproject/handlers/main.yml deleted file mode 100644 index fceb7999..00000000 --- a/roles/docker-openproject/handlers/main.yml +++ /dev/null @@ -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 diff --git a/roles/docker-openproject/meta/main.yml b/roles/docker-openproject/meta/main.yml index d3606e63..ec2a6059 100644 --- a/roles/docker-openproject/meta/main.yml +++ b/roles/docker-openproject/meta/main.yml @@ -1,2 +1,2 @@ dependencies: -- nginx-docker-reverse-proxy +- docker-compose \ No newline at end of file diff --git a/roles/docker-openproject/tasks/main.yml b/roles/docker-openproject/tasks/main.yml index 06474f4f..0f4713ea 100644 --- a/roles/docker-openproject/tasks/main.yml +++ b/roles/docker-openproject/tasks/main.yml @@ -2,54 +2,11 @@ - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- 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: "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: "include tasks update-repository-with-docker-compose.yml" + include_tasks: update-repository-with-docker-compose.yml - name: "copy .env" template: src: env.j2 dest: "{{ docker_compose_instance_directory }}.env" - notify: recreate openproject - -- name: "copy docker-compose.yml" - template: - src: docker-compose.yml.j2 - dest: "{{ docker_compose_file_path }}" - notify: recreate openproject + notify: docker compose project setup diff --git a/roles/docker-openproject/templates/docker-compose.yml.j2 b/roles/docker-openproject/templates/docker-compose.yml.j2 index 18339d43..603edf4c 100644 --- a/roles/docker-openproject/templates/docker-compose.yml.j2 +++ b/roles/docker-openproject/templates/docker-compose.yml.j2 @@ -21,7 +21,7 @@ x-op-app: &app RAILS_CACHE_STORE: "memcache" OPENPROJECT_CACHE__MEMCACHE__SERVER: "cache:11211" 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_MAX_THREADS: ${RAILS_MAX_THREADS:-16} # 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" services: - db: + database: image: postgres:13 <<: *restart_policy stop_grace_period: "3s" @@ -72,7 +72,7 @@ services: - frontend - backend depends_on: - - db + - database - cache - seeder labels: @@ -99,7 +99,7 @@ services: networks: - backend depends_on: - - db + - database - cache - seeder @@ -109,7 +109,7 @@ services: networks: - backend depends_on: - - db + - database - cache - seeder diff --git a/roles/docker-openproject/vars/main.yml b/roles/docker-openproject/vars/main.yml index 2f78deee..4b4440fc 100644 --- a/roles/docker-openproject/vars/main.yml +++ b/roles/docker-openproject/vars/main.yml @@ -1,9 +1,11 @@ -repository_directory: "{{ path_docker_compose_instances }}openproject/" -docker_compose_instance_directory: "{{repository_directory}}compose/" -docker_compose_file_path: "{{docker_compose_instance_directory}}docker-compose.yml" -docker_compose_backup_path: "/tmp/openproject-docker-compose-backup.yml" -database_instance: "openproject" -database_host: "db" -database_databasename: "{{database_instance}}" -database_username: "postgres" -database_password: "{{openproject_database_password}}" \ No newline at end of file +docker_compose_project_name: "openproject" +repository_directory: "{{ path_docker_compose_instances }}{{docker_compose_project_name}}/" +docker_compose_instance_directory: "{{repository_directory}}compose/" +docker_compose_file_path: "{{docker_compose_instance_directory}}docker-compose.yml" +docker_compose_backup_path: "/tmp/{{docker_compose_project_name}}-docker-compose-backup.yml" +database_instance: "{{docker_compose_project_name}}" +database_host: "database" +database_databasename: "{{database_instance}}" +database_username: "postgres" +database_password: "{{openproject_database_password}}" +repository_address: "https://github.com/opf/openproject-deploy" \ No newline at end of file diff --git a/servers.yml b/servers.yml index 8a0f92ba..c6707a64 100644 --- a/servers.yml +++ b/servers.yml @@ -246,7 +246,7 @@ - role: docker-akaunting vars: domain: "{{domain_akaunting}}" - http_port: 8080 + http_port: 8025 # Native Webserver Roles - name: setup nginx-homepages diff --git a/tasks/update-repository-with-docker-compose.yml b/tasks/update-repository-with-docker-compose.yml new file mode 100644 index 00000000..4287446d --- /dev/null +++ b/tasks/update-repository-with-docker-compose.yml @@ -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 \ No newline at end of file