From e641f84b3e50e929000e51a93382a8274955243e Mon Sep 17 00:00:00 2001 From: SebClem Date: Fri, 21 Jul 2023 13:48:49 +0200 Subject: [PATCH] Add site --- defaults/main.yml | 2 ++ tasks/install.yml | 26 ++++++++++++++++++++++++-- templates/dolibarr.conf.j2 | 11 +++++++++++ vars/main.yml | 5 +++++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 templates/dolibarr.conf.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 3e52a2e..858f428 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,3 +1,5 @@ --- # defaults file for Dolibarr dolibarr_version: 17.0.1 + +dolibarr_install_dir: "/opt/dolibarr" diff --git a/tasks/install.yml b/tasks/install.yml index ac62ff5..71fad26 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -1,6 +1,6 @@ - name: Ensure dolibar folder exist ansible.builtin.file: - path: "/opt/dolibarr" + path: "{{ dolibarr_install_dir }}" owner: "www-data" group: "www-data" mode: "755" @@ -10,8 +10,30 @@ ansible.builtin.unarchive: remote_src: true src: "{{ dolibarr_dowload_url }}" - dest: "/opt/dolibarr" + dest: "{{ dolibarr_install_dir }}" owner: "www-data" group: "www-data" extra_opts: - --strip-components=1 + +- name: Enable apache modules + community.general.apache2_module: + name: "{{ item }}" + state: present + loop: "{{ dolibarr_apache_modules }}" + +- name: Add dolibarr apache site + ansible.builtin.template: + src: dolibarr.conf.j2 + dest: /etc/apache2/sites-available/dolibarr.conf + mode: "644" + +- name: Disable default site + ansible.builtin.file: + path: "/etc/apache2/sites-enabled/000-default.conf" + +- name: Enable dolibarr site + ansible.builtin.file: + path: "/etc/apache2/sites-enabled/dolibarr" + src: "/etc/apache2/sites-available/dolibarr.conf" + state: link diff --git a/templates/dolibarr.conf.j2 b/templates/dolibarr.conf.j2 new file mode 100644 index 0000000..b58e44c --- /dev/null +++ b/templates/dolibarr.conf.j2 @@ -0,0 +1,11 @@ + + DocumentRoot {{ dolibarr_install_dir }}/htdocs + + + AllowOverride All + + + ErrorLog ${APACHE_LOG_DIR}/error.lo + CustomLog ${APACHE_LOG_DIR}/access.log combined + + \ No newline at end of file diff --git a/vars/main.yml b/vars/main.yml index 214db54..bb0fc7a 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -21,3 +21,8 @@ dolibarr_apache_dependencies: - libapache2-mod-php dolibarr_dowload_url: https://github.com/Dolibarr/dolibarr/archive/refs/tags/{{ dolibarr_version }}.tar.gz + +dolibarr_apache_modules: + - headers + - env + - rewrite