ajout du tags sftp master
authorrominique <romain.legoff@heureux-cyclage.org>
Fri, 5 Jul 2024 13:57:05 +0000 (15:57 +0200)
committerrominique <romain.legoff@heureux-cyclage.org>
Fri, 5 Jul 2024 13:57:05 +0000 (15:57 +0200)
correcton tags https
correction permission et owner WP

creation_nouveau_site.yml
tasks/config_WP.yml
tasks/config_nginx.yml
tasks/config_options_www.yml

index ed292dd..48caac2 100644 (file)
@@ -1,7 +1,10 @@
 # commande pour lancer le playbook: ansible-playbook creation_nouveau_site.yml
 # attention - Par défaut ce scipt se lancer vers ligatures
 
-# pour ne jouer que la partie permettant de générer le certificat SSL pour le HTTPS lancer la commance ci-dessous (attention il faut recharger nginx manuellement à la fin):
+# pour ne jouer que la partie permettant de générer le certificat SSL pour le HTTPS lancer la commance ci-dessous:
+# ansible-playbook creation_nouveau_site.yml --tags "https"
+
+# pour ne jouer que la partie permettant de configrer un accès SFTP lancer la commance ci-dessous:
 # ansible-playbook creation_nouveau_site.yml --tags "https"
 
 - name: Promp pour définir les variables du nouveau ite
@@ -54,7 +57,9 @@
 
     - name: Inclure les configurations optionnelles d'un site www
       ansible.builtin.include_tasks: tasks/config_options_www.yml
-      tags: https
+      tags:
+        - https
+        - sftp
 
     - name: Inclure la configuration d'un site web basique
       ansible.builtin.include_tasks: tasks/config_www.yml
       ansible.builtin.include_tasks: tasks/config_backup.yml
 
     - name: Inclure le configuration SFTP
-      ansible.builtin.include_tasks: tasks/config_sftp.yml
+      ansible.builtin.include_tasks:
+        file: tasks/config_sftp.yml
+        apply:
+          tags: sftp
       when: sftp_key != '' and sftp_key != 'non'
+      tags: sftp
index 684d161..646a2a4 100644 (file)
@@ -3,8 +3,8 @@
     src: "/home/sites/data/wordpress/"
     dest: "/home/sites/data/{{ TLD }}/{{ DOMAIN }}/{{ config_ss_domain }}/"
     remote_src: true # because the copy is from remote host to remote host
-    mode: '754' # or 'u=rwx,g=rx,o=r'
-    owner: "php_{{ SIGLE }}_{{ config_ss_domain }}"
+    mode: '2750' # or 'u=rwx,g=rx,o=r'
+    owner: "site_{{ SIGLE }}_{{ config_ss_domain }}"
     group: "site_{{ SIGLE }}_{{ config_ss_domain }}"
 
 - name: Créer les fichiers spécifiques wp
index 3f74047..d370f46 100644 (file)
     name: nginx
     state: reloaded
   when: SITE != 'nuage' and SITE != 'paheko' and SITE != 'WP' and template_site == 'http'
+
+# ne jamais executer cette tâche sauf si le playbook est appelé avec le tag https - fin du playbook
+- name: Recharger le service nginx
+  ansible.builtin.service:
+    name: nginx
+    state: reloaded
+  tags:
+    - https
+    - never
\ No newline at end of file
index 4f46142..132d063 100644 (file)
@@ -1,47 +1,51 @@
 - name: Demande sous-domaine
-  tags: https
+  tags:
+    - https
+    - sftp
   ansible.builtin.pause:
     prompt: 'quel sous-domaine faut-il configurer?(ex: www/gestion)'
     echo: true
-    default: '{{ SITE }}'
   register: config_ss_domain_promp
   when: SITE != 'nuage'
 
-- name: Bloc demande des autres options
+- name: Demande php
+  ansible.builtin.pause:
+    prompt: 'Faut-il configurer un pool PHP?(oui/non)'
+    echo: true
+  register: config_php_promp
   when: SITE != 'paheko' and SITE != 'nuage' and SITE != 'WP'
-  block:
 
-    - name: Demande php
-      ansible.builtin.pause:
-        prompt: 'Faut-il configurer un pool PHP?(oui/non)'
-        echo: true
-      register: config_php_promp
+- name: Demande bdd
+  ansible.builtin.pause:
+    prompt: 'Faut-il configurer une base de données SQL?(ex: mariadb/postgres/non)'
+    echo: true
+  register: config_bdd_promp
+  when: SITE != 'paheko' and SITE != 'nuage' and SITE != 'WP'
 
-    - name: Demande bdd
-      ansible.builtin.pause:
-        prompt: 'Faut-il configurer une base de données SQL?(ex: mariadb/postgres/non)'
-        echo: true
-      register: config_bdd_promp
+- name: Demande sftp_key
+  ansible.builtin.pause:
+    prompt: 'besoin de configurer un accès SFTP pour ce compte (vide ou clé public)'
+    echo: true
+  register: sftp_key_promp
+  when: SITE != 'paheko' and SITE != 'nuage'
+  tags: sftp
 
-    - name: Demande sftp_key
-      ansible.builtin.pause:
-        prompt: 'besoin de configurer un accès SFTP pour ce compte (vide ou clé public)'
-        echo: true
-      register: sftp_key_promp
+- name: Definir config_ss_domain
+  tags:
+    - https
+    - sftp
+  ansible.builtin.set_fact:
+    config_ss_domain: "{{ ( SITE == 'nuage' | default ('') ) | ternary (SITE, config_ss_domain_promp.user_input) }}"
 
 - name: Definir config_php
   ansible.builtin.set_fact:
     config_php: "{{ ( config_php_promp.user_input | default ('') | length == 0 ) | ternary ('non', config_php_promp.user_input) }}"
 
-- name: Definir config_ss_domain
-  tags: https
-  ansible.builtin.set_fact:
-    config_ss_domain: "{{ ( SITE == 'nuage' | default ('') ) | ternary (SITE, config_ss_domain_promp.user_input) }}"
-
 - name: Definir config_bdd
   ansible.builtin.set_fact:
     config_bdd: "{{ ( config_bdd_promp.user_input | default ('') | length == 0 ) | ternary ('non', config_bdd_promp.user_input) }}"
 
 - name: Definir sftp_key
+  tags: sftp
   ansible.builtin.set_fact:
     sftp_key: "{{ sftp_key_promp.user_input | default('non') }}"
\ No newline at end of file