feat: Complete deployment setup for code pushes
- Add pre-flight checks in deploy-update.yml - Automatically copy docker-compose.yml and nginx config in setup-infrastructure.yml - Add comprehensive deployment documentation - Ready for automated code deployments via CI/CD pipeline
This commit is contained in:
@@ -45,6 +45,22 @@
|
||||
group: "{{ ansible_user }}"
|
||||
mode: '0755'
|
||||
|
||||
- name: Check if docker-compose.yml exists in application stack
|
||||
stat:
|
||||
path: "{{ app_stack_path }}/docker-compose.yml"
|
||||
register: compose_file_exists
|
||||
|
||||
- name: Fail if docker-compose.yml doesn't exist
|
||||
fail:
|
||||
msg: |
|
||||
Application Stack docker-compose.yml not found at {{ app_stack_path }}/docker-compose.yml
|
||||
|
||||
The Application Stack must be deployed first via:
|
||||
ansible-playbook -i inventory/production.yml playbooks/setup-infrastructure.yml
|
||||
|
||||
This will create the application stack with docker-compose.yml and .env file.
|
||||
when: not compose_file_exists.stat.exists
|
||||
|
||||
- name: Create backup directory
|
||||
file:
|
||||
path: "{{ backups_path }}/{{ deployment_timestamp | regex_replace(':', '-') }}"
|
||||
@@ -54,6 +70,22 @@
|
||||
mode: '0755'
|
||||
|
||||
tasks:
|
||||
- name: Verify docker-compose.yml exists
|
||||
stat:
|
||||
path: "{{ app_stack_path }}/docker-compose.yml"
|
||||
register: compose_file_check
|
||||
|
||||
- name: Fail if docker-compose.yml doesn't exist
|
||||
fail:
|
||||
msg: |
|
||||
Application Stack docker-compose.yml not found at {{ app_stack_path }}/docker-compose.yml
|
||||
|
||||
The Application Stack must be deployed first via:
|
||||
ansible-playbook -i inventory/production.yml playbooks/setup-infrastructure.yml
|
||||
|
||||
This will create the application stack with docker-compose.yml and .env file.
|
||||
when: not compose_file_check.stat.exists
|
||||
|
||||
- name: Backup current deployment metadata
|
||||
shell: |
|
||||
docker compose -f {{ app_stack_path }}/docker-compose.yml ps --format json 2>/dev/null > {{ backups_path }}/{{ deployment_timestamp | regex_replace(':', '-') }}/current_containers.json || true
|
||||
@@ -62,6 +94,7 @@
|
||||
executable: /bin/bash
|
||||
changed_when: false
|
||||
ignore_errors: yes
|
||||
when: compose_file_check.stat.exists
|
||||
|
||||
- name: Login to Docker registry (if credentials provided)
|
||||
community.docker.docker_login:
|
||||
|
||||
Reference in New Issue
Block a user