new-site/infra/ansible/roles/app/tasks/main.yml
justin f8cd37ac8c Initial commit — Performance West telecom compliance platform
Includes: API (Express/TypeScript), Astro site, Python workers,
document generators, FCC compliance tools, Canada CRTC formation,
Ansible infrastructure, and deployment scripts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-27 06:54:22 -05:00

52 lines
1.3 KiB
YAML

---
- name: Create API deployment directory
ansible.builtin.file:
path: /opt/performancewest/api
state: directory
owner: "{{ deploy_user }}"
group: "{{ deploy_user }}"
mode: "0755"
- name: Sync API source code
ansible.posix.synchronize:
src: "{{ playbook_dir }}/../../api/"
dest: /opt/performancewest/api/
delete: true
rsync_opts:
- "--exclude=node_modules"
- "--exclude=.env"
- "--exclude=dist"
notify: Rebuild api container
- name: Deploy API .env file
ansible.builtin.template:
src: app.env.j2
dest: /opt/performancewest/api/.env
owner: "{{ deploy_user }}"
group: "{{ deploy_user }}"
mode: "0600"
notify: Rebuild api container
- name: Build API container
ansible.builtin.command:
cmd: docker compose build api
chdir: /opt/performancewest
register: api_build
changed_when: "'writing image' in api_build.stderr"
- name: Start API container
ansible.builtin.command:
cmd: docker compose up -d api
chdir: /opt/performancewest
register: api_start
changed_when: "'Started' in api_start.stderr or 'Creating' in api_start.stderr"
- name: Wait for API health check
ansible.builtin.uri:
url: "http://127.0.0.1:{{ api_port }}/health"
status_code: 200
timeout: 5
register: api_health
retries: 12
delay: 5
until: api_health.status == 200