All checks were successful
Deploy to ras-dan-01 / deploy (push) Successful in -24s
68 lines
1.8 KiB
YAML
68 lines
1.8 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_host_info:
|
|
containers: true
|
|
containers_all: true
|
|
register: host_info
|
|
until: (host_info.containers | selectattr('Names', 'match', '.*-web') | list | length) >= 1 and (host_info.containers | selectattr('Names', 'match', '.*-db') | list | length) >= 1
|
|
retries: 10
|
|
delay: 5
|
|
|
|
- name: Verify that web and db services are running
|
|
ansible.builtin.assert:
|
|
that:
|
|
- (host_info.containers | selectattr('Names', 'match', '.*-web') | first).Status is search('Up')
|
|
- (host_info.containers | selectattr('Names', 'match', '.*-db') | first).Status is search('Up')
|
|
|
|
|