diff --git a/playbook.yml b/playbook.yml index 5e2ff9b..22d5c8c 100644 --- a/playbook.yml +++ b/playbook.yml @@ -8,6 +8,7 @@ - { role: traefik, tags: ["traefik"] } - { role: whoami, tags: ["whoami"] } - { role: protonmail, tags: ["protonmail"] } + - { role: dolibarr, tags: ["dolibarr"] } - { role: cloud, tags: ["cloud"] } - { role: vaultwarden, tags: ["vaultwarden"] } - { role: home_assistant, tags: ["home_assistant"] } diff --git a/roles/dolibarr/tasks/base.yml b/roles/dolibarr/tasks/base.yml new file mode 100644 index 0000000..7059f7f --- /dev/null +++ b/roles/dolibarr/tasks/base.yml @@ -0,0 +1,33 @@ +--- + +- name: Check dolibarr directory exist + ansible.builtin.file: + path: dolibarr + state: directory + register: first_install + +- name: Copy template conf + ansible.builtin.template: + src: "{{ item.src }}" + dest: "dolibarr/{{ item.dest }}" + loop: + - { src: 'docker-compose.yml.j2', dest: 'docker-compose.yml' } + register: dolibarr_copy_templates_results + +- name: Prepare volume folder + ansible.builtin.file: + path: "{{ item }}" + state: directory + loop: + - "{{ server.work_dir }}/dolibarr/base/documents" + - "{{ server.work_dir }}/dolibarr/base/html" + - "{{ server.work_dir }}/dolibarr/db" + become: true + +- name: Update and restart container + community.docker.docker_compose: + project_src: dolibarr + state: present + pull: true + restarted: "{{ dolibarr_copy_templates_results.changed }}" + become: true \ No newline at end of file diff --git a/roles/dolibarr/tasks/main.yml b/roles/dolibarr/tasks/main.yml new file mode 100644 index 0000000..c4e7ea2 --- /dev/null +++ b/roles/dolibarr/tasks/main.yml @@ -0,0 +1,4 @@ +--- + +- ansible.builtin.import_tasks: base.yml + name: base diff --git a/roles/dolibarr/templates/docker-compose.yml.j2 b/roles/dolibarr/templates/docker-compose.yml.j2 new file mode 100644 index 0000000..96836a3 --- /dev/null +++ b/roles/dolibarr/templates/docker-compose.yml.j2 @@ -0,0 +1,45 @@ +version: '3' + +services: + mariadb: + image: mariadb:latest + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: dolibarr + volumes: + - {{ server.work_dir }}/dolibarr/db:/var/lib/mysql + networks: + - internal + + dolibarr: + image: upshift/dolibarr:latest + restart: always + container_name: dolibarr + environment: + DOLI_DB_HOST: mariadb + DOLI_DB_USER: root + DOLI_DB_PASSWORD: root + DOLI_DB_NAME: dolibarr + DOLI_URL_ROOT: 'http://0.0.0.0' + DOLI_ADMIN_LOGIN: admin + DOLI_ADMIN_PASSWORD: admin + PHP_INI_date.timezone: 'Europe/Paris' + DOLI_INSTALL_AUTO: 1 + volumes: + - {{ server.work_dir }}/dolibarr/base/documents:/var/www/documents + - {{ server.work_dir }}/dolibarr/base/html:/var/www/html + networks: + - proxy + - internal + labels: + - "traefik.enable=true" + - "traefik.http.routers.dolibarr-secure.entrypoints=https" + - "traefik.http.routers.dolibarr-secure.rule=Host(`dolibarr.{{ server.domain }}`)" + - "traefik.http.routers.dolibarr-secure.tls=true" + - "traefik.http.routers.dolibarr-secure.tls.certresolver=sslResolver" + - "traefik.docker.network=proxy" + +networks: + internal: + proxy: + external: true