--- - 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