From 09f7e02520b21a08433c051c1341e4da71058bc8 Mon Sep 17 00:00:00 2001 From: rick Date: Sat, 25 Jun 2022 01:31:56 +0200 Subject: [PATCH] add archives mail --- main.yml | 1 + roles/bubger/tasks/main.yml | 60 +++++++++++++++++++++++++++ roles/bubger/templates/archives-nginx | 17 ++++++++ roles/bubger/vars/main.yml | 8 ++++ vars/sites.yml | 1 + 5 files changed, 87 insertions(+) create mode 100644 roles/bubger/tasks/main.yml create mode 100644 roles/bubger/templates/archives-nginx create mode 100644 roles/bubger/vars/main.yml diff --git a/main.yml b/main.yml index 2414577..dd813a2 100644 --- a/main.yml +++ b/main.yml @@ -51,6 +51,7 @@ - libretls - cgit - site + - bubger post_tasks: - name: démarrage par défaut de nginx diff --git a/roles/bubger/tasks/main.yml b/roles/bubger/tasks/main.yml new file mode 100644 index 0000000..ba8ab18 --- /dev/null +++ b/roles/bubger/tasks/main.yml @@ -0,0 +1,60 @@ +################################################################################ +# création des dossiers pour les archives mails +# +# Copyright (C) 2022 rick G. +# +# This program is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program. If not, see . +################################################################################ + +--- +- name: installation des paquets nécessaires + apt: + name: + - rsync + +- name: création dossier principal + ansible.builtin.file: + path: "{{ path }}" + state: directory + +- name: création des sous dossiers + ansible.builtin.file: + path: "{{ item }}" + state: directory + with_items: + - "{{ public }}" + - "{{ private }}" + +- name: lien symbolique pour le dossier publique + ansible.builtin.file: + src: "{{ public }}" + dest: "{{ path_site_public }}" + state: link + +- name: lien symbolique pour le dossier privé + ansible.builtin.file: + src: "{{ private }}" + dest: "{{ path_site_private }}" + state: link + +- name: configuration de Nginx + template: + src: "archives-nginx" + dest: "{{ ava }}/archives.conf" + mode: 0644 + +- name: lien symbolique pour Nginx + file: + src: "{{ ava }}/archives.conf" + dest: "{{ ena }}/archives.conf" + state: link diff --git a/roles/bubger/templates/archives-nginx b/roles/bubger/templates/archives-nginx new file mode 100644 index 0000000..6a8a52d --- /dev/null +++ b/roles/bubger/templates/archives-nginx @@ -0,0 +1,17 @@ +server { + server_name {{ site }}; + listen 80; + listen [::]:80; + + root {{ path_site }}; + + index index.html index.htm; + + location /archives { + try_files $uri $uri/ =404; + } + + location /{{ private_name }} { + try_files $uri $uri/ =404; + } +} diff --git a/roles/bubger/vars/main.yml b/roles/bubger/vars/main.yml new file mode 100644 index 0000000..eaef55e --- /dev/null +++ b/roles/bubger/vars/main.yml @@ -0,0 +1,8 @@ +--- +private_name: "" +path: "{{ home_user_default }}/bubger" +path_site: "/var/www/mailings_list" +path_site_public: "{{ path_site }}/archives" +path_site_private: "{{ path_site }}/{{ private_name }}" +public: "{{ path }}/archives" +private: "{{ path }}/{{ private_name }}" diff --git a/vars/sites.yml b/vars/sites.yml index e71e32c..9923358 100644 --- a/vars/sites.yml +++ b/vars/sites.yml @@ -3,5 +3,6 @@ site: "" cgit_site: "" user_default: "ubuntu" +home_user_default: "/home/{{ user_default }}" ava: "/etc/nginx/sites-available" ena: "/etc/nginx/sites-enabled"