From 01bf777f5cb23bcd2a4e4dd9f74c1ea6ded902f8 Mon Sep 17 00:00:00 2001 From: mafyuh Date: Tue, 30 Jul 2024 20:20:04 -0400 Subject: [PATCH] Add ansible/playbooks/deploy-docker.yml --- ansible/playbooks/deploy-docker.yml | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 ansible/playbooks/deploy-docker.yml diff --git a/ansible/playbooks/deploy-docker.yml b/ansible/playbooks/deploy-docker.yml new file mode 100644 index 0000000..da06f3c --- /dev/null +++ b/ansible/playbooks/deploy-docker.yml @@ -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