Files
MyMovieDB/deploy_remote.yml
jonnybravo 34d57edbb2
Some checks failed
Deploy to ras-dan-01 / deploy (push) Failing after -24s
try
2025-08-26 15:42:20 +02:00

73 lines
1.9 KiB
YAML

---
- name: Deploy and start Movie-DB Application
hosts: all
become: False
gather_facts: True
vars:
project_name: movie-db
install_dir: "/opt/{{ project_name }}"
tasks:
- name: Create installation directory
ansible.builtin.file:
path: "{{ install_dir }}"
state: directory
mode: '0755'
- name: Copy project files
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ install_dir }}/"
owner: root
group: root
mode: '0644'
with_items:
- cert.pem
- docker-compose.yml
- Dockerfile
- genre_list
- imdb_suche.py
- key.pem
- main.py
- moviedb_func.py
- regie_name.csv
- requirements.txt
- name: Copy templates directory
ansible.builtin.copy:
src: templates/
dest: "{{ install_dir }}/templates/"
owner: root
group: root
- name: Start application with Docker Compose
community.docker.docker_compose_v2:
project_src: "{{ install_dir }}"
project_name: "{{ project_name }}"
recreate: always
register: compose_output
- name: Get container info
community.docker.docker_container_info:
filters:
label:
- "com.docker.compose.project={{ project_name }}"
register: container_info
until: container_info.containers | length >= 2 # Assuming 2 services (web and db)
retries: 10
delay: 5
- name: Debug container_info
ansible.builtin.debug:
var: container_info
- name: Verify that web and db services are running
ansible.builtin.assert:
that:
- (container_info.containers | selectattr('name', 'match', '.*-web-.*') | first).State.Running
- (container_info.containers | selectattr('name', 'match', '.*-db-.*') | first).State.Running