✨ feat(ansible/playbook.yml): Déploie LudikEvent avec PHP 8.4, inclut mises à jour, configuration et optimisations.
```
185 lines
6.6 KiB
YAML
185 lines
6.6 KiB
YAML
# Fichier: deploy_ludikevent_php84.yml
|
|
- name: Deploy LudikEvent Application
|
|
hosts: webservers
|
|
become: true
|
|
gather_facts: true
|
|
|
|
vars:
|
|
path: "/var/www/mainframe/app" # Assure-toi que ce chemin est correct
|
|
php_bin: "/usr/bin/php8.4"
|
|
php_fpm_service: "php8.4-fpm"
|
|
db_name: "ludikevent"
|
|
db_user: "ludikevent"
|
|
db_password: "ludikevent"
|
|
redis_password: "ludikevent"
|
|
redis_port: "20110"
|
|
|
|
tasks:
|
|
- name: Installation des dépôts et dépendances système
|
|
ansible.builtin.apt:
|
|
name:
|
|
- acl
|
|
- python3-psycopg2
|
|
- ffmpeg
|
|
- php8.4
|
|
- php8.4-fpm
|
|
- php8.4-cli
|
|
- php8.4-common
|
|
- php8.4-mysql
|
|
- php8.4-pgsql
|
|
- php8.4-xml
|
|
- php8.4-mbstring
|
|
- php8.4-zip
|
|
- php8.4-intl
|
|
- php8.4-gd
|
|
- php8.4-curl
|
|
- php8.4-opcache
|
|
- php8.4-bcmath
|
|
- php8.4-redis
|
|
- php8.4-imagick
|
|
state: present
|
|
update_cache: true
|
|
when: ansible_os_family == "Debian"
|
|
|
|
- name: Forcer PHP 8.4 par défaut via update-alternatives
|
|
ansible.builtin.shell: |
|
|
update-alternatives --set php {{ php_bin }}
|
|
changed_when: false
|
|
|
|
- name: Démarrage et activation de PHP-FPM
|
|
ansible.builtin.systemd:
|
|
name: "{{ php_fpm_service }}"
|
|
state: started
|
|
enabled: yes
|
|
|
|
- name: Créer le fichier .env.local de production
|
|
ansible.builtin.copy:
|
|
content: |
|
|
APP_ENV=prod
|
|
APP_DEBUG=false
|
|
VITE_LOAD=1
|
|
DATABASE_URL="postgresql://{{ db_user }}:{{ db_password }}@127.0.0.1:5432/{{ db_name }}?serverVersion=16&charset=utf8"
|
|
REDIS_DSN="redis://{{ redis_password }}@127.0.0.1:{{ redis_port }}"
|
|
REDIS_URL="redis://{{ redis_password }}@127.0.0.1:{{ redis_port }}"
|
|
MESSENGER_TRANSPORT_DSN="redis://{{ redis_password }}@127.0.0.1:{{ redis_port }}/messages"
|
|
APP_SECRET=939bbc67038c2e2d1232d86fc605bf2f
|
|
REAL_MAIL=1
|
|
VAULT_ADDR=http://127.0.0.1:8200
|
|
VAULT_TOKEN=hvs.QLpUdiptXtSPo5Qf7i2nn2Xz
|
|
MAILER_DSN=ses+smtp://AKIAWTT2T22CWBRBBDYN:BBdgb6KxRQ8mNcpWFJsZCJxbSGNdgLhKFiITMErfBlQP@default?region=eu-west-3
|
|
PATH_URL=https://intranet.ludikevent.fr
|
|
STRIPE_BASEURL=https://payment.ludikevent.fr
|
|
SIGN_URL=https://signature.ludikevent.fr
|
|
DEFAULT_URI=https://reservation.ludikevent.fr
|
|
INTRANET_LOCK=false
|
|
dest: "{{ path }}/.env.local"
|
|
owner: bot
|
|
group: www-data
|
|
mode: '0640'
|
|
|
|
- name: Configuration des répertoires essentiels (Permissions)
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
owner: bot
|
|
group: www-data
|
|
mode: '0775'
|
|
state: directory
|
|
recurse: yes
|
|
loop:
|
|
- "{{ path }}/var"
|
|
- "{{ path }}/public/media"
|
|
- "{{ path }}/public/images"
|
|
- "{{ path }}/public/pdf"
|
|
- "{{ path }}/public/seo"
|
|
- "{{ path }}/public/tmp-sign"
|
|
- "{{ path }}/sauvegarde"
|
|
|
|
- name: Exécuter 'composer install'
|
|
ansible.builtin.command: composer install --no-dev --optimize-autoloader
|
|
become: false
|
|
args:
|
|
chdir: "{{ path }}"
|
|
|
|
- name: Exécuter 'bun install' et 'build'
|
|
ansible.builtin.command: "{{ item }}"
|
|
become: false
|
|
args:
|
|
chdir: "{{ path }}"
|
|
loop:
|
|
- "bun install"
|
|
- "bun run build"
|
|
|
|
- name: Exécuter les commandes Symfony bin/console (via PHP 8.4)
|
|
ansible.builtin.command: "{{ php_bin }} bin/console {{ item }} --no-interaction"
|
|
become: false
|
|
args:
|
|
chdir: "{{ path }}"
|
|
loop:
|
|
- "doctrine:migrations:migrate"
|
|
- "cache:clear"
|
|
- "liip:imagine:cache:remove"
|
|
- "app:sitemap"
|
|
|
|
- name: Exécuter pwa:compile (sans limite mémoire)
|
|
ansible.builtin.command: "{{ php_bin }} -d memory_limit=-1 bin/console pwa:compile"
|
|
become: false
|
|
args:
|
|
chdir: "{{ path }}"
|
|
|
|
- name: Mise à jour du journal Git (ignore errors)
|
|
ansible.builtin.command: "{{ php_bin }} bin/console app:git-log-update"
|
|
become: false
|
|
args:
|
|
chdir: "{{ path }}"
|
|
ignore_errors: yes
|
|
|
|
- name: Purger Redis
|
|
ansible.builtin.command: "redis-cli -p {{ redis_port }} -a {{ redis_password }} FLUSHALL"
|
|
|
|
- name: Gestion de Supervisor et Caddy
|
|
ansible.builtin.template:
|
|
src: "{{ item.src }}"
|
|
dest: "{{ item.dest }}"
|
|
mode: '0644'
|
|
loop:
|
|
- { src: 'supervisor.j2', dest: '/etc/supervisor/conf.d/mainframe.conf' }
|
|
- { src: 'caddy.j2', dest: '/etc/caddy/sites/ludikevent.conf' }
|
|
|
|
- name: Rechargement des services
|
|
ansible.builtin.shell: |
|
|
supervisorctl reread && supervisorctl update
|
|
systemctl reload caddy
|
|
changed_when: true
|
|
|
|
- name: Notification Discord
|
|
community.general.discord:
|
|
webhook_id: "1419573620602044518"
|
|
webhook_token: "ikAdxWxsrrTqMTb5Gh_8ylcoJHlOnq7aJZvR5udoS_fCK56Jk3qpEnJHVKdD8fwuNJF3"
|
|
content: "✅ **Déploiement réussi** sur PHP 8.4 - LudikEvent Intranet"
|
|
|
|
- name: Configuration des tâches CRON (via PHP 8.4)
|
|
ansible.builtin.cron:
|
|
name: "{{ item.name }}"
|
|
minute: "{{ item.minute }}"
|
|
hour: "{{ item.hour | default('*') }}"
|
|
job: "{{ php_bin }} {{ path }}/bin/console {{ item.cmd }}"
|
|
user: root
|
|
loop:
|
|
- { name: "LDK - Search", minute: "*/5", cmd: "app:search" }
|
|
- { name: "LDK - Stripe", minute: "0", hour: "1", cmd: "app:stripe:sync" }
|
|
- { name: "LDK - Backup", minute: "0", hour: "*/6", cmd: "app:backup" }
|
|
- { name: "LDK - Clean", minute: "0", hour: "20", cmd: "app:clean" }
|
|
|
|
- name: Permissions finales (Cache & Logs) - Set ACLs
|
|
ansible.builtin.acl:
|
|
path: "{{ item }}"
|
|
entity: www-data
|
|
etype: group
|
|
permissions: rwx
|
|
state: present
|
|
recursive: yes
|
|
default: yes
|
|
loop:
|
|
- "{{ path }}/var/cache"
|
|
- "{{ path }}/var/log"
|