From d8385bff84186afe66e6fb5842b728a3337c225e Mon Sep 17 00:00:00 2001 From: Patrick Marchand Date: Mon, 6 May 2019 22:00:45 +0200 Subject: [PATCH 1/2] Make it possible to overwrite the default evoadmin-web templates The templates can also be forced to update if so desired. --- CHANGELOG.md | 1 + webapps/evoadmin-web/README.md | 35 ++++++++++++++++++++++++++ webapps/evoadmin-web/defaults/main.yml | 5 ++++ webapps/evoadmin-web/tasks/config.yml | 18 +++++++++++-- webapps/evoadmin-web/tasks/user.yml | 9 ++++++- webapps/evoadmin-web/tasks/web.yml | 19 +++++++++++--- 6 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 webapps/evoadmin-web/README.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 73e9f2e0..8642c3bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The **patch** part changes incrementally at each release. ### Added * apache: add server status suffix in VHost (and default site) if missing * nginx: add server status suffix in VHost (and default site) if missing +* Overload evoadmin-web templates if needed ### Changed * evocheck : version 19.04 from upstream diff --git a/webapps/evoadmin-web/README.md b/webapps/evoadmin-web/README.md new file mode 100644 index 00000000..918e8004 --- /dev/null +++ b/webapps/evoadmin-web/README.md @@ -0,0 +1,35 @@ +# Set custom web-add.conf file +- "templates/evoadmin-web/web-add.{{ inventory_hostname }}.conf.j2" +- "templates/evoadmin-web/web-add.{{ host_group }}.conf.j2" +- "templates/evoadmin-web/web-add.conf.j2" +And force it to update: + web_add_conf_force: True + +# Set custom web-mail.tpl +- "templates/evoadmin-web/web-mail.{{ inventory_hostname }}.tpl.j2" +- "templates/evoadmin-web/web-mail.{{ host_group }}.tpl.j2" +- "templates/evoadmin-web/web-mail.tpl.j2" +And force it to update: + web_mail_tpl_force: True + +# Set custom evoadmin.conf VHost +- "templates/evoadmin-web/evoadmin.{{ inventory_hostname }}.conf.j2" +- "templates/evoadmin-web/evoadmin.{{ host_group }}.conf.j2" +- "templates/evoadmin-web/evoadmin.conf.j2" +And force it to update: + evoadmin_web_conf_force: True + +# Set custom config.local.php +- "templates/evoadmin-web/config.local.{{ inventory_hostname }}.conf.j2" +- "templates/evoadmin-web/config.local.{{ host_group }}.conf.j2" +- "templates/evoadmin-web/config.local.conf.j2" +And force it to update: + evoadmin_web_config_local_php_force: True + +# Set evoadmin-web sudoers file +- "templates/evoadmin-web/sudoers.{{ inventory_hostname }}.j2" +- "templates/evoadmin-web/sudoers.{{ host_group }}.j2" +- "templates/evoadmin-web/sudoers.j2" +- "sudoers.j2" +And force it to update: + evoadmin_web_sudoers_conf_force: True \ No newline at end of file diff --git a/webapps/evoadmin-web/defaults/main.yml b/webapps/evoadmin-web/defaults/main.yml index c57c3b54..fc77c234 100644 --- a/webapps/evoadmin-web/defaults/main.yml +++ b/webapps/evoadmin-web/defaults/main.yml @@ -11,6 +11,11 @@ evoadmin_host: "evoadmin.{{ ansible_fqdn }}" evoadmin_username: evoadmin evoadmin_enable_vhost: True +evoadmin_force_vhost: False +evoadmin_web_config_local_php_force: False +evoadmin_web_sudoers_conf_force: False +web_add_conf_force: False +web_mail_tpl_force: False evoadmin_tpl_servername: "{{ ansible_fqdn }}" evoadmin_tpl_address: "{{ ansible_default_ipv4.address }}" diff --git a/webapps/evoadmin-web/tasks/config.yml b/webapps/evoadmin-web/tasks/config.yml index b34b5ef0..b36f8178 100644 --- a/webapps/evoadmin-web/tasks/config.yml +++ b/webapps/evoadmin-web/tasks/config.yml @@ -8,10 +8,24 @@ - name: Configure web-add config file template: - src: web-add.conf.j2 + src: "{{ item }}" dest: /etc/evolinux/web-add.conf + force: "{{ web_add_conf_force | bool }}" + with_first_found: + - "templates/evoadmin-web/web-add.{{ inventory_hostname }}.conf.j2" + - "templates/evoadmin-web/web-add.{{ host_group }}.conf.j2" + - "templates/evoadmin-web/web-add.conf.j2" + - "web-add.conf.j2" + register: web_add_conf_template - name: Configure web-add template file for mail template: - src: web-mail.tpl.j2 + src: "{{ item }}" dest: "{{ evoadmin_scripts_dir }}/web-mail.tpl" + force: "{{ web_mail_tpl_force | bool }}" + with_first_found: + - "templates/evoadmin-web/web-mail.{{ inventory_hostname }}.tpl.j2" + - "templates/evoadmin-web/web-mail.{{ host_group }}.tpl.j2" + - "templates/evoadmin-web/web-mail.tpl.j2" + - "web-mail.default.tpl.j2" + register: web_mail_tpl_template \ No newline at end of file diff --git a/webapps/evoadmin-web/tasks/user.yml b/webapps/evoadmin-web/tasks/user.yml index 947b3cd0..08a952a2 100644 --- a/webapps/evoadmin-web/tasks/user.yml +++ b/webapps/evoadmin-web/tasks/user.yml @@ -103,7 +103,14 @@ - name: Add evoadmin sudoers file template: - src: sudoers.j2 + src: "{{ item }}" dest: /etc/sudoers.d/evoadmin mode: "0600" + force: "{{ evoadmin_web_sudoers_conf_force | bool }}" validate: "visudo -cf %s" + with_first_found: + - "templates/evoadmin-web/sudoers.{{ inventory_hostname }}.j2" + - "templates/evoadmin-web/sudoers.{{ host_group }}.j2" + - "templates/evoadmin-web/sudoers.j2" + - "sudoers.j2" + register: evoadmin_web_sudoers_conf \ No newline at end of file diff --git a/webapps/evoadmin-web/tasks/web.yml b/webapps/evoadmin-web/tasks/web.yml index d8405f8f..12ad23b6 100644 --- a/webapps/evoadmin-web/tasks/web.yml +++ b/webapps/evoadmin-web/tasks/web.yml @@ -20,8 +20,15 @@ - name: Install evoadmin VHost template: - src: evoadmin.conf.j2 + src: "{{ item }}" dest: /etc/apache2/sites-available/evoadmin.conf + force: "{{ evoadmin_force_vhost | bool }}" + with_first_found: + - "templates/evoadmin-web/evoadmin.{{ inventory_hostname }}.conf.j2" + - "templates/evoadmin-web/evoadmin.{{ host_group }}.conf.j2" + - "templates/evoadmin-web/evoadmin.conf.j2" + - "evoadmin.conf.j2" + register: evoadmin_vhost_template notify: reload apache2 - name: Enable evoadmin vhost @@ -40,9 +47,15 @@ - name: Copy config file for evoadmin template: - src: config.local.php.j2 + src: "{{ item }}" dest: "{{ evoadmin_document_root}}/conf/config.local.php" mode: "0640" owner: evoadmin group: evoadmin - force: no + force: "{{ evoadmin_web_config_local_php_force | bool }}" + with_first_found: + - "templates/evoadmin-web/config.local.{{ inventory_hostname }}.conf.j2" + - "templates/evoadmin-web/config.local.{{ host_group }}.conf.j2" + - "templates/evoadmin-web/config.local.conf.j2" + - "config.local.conf.j2" + register: evoadmin_web_config_local_php_template \ No newline at end of file -- 2.39.2 From 1fc8b2b9f910a84918d3a5b70b522d295601f974 Mon Sep 17 00:00:00 2001 From: Patrick Marchand Date: Mon, 6 May 2019 23:41:36 +0200 Subject: [PATCH 2/2] Fixed errors in filenames --- webapps/evoadmin-web/README.md | 8 ++++---- webapps/evoadmin-web/tasks/config.yml | 2 +- webapps/evoadmin-web/tasks/web.yml | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/webapps/evoadmin-web/README.md b/webapps/evoadmin-web/README.md index 918e8004..bf5fd03e 100644 --- a/webapps/evoadmin-web/README.md +++ b/webapps/evoadmin-web/README.md @@ -17,12 +17,12 @@ And force it to update: - "templates/evoadmin-web/evoadmin.{{ host_group }}.conf.j2" - "templates/evoadmin-web/evoadmin.conf.j2" And force it to update: - evoadmin_web_conf_force: True + evoadmin_force_vhost: True # Set custom config.local.php -- "templates/evoadmin-web/config.local.{{ inventory_hostname }}.conf.j2" -- "templates/evoadmin-web/config.local.{{ host_group }}.conf.j2" -- "templates/evoadmin-web/config.local.conf.j2" +- "templates/evoadmin-web/config.local.{{ inventory_hostname }}.php.j2" +- "templates/evoadmin-web/config.local.{{ host_group }}.php.j2" +- "templates/evoadmin-web/config.local.php.j2" And force it to update: evoadmin_web_config_local_php_force: True diff --git a/webapps/evoadmin-web/tasks/config.yml b/webapps/evoadmin-web/tasks/config.yml index b36f8178..68423193 100644 --- a/webapps/evoadmin-web/tasks/config.yml +++ b/webapps/evoadmin-web/tasks/config.yml @@ -27,5 +27,5 @@ - "templates/evoadmin-web/web-mail.{{ inventory_hostname }}.tpl.j2" - "templates/evoadmin-web/web-mail.{{ host_group }}.tpl.j2" - "templates/evoadmin-web/web-mail.tpl.j2" - - "web-mail.default.tpl.j2" + - "web-mail.tpl.j2" register: web_mail_tpl_template \ No newline at end of file diff --git a/webapps/evoadmin-web/tasks/web.yml b/webapps/evoadmin-web/tasks/web.yml index 12ad23b6..8a79b8b2 100644 --- a/webapps/evoadmin-web/tasks/web.yml +++ b/webapps/evoadmin-web/tasks/web.yml @@ -54,8 +54,8 @@ group: evoadmin force: "{{ evoadmin_web_config_local_php_force | bool }}" with_first_found: - - "templates/evoadmin-web/config.local.{{ inventory_hostname }}.conf.j2" - - "templates/evoadmin-web/config.local.{{ host_group }}.conf.j2" - - "templates/evoadmin-web/config.local.conf.j2" + - "templates/evoadmin-web/config.local.{{ inventory_hostname }}.php.j2" + - "templates/evoadmin-web/config.local.{{ host_group }}.php.j2" + - "templates/evoadmin-web/config.local.php.j2" - "config.local.conf.j2" register: evoadmin_web_config_local_php_template \ No newline at end of file -- 2.39.2