From 0c2bd2b01afd4d557c060695e8a002b9f9fb9928 Mon Sep 17 00:00:00 2001 From: rominique Date: Mon, 29 Apr 2024 19:25:35 +0200 Subject: [PATCH] corrections pour le sftp --- tasks/config_options_www.yml | 2 +- tasks/config_sftp.yml | 20 +++++++++++++------- templates/nginx_www_server.j2 | 1 + 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tasks/config_options_www.yml b/tasks/config_options_www.yml index 8f4a943..22fb7b0 100644 --- a/tasks/config_options_www.yml +++ b/tasks/config_options_www.yml @@ -12,7 +12,7 @@ config_ss_domain: "{{ config_ss_domain_promp.user_input | default(SITE) }}" - name: Bloc demande des autres options - when: SITE != 'WP' and SITE != 'paheko' + when: SITE != 'paheko' #and SITE != 'WP' block: - name: Demande php diff --git a/tasks/config_sftp.yml b/tasks/config_sftp.yml index 54bc7dc..92212da 100644 --- a/tasks/config_sftp.yml +++ b/tasks/config_sftp.yml @@ -1,12 +1,13 @@ -- name: Ajout de l'utilisateur site_SIGLE_SITE dans le group sftponly +- name: Ajout de l'utilisateur site_SIGLE_SITE dans le group sftponly et modification du home ansible.builtin.user: name: "site_{{ SIGLE }}_{{ SITE }}" + home: "/home/sites/data/{{ TLD }}/{{ DOMAIN }}" + shell: /bin/false groups: sftponly append: true + create_home: false -# verif si le home appartient bien à root avec un mode 2750 ou 2770? - -- name: Boucle création ou modifications du repertoire .ssh +- name: Boucle création ou modifications du repertoire .ssh et vérif des permissions/owner du home ansible.builtin.file: path: "{{ item.path }}" state: "{{ item.state }}" @@ -16,7 +17,12 @@ loop_control: label: "{{ item.path }}" loop: - - path: "/home/sites/data/{{ TLD }}/{{ DOMAIN }}/{{ SITE }}/.ssh" + - path: "/home/sites/data/{{ TLD }}/{{ DOMAIN }}" + state: directory + owner: 'root' + group: 'www-data' + mode: '2751' + - path: "/home/sites/data/{{ TLD }}/{{ DOMAIN }}/.ssh" state: directory owner: "site_{{ SIGLE }}_{{ SITE }}" group: "site_{{ SIGLE }}_{{ SITE }}" @@ -25,10 +31,10 @@ - name: Création du fichier authorized_keys ansible.builtin.template: src: "templates/authorized_keys.j2" - dest: "/home/sites/data/{{ TLD }}/{{ DOMAIN }}/{{ SITE }}/.ssh/authorized_keys" + dest: "/home/sites/data/{{ TLD }}/{{ DOMAIN }}/.ssh/authorized_keys" owner: "site_{{ SIGLE }}_{{ SITE }}" group: "site_{{ SIGLE }}_{{ SITE }}" - mode: '640' + mode: '600' when: sftp_key is defined # verif le serveur openssh est bien config et sinon le faire? + reload diff --git a/templates/nginx_www_server.j2 b/templates/nginx_www_server.j2 index 1000490..ace724b 100644 --- a/templates/nginx_www_server.j2 +++ b/templates/nginx_www_server.j2 @@ -1,5 +1,6 @@ server { listen 80; + include /etc/nginx/{{ TLD }}/{{ DOMAIN }}/{{ SITE }}/common.conf; server_name {{ DOMAIN }}.{{ TLD }}; access_log /home/sites/log/nginx/{{ TLD }}/{{ DOMAIN }}/{{ SITE }}/access.log main buffer=32k; error_log /home/sites/log/nginx/{{ TLD }}/{{ DOMAIN }}/{{ SITE }}/error.log warn; -- 2.20.1