61 lines
1.4 KiB
YAML
61 lines
1.4 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: Verify that web and db services are running
|
|
ansible.builtin.assert:
|
|
that:
|
|
- pythonapp.State == 'running'
|
|
vars:
|
|
pythonapp: >-
|
|
{{ compose_output.containers | selectattr("Service","equalto", "movie-db-web") | first }}
|
|
|
|
|