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
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
- 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'
-- 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:
+- 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 }}"
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
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:
- 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'
owner: "{{ item.owner }}"
group: "{{ item.group }}"
mode: "{{ item.mode }}"
+ vars:
+ concat: "site_{{ SIGLE }}_{{ SITE }}"
loop_control:
label: "{{ item.path }}"
loop:
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'
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
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:
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"
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
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 / {
}
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;
}