45 lines
1.4 KiB
YAML
45 lines
1.4 KiB
YAML
- name: Deploy app
|
|
hosts: photos
|
|
gather_facts: false
|
|
vars:
|
|
app: immich
|
|
tasks:
|
|
- name: Wait for connection
|
|
ansible.builtin.wait_for_connection:
|
|
timeout: 300
|
|
|
|
- name: Check if project exists
|
|
ansible.builtin.stat:
|
|
path: "$HOME/{{ app }}"
|
|
register: project
|
|
- name: Docker compose down
|
|
when: project.stat.exists
|
|
community.docker.docker_compose_v2:
|
|
project_src: "$HOME/{{ app }}"
|
|
state: absent
|
|
- name: Copy project
|
|
ansible.builtin.copy:
|
|
src: "./{{ app }}"
|
|
dest: "$HOME"
|
|
mode: "0744"
|
|
|
|
- name: Replace Typesense secret
|
|
ansible.builtin.replace:
|
|
path: "{{ user.home }}/{{ app }}/.env"
|
|
regexp: "TYPESENSE_API_KEY_VALUE"
|
|
replace:
|
|
"{{ lookup('infisical.vault.read_secrets', project_id=infisical_project, env_slug='prod',
|
|
path='/photos', secret_name='TYPESENSE_API_KEY')['value'] }}"
|
|
- name: Replace DB secret
|
|
ansible.builtin.replace:
|
|
path: "{{ user.home }}/{{ app }}/.env"
|
|
regexp: "DB_PASSWORD_VALUE"
|
|
replace:
|
|
"{{ lookup('infisical.vault.read_secrets', project_id=infisical_project, env_slug='prod',
|
|
path='/photos', secret_name='DB_PASSWORD')['value'] }}"
|
|
|
|
- name: Docker compose up
|
|
community.docker.docker_compose_v2:
|
|
pull: always
|
|
project_src: "$HOME/{{ app }}"
|