From e98d8ba105eab6a1a8c65574923be9f00f124b0b Mon Sep 17 00:00:00 2001 From: rominique Date: Fri, 10 May 2024 22:14:42 +0200 Subject: [PATCH] correction syntaxe correction scenario WP --- creation_nouveau_site.yml | 8 ++++---- tasks/config_WP.yml | 8 ++++---- tasks/config_mariadb.yml | 13 +++++++++++-- tasks/config_nginx.yml | 2 +- tasks/config_pool_php.yml | 2 +- tasks/config_www.yml | 4 +++- tasks/download_nextcloud_source.yml | 16 ++++++++-------- tasks/verif_installation_nextcloud.yml | 2 +- templates/nginx_WP_server.j2 | 6 +++--- 9 files changed, 36 insertions(+), 25 deletions(-) diff --git a/creation_nouveau_site.yml b/creation_nouveau_site.yml index c5ca22c..145d82f 100644 --- a/creation_nouveau_site.yml +++ b/creation_nouveau_site.yml @@ -103,11 +103,11 @@ when: config_php == 'oui' or SITE == 'paheko' or SITE == 'WP' or SITE == 'nuage' - name: Inclure la configuration d'une bdd postgres - ansible.builtin.include_tasks: tasks/config_bdd_postgres.yml + ansible.builtin.include_tasks: tasks/config_postgres.yml when: config_bdd == 'postgres' or SITE == 'nuage' - name: Inclure la configuration d'une bdd mariadb - ansible.builtin.include_tasks: tasks/config_bdd_mariadb.yml + ansible.builtin.include_tasks: tasks/config_mariadb.yml when: config_bdd == 'mariadb' or SITE == 'WP' - name: Inclure la configuration nextcloud si besoin @@ -119,7 +119,7 @@ when: SITE == 'paheko' - name: Inclure la configuration WP si besoin - ansible.builtin.include_tasks: tasks/config_wp.yml + ansible.builtin.include_tasks: tasks/config_WP.yml when: SITE == 'WP' - name: Inclure le configuration du backup @@ -127,4 +127,4 @@ - name: Inclure le configuration SFTP ansible.builtin.include_tasks: tasks/config_sftp.yml - when: sftp_key =! '' and sftp_key =! 'non' + when: sftp_key != '' and sftp_key != 'non' diff --git a/tasks/config_WP.yml b/tasks/config_WP.yml index c328bc0..235cdbb 100644 --- a/tasks/config_WP.yml +++ b/tasks/config_WP.yml @@ -1,12 +1,12 @@ -- name: Create new app common folder from old version one - become_user: "site_{{ SIGLE }}_{{ SITE }}" - become: true +- name: Copie des fichiers sources WP dans le home du nouveau site ansible.builtin.copy: - src: "/home/sites/data/wordpress" + src: "/home/sites/data/wordpress/" dest: "/home/sites/data/{{ TLD }}/{{ DOMAIN }}/{{ SITE }}/" 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 }}_{{ SITE }}" + group: "site_{{ SIGLE }}_{{ SITE }}" - name: Créer les fichiers spécifiques wp ansible.builtin.template: diff --git a/tasks/config_mariadb.yml b/tasks/config_mariadb.yml index 3816d0c..831fc66 100644 --- a/tasks/config_mariadb.yml +++ b/tasks/config_mariadb.yml @@ -1,3 +1,12 @@ +- name: Etckeeper commit if necessary + ansible.builtin.command: etckeeper commit "commit by ansible because installing {{ DOMAIN }}/{{ SITE }}" + ignore_errors: true + +- name: Install ansible mysql required packages + ansible.builtin.apt: + name: + - python3-pymysql + - name: Boucle d'ajout du user php dans plusieurs groupe ansible.builtin.user: name: "php_{{ SIGLE }}_{{ SITE }}" @@ -15,8 +24,8 @@ encoding: utf8mb4 # pour WP - name: Créer le user mysql - mysql_user: + community.mysql.mysql_user: name: "php_{{ SIGLE }}_{{ SITE }}" priv: "php_{{ SIGLE }}_{{ SITE }}.*:ALL" state: present - login_unix_socket: /run/mysqld/mysqld.sock \ No newline at end of file + login_unix_socket: /run/mysqld/mysqld.sock diff --git a/tasks/config_nginx.yml b/tasks/config_nginx.yml index f932ac8..0c61275 100644 --- a/tasks/config_nginx.yml +++ b/tasks/config_nginx.yml @@ -39,7 +39,7 @@ owner: "root" group: "root" mode: '640' # or u=rwx,g=r,o= - when: SITE != 'nuage' and template_site != 'http' + when: SITE != 'nuage' and template_site != 'http' and SITE != 'WP' - name: Recharger le service nginx ansible.builtin.service: diff --git a/tasks/config_pool_php.yml b/tasks/config_pool_php.yml index 970a039..cf1c432 100644 --- a/tasks/config_pool_php.yml +++ b/tasks/config_pool_php.yml @@ -76,4 +76,4 @@ - name: ATTENTION la config php n'a pas été créer ansible.builtin.debug: msg: "Il n'y a pas de templates php pour votre site, il faudra le créer manuellement" - when: SITE != 'nuage' and SITE != 'paheko' or SITE != 'WP' + when: SITE != 'nuage' and SITE != 'paheko' and SITE != 'WP' diff --git a/tasks/config_www.yml b/tasks/config_www.yml index d01c9bf..c1a4b20 100644 --- a/tasks/config_www.yml +++ b/tasks/config_www.yml @@ -25,6 +25,8 @@ owner: "{{ item.owner }}" group: "{{ item.group }}" mode: "{{ item.mode }}" + vars: + concat: "site_{{ SIGLE }}_{{ SITE }}" loop_control: label: "{{ item.path }}" loop: @@ -40,6 +42,6 @@ mode: '2751' - path: "/home/sites/data/{{ TLD }}/{{ DOMAIN }}/{{ SITE }}" state: directory - owner: 'root' + owner: "{{ ( SITE in ['www','WP'] ) | ternary ( concat , 'root' ) }}" group: "site_{{ SIGLE }}_{{ SITE }}" mode: '2750' diff --git a/tasks/download_nextcloud_source.yml b/tasks/download_nextcloud_source.yml index 77a46c6..4c79f2b 100644 --- a/tasks/download_nextcloud_source.yml +++ b/tasks/download_nextcloud_source.yml @@ -7,10 +7,10 @@ mode: '755' # or u=rwx,g=rx,o=rx checksum: "md5:{{ nextcloud_repo_url }}/nextcloud-{{ nouvelle_version }}.tar.bz2.md5" -- name: create nextcloud source dir +- name: Create nextcloud source dir become: true become_user: nextcloud - ansible.builtin.file: + ansible.builtin.file: path: "{{ nextcloud_sources_files_path }}/nextcloud-{{ nouvelle_version }}" state: directory mode: '755' # or u=rwx,g=rx,o=rx @@ -22,17 +22,17 @@ src: "{{ nextcloud_sources_files_path }}/nextcloud-{{ nouvelle_version }}.tar.bz2" dest: "{{ nextcloud_sources_files_path }}/" # mode: '755' # or u=rwx,g=rx,o=rx - remote_src: yes + remote_src: true -- name: "rename nextloud dir to nextcloud-{{ nouvelle_version }}" +- name: Rename nextloud dir to nextcloud-nouvelle_version become: true become_user: nextcloud - ansible.builtin.copy: + ansible.builtin.copy: src: "{{ nextcloud_sources_files_path }}/nextcloud/" dest: "{{ nextcloud_sources_files_path }}/nextcloud-{{ nouvelle_version }}" - remote_src: yes # because the config file is already in the nextcloud_tmp_path + remote_src: true # because the config file is already in the nextcloud_tmp_path -- name: deleted downloaded nextcloud files +- name: Deleted downloaded nextcloud files become: true become_user: nextcloud ansible.builtin.file: @@ -40,4 +40,4 @@ state: absent loop: - "{{ nextcloud_sources_files_path }}/nextcloud-{{ nouvelle_version }}.tar.bz2" - - "{{ nextcloud_sources_files_path }}/nextcloud" \ No newline at end of file + - "{{ nextcloud_sources_files_path }}/nextcloud" diff --git a/tasks/verif_installation_nextcloud.yml b/tasks/verif_installation_nextcloud.yml index bb679e4..508c5fd 100644 --- a/tasks/verif_installation_nextcloud.yml +++ b/tasks/verif_installation_nextcloud.yml @@ -25,4 +25,4 @@ dest: "{{ nextcloud_common_files_path }}/nextcloud-{{ nouvelle_version }}" remote_src: true # because the copy is from remote host to remote host mode: '754' # or 'u=rwx,g=rx,o=r' - when: not new_nextcloud_common.stat.exists \ No newline at end of file + when: not new_nextcloud_common.stat.exists diff --git a/templates/nginx_WP_server.j2 b/templates/nginx_WP_server.j2 index a501e6d..a41c72d 100644 --- a/templates/nginx_WP_server.j2 +++ b/templates/nginx_WP_server.j2 @@ -13,9 +13,9 @@ server { ssl_certificate_key /etc/letsencrypt/live/{{ SITE }}.{{ DOMAIN }}.{{ TLD }}/privkey.pem; 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; + root /home/sites/data/{{ TLD }}/{{ DOMAIN }}/{{ SITE }}/; + server_name {{ DOMAIN }}.{{ TLD }} {{ config_ss_domain | default(SITE) }}.{{ DOMAIN }}.{{ TLD }}; {% endif %} - server_name {{ DOMAIN }}.{{ TLD }} {{ config_ss_domain | default(SITE) }}.{{ DOMAIN }}.{{ TLD }}; - root /home/sites/data/{{ TLD }}/{{ DOMAIN }}/{{ SITE }}/; index index.php index.html index.htm; client_max_body_size 500M; location / { @@ -36,7 +36,7 @@ server { } location ~ \.php$ { include snippets/fastcgi-php.conf; - fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; + fastcgi_pass unix:/run/php{{ php_version }}/fpm/php_{{ SIGLE }}_{{ SITE }}; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } -- 2.20.1