Skip to content

Commit 01bf777

Browse files
author
mafyuh
committedJul 31, 2024
Add ansible/playbooks/deploy-docker.yml
1 parent ee5b607 commit 01bf777

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
 

‎ansible/playbooks/deploy-docker.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
- name: Deploy application
3+
hosts: "{{ target_host }}"
4+
vars:
5+
repo_path: "/home/{{ ansible_user }}/iac/{{ folder }}"
6+
tasks:
7+
- name: Ensure the repository is up-to-date
8+
shell: git pull
9+
args:
10+
chdir: "{{ repo_path }}"
11+
register: git_pull_output
12+
13+
- name: Display git pull output
14+
debug:
15+
var: git_pull_output.stdout_lines
16+
17+
- name: Restart services
18+
command: docker compose up -d
19+
args:
20+
chdir: "{{ repo_path }}"
21+
register: docker_compose_output
22+
23+
- name: Display docker output
24+
debug:
25+
var: docker_compose_output.stdout_lines
26+
27+
- name: Run Docker Command
28+
command: docker ps
29+
register: docker_output
30+
31+
- name: Display Docker Output
32+
debug:
33+
var: docker_output.stdout_lines

0 commit comments

Comments
 (0)
Please sign in to comment.