2023-09-25 23:40:09 +00:00
|
|
|
- name: Deploy app
|
|
|
|
hosts: cloud
|
|
|
|
gather_facts: false
|
|
|
|
vars:
|
2023-09-26 00:05:26 +00:00
|
|
|
project: cloud
|
2023-09-25 23:40:09 +00:00
|
|
|
tasks:
|
|
|
|
- name: Wait for connection
|
|
|
|
ansible.builtin.wait_for_connection:
|
|
|
|
timeout: 300
|
2023-09-26 00:05:26 +00:00
|
|
|
- name: Get user
|
|
|
|
ansible.builtin.user:
|
|
|
|
name: debian
|
|
|
|
register: user
|
2023-09-25 23:40:09 +00:00
|
|
|
- name: Copy project
|
|
|
|
ansible.builtin.copy:
|
2023-09-26 00:05:26 +00:00
|
|
|
src: ./{{ project }}
|
|
|
|
dest: "{{ user.home }}"
|
2023-09-26 00:20:36 +00:00
|
|
|
mode: "0744"
|
2023-09-26 00:49:40 +00:00
|
|
|
notify: re-deploy
|
|
|
|
handlers:
|
|
|
|
- name: Restart Docker compose
|
|
|
|
ansible.builtin.shell: |
|
|
|
|
docker compose down
|
|
|
|
docker compose up -d
|
|
|
|
exit 0
|
|
|
|
args:
|
|
|
|
chdir: "{{ user.home }}/{{ project }}"
|
|
|
|
listen: re-deploy
|