2023-09-26 19:50:11 +00:00
|
|
|
- name: Deploy app
|
2024-02-29 22:53:28 +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
|
2024-12-14 01:33:59 +00:00
|
|
|
- name: Check if project exists
|
|
|
|
ansible.builtin.stat:
|
|
|
|
path: "$HOME/{{ app }}"
|
|
|
|
register: project
|
2023-09-27 21:18:49 +00:00
|
|
|
- name: Docker compose down
|
2024-12-14 01:33:59 +00:00
|
|
|
when: project.stat.exists
|
|
|
|
community.docker.docker_compose_v2:
|
|
|
|
project_src: "$HOME/{{ app }}"
|
|
|
|
state: absent
|
2023-09-27 21:18:49 +00:00
|
|
|
- name: Copy project
|
|
|
|
ansible.builtin.copy:
|
2023-09-27 21:31:32 +00:00
|
|
|
src: "./{{ app }}"
|
2024-12-14 01:33:59 +00:00
|
|
|
dest: "$HOME"
|
2023-09-27 21:18:49 +00:00
|
|
|
mode: "0744"
|
2024-12-14 01:33:59 +00:00
|
|
|
|
2023-09-28 12:44:24 +00:00
|
|
|
- name: Replace Typesense secret
|
|
|
|
ansible.builtin.replace:
|
2024-12-14 01:38:03 +00:00
|
|
|
path: "$HOME/{{ app }}/.env"
|
2023-09-28 12:44:24 +00:00
|
|
|
regexp: "TYPESENSE_API_KEY_VALUE"
|
2024-06-21 23:44:08 +00:00
|
|
|
replace:
|
|
|
|
"{{ lookup('infisical.vault.read_secrets', project_id=infisical_project, 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:
|
2024-12-14 01:38:03 +00:00
|
|
|
path: "$HOME/{{ app }}/.env"
|
2023-09-28 12:44:24 +00:00
|
|
|
regexp: "DB_PASSWORD_VALUE"
|
2024-06-21 23:44:08 +00:00
|
|
|
replace:
|
|
|
|
"{{ lookup('infisical.vault.read_secrets', project_id=infisical_project, env_slug='prod',
|
|
|
|
path='/photos', secret_name='DB_PASSWORD')['value'] }}"
|
2024-12-14 01:33:59 +00:00
|
|
|
|
|
|
|
- name: Docker compose up
|
|
|
|
community.docker.docker_compose_v2:
|
|
|
|
pull: always
|
|
|
|
project_src: "$HOME/{{ app }}"
|