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
|
|
|
|
shell: git pull
|
|
|
|
args:
|
|
|
|
chdir: "{{ repo_path }}"
|
|
|
|
register: git_pull_output
|
|
|
|
|
|
|
|
- name: Display git pull output
|
|
|
|
debug:
|
|
|
|
var: git_pull_output.stdout_lines
|
|
|
|
|
|
|
|
- name: Restart services
|
2024-10-12 14:04:37 -04:00
|
|
|
command: docker compose up -d --remove-orphans
|
2024-07-30 20:20:04 -04:00
|
|
|
args:
|
|
|
|
chdir: "{{ repo_path }}"
|
|
|
|
register: docker_compose_output
|
|
|
|
|
|
|
|
- name: Display docker output
|
|
|
|
debug:
|
|
|
|
var: docker_compose_output.stdout_lines
|
|
|
|
|
|
|
|
- name: Run Docker Command
|
|
|
|
command: docker ps
|
|
|
|
register: docker_output
|
|
|
|
|
|
|
|
- name: Display Docker Output
|
|
|
|
debug:
|
|
|
|
var: docker_output.stdout_lines
|