Add ansible/playbooks/deploy-docker.yml
This commit is contained in:
parent
ee5b607785
commit
01bf777f5c
1 changed files with 33 additions and 0 deletions
33
ansible/playbooks/deploy-docker.yml
Normal file
33
ansible/playbooks/deploy-docker.yml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
---
|
||||||
|
- name: Deploy application
|
||||||
|
hosts: "{{ target_host }}"
|
||||||
|
vars:
|
||||||
|
repo_path: "/home/{{ ansible_user }}/iac/{{ folder }}"
|
||||||
|
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
|
||||||
|
command: docker compose up -d
|
||||||
|
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
|
Loading…
Reference in a new issue