2024-07-30 20:20:04 -04:00
|
|
|
---
|
|
|
|
- name: Deploy application
|
|
|
|
hosts: "{{ target_host }}"
|
|
|
|
vars:
|
2024-07-30 20:33:00 -04:00
|
|
|
repo_path: "/home/{{ ansible_user }}/iac/docker/{{ folder }}"
|
2024-07-30 20:20:04 -04:00
|
|
|
tasks:
|
|
|
|
- name: Ensure the repository is up-to-date
|
2024-12-19 21:44:47 -05:00
|
|
|
ansible.builtin.shell: git pull
|
2024-07-30 20:20:04 -04:00
|
|
|
args:
|
|
|
|
chdir: "{{ repo_path }}"
|
|
|
|
register: git_pull_output
|
|
|
|
|
|
|
|
- name: Display git pull output
|
2024-12-19 21:44:47 -05:00
|
|
|
ansible.builtin.debug:
|
2024-07-30 20:20:04 -04:00
|
|
|
var: git_pull_output.stdout_lines
|
|
|
|
|
2024-12-19 21:44:47 -05:00
|
|
|
- name: Restart services using Docker Compose
|
|
|
|
community.docker.docker_compose_v2:
|
|
|
|
project_src: "{{ repo_path }}"
|
|
|
|
state: present
|
|
|
|
remove_orphans: true
|
2024-07-30 20:20:04 -04:00
|
|
|
register: docker_compose_output
|
|
|
|
|
2024-12-19 21:44:47 -05:00
|
|
|
- name: Display docker compose output
|
|
|
|
ansible.builtin.debug:
|
|
|
|
var: docker_compose_output
|