--- - name: ⏳ Wait until application container is up ansible.builtin.shell: >- container ps --filter {{ ('label=com.docker.swarm.service.name=' ~ lookup('container_service', application_id, SNIPE_IT_SERVICE)) if DEPLOYMENT_MODE == 'swarm' else ('name=^' ~ lookup('container_service', application_id, SNIPE_IT_SERVICE) ~ '$') }} --format '{% raw %}{{.ID}}{% endraw %}' register: snipeit_app_id retries: 30 delay: 5 until: snipeit_app_id.stdout | length > 0 changed_when: false - name: "⏳ Wait until the Snipe-IT Service is available" uri_retry: url: "{{ SNIPE_IT_URL }}" method: GET return_content: false status_code: 200 register: snipeit_admin_check retries: 30 delay: 5 until: snipeit_admin_check.status == 200 - name: ▶️ Run Snipe-IT migrations (idempotent) ansible.builtin.shell: >- container exec -i -e APP_KEY="{{ SNIPE_IT_APP_KEY }}" -e XDG_CONFIG_HOME=/tmp {{ SNIPE_IT_CONTAINER_ADDRESS }} php artisan migrate --force register: snipeit_migrate changed_when: > ('Migrating:' in snipeit_migrate.stdout) or ('Migrated:' in snipeit_migrate.stdout) failed_when: snipeit_migrate.rc != 0 - name: 🌱 Seed Snipe-IT database (optional, safe to rerun if seeder is idempotent) ansible.builtin.shell: >- container exec -i -e APP_KEY="{{ SNIPE_IT_APP_KEY }}" -e XDG_CONFIG_HOME=/tmp {{ SNIPE_IT_CONTAINER_ADDRESS }} php -d memory_limit={{ lookup('service_memory_mb', application_id, SNIPE_IT_SERVICE, 0.25) }}M artisan db:seed --force register: snipeit_seed changed_when: "'Seeding:' in snipeit_seed.stdout" failed_when: snipeit_seed.rc != 0