- Add docker-compose.yml with MySQL, Redis, API, and Web services - Add deploy-mixarr.yml Ansible playbook - Services running on ports 3005 (API) and 3006 (Web) - Migrated from alien to replicant VM Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
160 lines
5 KiB
YAML
160 lines
5 KiB
YAML
---
|
|
# Deploy Mixarr Stack to replicant VM
|
|
# Containers: mysql, redis, api, web
|
|
# Target: replicant (192.168.1.80)
|
|
|
|
- name: Deploy Mixarr Stack
|
|
hosts: replicant
|
|
vars:
|
|
appdata_path: /home/maddox/docker/appdata
|
|
service_name: mixarr
|
|
service_dir: "{{ appdata_path }}/{{ service_name }}"
|
|
compose_src: "{{ playbook_dir }}/../compose-files/replicant/{{ service_name }}"
|
|
|
|
tasks:
|
|
# =========================================================================
|
|
# PRE-FLIGHT CHECKS
|
|
# =========================================================================
|
|
- name: Check if .env file exists on control server
|
|
delegate_to: localhost
|
|
ansible.builtin.stat:
|
|
path: "{{ compose_src }}/.env"
|
|
register: env_file
|
|
|
|
- name: Fail if .env is missing
|
|
ansible.builtin.fail:
|
|
msg: |
|
|
.env file not found at {{ compose_src }}/.env
|
|
Copy .env.example to .env and fill in the secrets!
|
|
when: not env_file.stat.exists
|
|
|
|
# =========================================================================
|
|
# DIRECTORY SETUP
|
|
# =========================================================================
|
|
- name: Create mixarr base directory
|
|
ansible.builtin.file:
|
|
path: "{{ service_dir }}"
|
|
state: directory
|
|
owner: maddox
|
|
group: maddox
|
|
mode: '0755'
|
|
|
|
- name: Create mysql_data directory
|
|
ansible.builtin.file:
|
|
path: "{{ service_dir }}/mysql_data"
|
|
state: directory
|
|
owner: maddox
|
|
group: maddox
|
|
mode: '0755'
|
|
|
|
- name: Create redis_data directory
|
|
ansible.builtin.file:
|
|
path: "{{ service_dir }}/redis_data"
|
|
state: directory
|
|
owner: maddox
|
|
group: maddox
|
|
mode: '0755'
|
|
|
|
- name: Create api_data directory
|
|
ansible.builtin.file:
|
|
path: "{{ service_dir }}/api_data"
|
|
state: directory
|
|
owner: maddox
|
|
group: maddox
|
|
mode: '0755'
|
|
|
|
- name: Create web_data directory
|
|
ansible.builtin.file:
|
|
path: "{{ service_dir }}/web_data"
|
|
state: directory
|
|
owner: maddox
|
|
group: maddox
|
|
mode: '0755'
|
|
|
|
# =========================================================================
|
|
# FILE DEPLOYMENT
|
|
# =========================================================================
|
|
- name: Copy docker-compose.yml
|
|
ansible.builtin.copy:
|
|
src: "{{ compose_src }}/docker-compose.yml"
|
|
dest: "{{ service_dir }}/docker-compose.yml"
|
|
owner: maddox
|
|
group: maddox
|
|
mode: '0644'
|
|
|
|
- name: Copy .env file
|
|
ansible.builtin.copy:
|
|
src: "{{ compose_src }}/.env"
|
|
dest: "{{ service_dir }}/.env"
|
|
owner: maddox
|
|
group: maddox
|
|
mode: '0600'
|
|
|
|
# =========================================================================
|
|
# CONTAINER DEPLOYMENT
|
|
# =========================================================================
|
|
- name: Deploy mixarr stack
|
|
community.docker.docker_compose_v2:
|
|
project_src: "{{ service_dir }}"
|
|
state: present
|
|
pull: always
|
|
register: mixarr_result
|
|
|
|
- name: Show deployment status
|
|
ansible.builtin.debug:
|
|
msg: "Mixarr stack deployed: {{ mixarr_result.changed }}"
|
|
|
|
# =========================================================================
|
|
# VERIFICATION
|
|
# =========================================================================
|
|
- name: Wait for MySQL to be ready
|
|
ansible.builtin.command:
|
|
cmd: docker exec mixarr_mysql mysqladmin ping -h localhost
|
|
register: mysql_check
|
|
retries: 30
|
|
delay: 5
|
|
until: mysql_check.rc == 0
|
|
changed_when: false
|
|
|
|
- name: Wait for Redis to be ready
|
|
ansible.builtin.command:
|
|
cmd: docker exec mixarr_redis redis-cli ping
|
|
register: redis_check
|
|
retries: 10
|
|
delay: 3
|
|
until: "'PONG' in redis_check.stdout"
|
|
changed_when: false
|
|
|
|
- name: Wait for API to be healthy (may take up to 2 minutes for Prisma migrations)
|
|
ansible.builtin.uri:
|
|
url: "http://localhost:3005/api/health"
|
|
status_code: 200
|
|
timeout: 10
|
|
register: api_health
|
|
retries: 30
|
|
delay: 10
|
|
until: api_health.status == 200
|
|
ignore_errors: true
|
|
|
|
- name: Wait for Web frontend to be ready
|
|
ansible.builtin.uri:
|
|
url: "http://localhost:3006"
|
|
status_code: [200, 302]
|
|
timeout: 10
|
|
register: web_health
|
|
retries: 15
|
|
delay: 5
|
|
until: web_health.status in [200, 302]
|
|
ignore_errors: true
|
|
|
|
- name: Summary
|
|
ansible.builtin.debug:
|
|
msg:
|
|
- "========================================="
|
|
- "Mixarr Stack Deployment Complete"
|
|
- "========================================="
|
|
- "✅ MySQL: Running on internal network"
|
|
- "✅ Redis: Running on internal network"
|
|
- "✅ API: http://192.168.1.80:3005"
|
|
- "✅ Web: http://192.168.1.80:3006"
|
|
- "========================================="
|