2023-09-26 19:50:11 +00:00
|
|
|
- name: Deploy app
|
2023-09-28 12:44:24 +00:00
|
|
|
hosts: photos
|
2023-09-26 19:50:11 +00:00
|
|
|
gather_facts: false
|
|
|
|
vars:
|
|
|
|
app: immich
|
|
|
|
tasks:
|
|
|
|
- name: Wait for connection
|
|
|
|
ansible.builtin.wait_for_connection:
|
|
|
|
timeout: 300
|
|
|
|
- name: Get user
|
|
|
|
ansible.builtin.user:
|
|
|
|
name: debian
|
|
|
|
register: user
|
2023-09-27 21:18:49 +00:00
|
|
|
- name: Docker compose down
|
|
|
|
ansible.builtin.command: docker compose down
|
|
|
|
args:
|
|
|
|
chdir: "{{ user.home }}/{{ app }}"
|
|
|
|
ignore_errors: true
|
|
|
|
- name: Copy project
|
|
|
|
ansible.builtin.copy:
|
2023-09-27 21:31:32 +00:00
|
|
|
src: "./{{ app }}"
|
2023-09-27 21:18:49 +00:00
|
|
|
dest: "{{ user.home }}"
|
|
|
|
mode: "0744"
|
2023-09-28 12:44:24 +00:00
|
|
|
- name: Replace Typesense secret
|
|
|
|
ansible.builtin.replace:
|
|
|
|
path: "{{ user.home }}/{{ app }}/.env"
|
|
|
|
regexp: "TYPESENSE_API_KEY_VALUE"
|
2024-01-04 16:03:11 +00:00
|
|
|
replace: "{{ lookup('infisical.vault.read_secrets', env_slug='prod', path='/photos', secret_name='TYPESENSE_API_KEY')['value'] }}"
|
2023-09-28 12:44:24 +00:00
|
|
|
- name: Replace DB secret
|
|
|
|
ansible.builtin.replace:
|
|
|
|
path: "{{ user.home }}/{{ app }}/.env"
|
|
|
|
regexp: "DB_PASSWORD_VALUE"
|
2024-01-04 16:03:11 +00:00
|
|
|
replace: "{{ lookup('infisical.vault.read_secrets', env_slug='prod', path='/photos', secret_name='DB_PASSWORD')['value'] }}"
|
2023-09-27 21:18:49 +00:00
|
|
|
- name: Docker compose up -d
|
|
|
|
ansible.builtin.command: docker compose up -d
|
|
|
|
args:
|
|
|
|
chdir: "{{ user.home }}/{{ app }}"
|