This repository has been archived on 2024-07-30. You can view files and clone it, but cannot push or open issues or pull requests.
ansible-playbooks/deploy.yml

34 lines
808 B
YAML
Raw Normal View History

2024-06-09 15:21:52 -04:00
---
- name: Deploy application
hosts: "{{ target_host }}"
vars:
2024-06-09 19:36:01 -04:00
repo_path: "/home/{{ ansible_user }}/Auto-Homelab/{{ folder }}"
2024-06-09 15:21:52 -04:00
tasks:
- name: Ensure the repository is up-to-date
shell: git pull
args:
chdir: "{{ repo_path }}"
2024-06-09 21:56:59 -04:00
register: git_pull_output
- name: Display git pull output
debug:
var: git_pull_output.stdout_lines
2024-06-09 15:21:52 -04:00
- name: Restart services
2024-06-09 19:36:01 -04:00
command: docker compose up -d
2024-06-09 15:21:52 -04:00
args:
chdir: "{{ repo_path }}"
2024-06-09 22:49:54 -04:00
register: docker_compose_output
2024-06-09 21:56:59 -04:00
- name: Display docker output
2024-06-09 22:49:54 -04:00
debug:
var: docker_compose_output.stdout_lines
- name: Run Docker Command
command: docker ps
register: docker_output
- name: Display Docker Output
2024-06-09 21:56:59 -04:00
debug:
var: docker_output.stdout_lines