chore: complete update
This commit is contained in:
98
x_ansible/playbooks/deploy/production.yml
Normal file
98
x_ansible/playbooks/deploy/production.yml
Normal file
@@ -0,0 +1,98 @@
|
||||
- name: Deployment für PRODUCTION
|
||||
hosts: production
|
||||
become: true
|
||||
gather_facts: false
|
||||
|
||||
vars:
|
||||
docker_compose_project_path: "/var/www/www.michaelschiemer.de/"
|
||||
env_file_path: "/var/www/www.michaelschiemer.de/.env"
|
||||
deploy_root: /var/www/www.michaelschiemer.de
|
||||
deploy_public: "{{ deploy_root }}/public"
|
||||
deploy_user: deploy
|
||||
app_domain: "michaelschiemer.de"
|
||||
project_root: "{{ playbook_dir }}/../.."
|
||||
|
||||
roles:
|
||||
- app
|
||||
- nginx
|
||||
- php
|
||||
- redis
|
||||
---
|
||||
# Produktions-Deployment
|
||||
# Dieses Playbook steuert das Deployment in die Produktionsumgebung
|
||||
|
||||
- name: Deployment für PRODUKTIONS-Umgebung
|
||||
hosts: production
|
||||
become: true
|
||||
gather_facts: true
|
||||
|
||||
# Vorbereitung des Deployments
|
||||
pre_tasks:
|
||||
- name: Prüfe Verbindung zum Produktionsserver
|
||||
ping:
|
||||
register: ping_result
|
||||
tags: [always, check]
|
||||
|
||||
- name: Zeige Serverinformationen
|
||||
debug:
|
||||
msg: "Verbunden mit {{ inventory_hostname }} ({{ ansible_host }})"
|
||||
tags: [always, check]
|
||||
|
||||
- name: Sicherung der aktuellen Anwendung erstellen
|
||||
shell: |
|
||||
timestamp=$(date +%Y%m%d_%H%M%S)
|
||||
mkdir -p {{ deploy_root }}_backups
|
||||
tar -czf {{ deploy_root }}_backups/backup_$timestamp.tar.gz -C {{ deploy_root }} . || true
|
||||
tags: [backup]
|
||||
|
||||
# Rollen für die Basiseinrichtung des Servers
|
||||
roles:
|
||||
- docker
|
||||
- app
|
||||
- nginx
|
||||
- php
|
||||
- redis
|
||||
|
||||
# Haupttasks für das Deployment
|
||||
tasks:
|
||||
- name: Synchronisiere Anwendungsdateien
|
||||
synchronize:
|
||||
src: "{{ project_source }}/"
|
||||
dest: "{{ deploy_root }}/"
|
||||
delete: yes
|
||||
rsync_opts:
|
||||
- "--exclude=.git/"
|
||||
- "--exclude=node_modules/"
|
||||
- "--exclude=vendor/"
|
||||
- "--exclude=.env.local"
|
||||
tags: [sync, files]
|
||||
|
||||
- name: Wende modulare Deployment-Tasks an
|
||||
import_tasks: ../deploy/includes/deploy_common.yml
|
||||
tags: [deploy]
|
||||
|
||||
# Nachbereitung nach dem Deployment
|
||||
post_tasks:
|
||||
- name: Prüfe Anwendungsstatus
|
||||
uri:
|
||||
url: "https://{{ app_domain }}/"
|
||||
return_content: no
|
||||
status_code: 200, 301, 302, 403
|
||||
validate_certs: yes
|
||||
register: app_status
|
||||
ignore_errors: yes
|
||||
delegate_to: localhost
|
||||
tags: [check]
|
||||
|
||||
- name: Zeige Anwendungsstatus
|
||||
debug:
|
||||
msg: "Anwendung ist {% if app_status.status == 200 %}verfügbar{% else %}nicht verfügbar (Status: {{ app_status.status | default('unbekannt') }}){% endif %}"
|
||||
tags: [check]
|
||||
|
||||
- name: Benachrichtigung über abgeschlossenes Deployment
|
||||
debug:
|
||||
msg: "Deployment in Produktionsumgebung abgeschlossen"
|
||||
tags: [always, notify]
|
||||
tasks:
|
||||
- name: Common Deployment Tasks
|
||||
import_tasks: ../deploy/includes/deploy_common.yml
|
||||
Reference in New Issue
Block a user