--- - name: Check .env File and Environment Variables hosts: production gather_facts: no become: no vars: application_stack_dest: "{{ app_stack_path | default(stacks_base_path + '/production') }}" application_compose_suffix: "production.yml" tasks: - name: Check if .env file exists stat: path: "{{ application_stack_dest }}/.env" delegate_to: "{{ inventory_hostname }}" register: env_file_exists - name: Display .env file status debug: msg: ".env file exists: {{ env_file_exists.stat.exists }}" - name: Read .env file content (first 50 lines) shell: | head -50 {{ application_stack_dest }}/.env 2>&1 || echo "FILE_NOT_FOUND" delegate_to: "{{ inventory_hostname }}" register: env_file_content changed_when: false when: env_file_exists.stat.exists - name: Display .env file content debug: msg: | .env file content: {{ env_file_content.stdout }} - name: Check for DB_DATABASE in .env file shell: | grep -E "^DB_DATABASE=|^DB_NAME=" {{ application_stack_dest }}/.env 2>&1 || echo "NOT_FOUND" delegate_to: "{{ inventory_hostname }}" register: db_database_check changed_when: false when: env_file_exists.stat.exists - name: Display DB_DATABASE check debug: msg: "DB_DATABASE in .env: {{ db_database_check.stdout }}" - name: Check environment variables in queue-worker container shell: | docker compose -f {{ application_stack_dest }}/docker-compose.base.yml -f {{ application_stack_dest }}/docker-compose.{{ application_compose_suffix }} exec -T queue-worker env | grep -E "^DB_" | sort register: queue_worker_env changed_when: false failed_when: false ignore_errors: yes - name: Display queue-worker environment variables debug: msg: | Queue-Worker DB Environment Variables: {{ queue_worker_env.stdout | default('CONTAINER_NOT_RUNNING') }} - name: Check docker-compose project directory shell: | cd {{ application_stack_dest }} && pwd delegate_to: "{{ inventory_hostname }}" register: project_dir changed_when: false - name: Display project directory debug: msg: "Docker Compose project directory: {{ project_dir.stdout }}" - name: Check if .env file is in project directory shell: | test -f {{ application_stack_dest }}/.env && echo "EXISTS" || echo "MISSING" delegate_to: "{{ inventory_hostname }}" register: env_in_project_dir changed_when: false - name: Display .env file location check debug: msg: ".env file in project directory: {{ env_in_project_dir.stdout }}"