From 95b73daa36b23565a8566f71f9b202d3459b685f Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sun, 25 Jun 2023 09:52:36 -0400 Subject: Initial Commit --- .../services/containers/photoprism/tasks/main.yml | 115 +++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 roles/services/containers/photoprism/tasks/main.yml (limited to 'roles/services/containers/photoprism/tasks') diff --git a/roles/services/containers/photoprism/tasks/main.yml b/roles/services/containers/photoprism/tasks/main.yml new file mode 100644 index 0000000..e6ac544 --- /dev/null +++ b/roles/services/containers/photoprism/tasks/main.yml @@ -0,0 +1,115 @@ +- name: set image fact + set_fact: + image: photoprism/photoprism:221118-jammy + +- name: set other facts + vars: + array: "{{ image.split('/', 1) }}" + set_fact: + repo_tag: "{{ array.1 }}" + custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}" + +- name: create photoprism directory + file: + path: "{{ docker_home }}/photoprism" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: login to docker registry + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_login: + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + registry_url: "{{ docker_registry_url }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + +- name: get photoprism image + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_image: + name: "{{ image }}" + repository: "{{ custom_registry }}/{{ repo_tag }}" + push: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + source: pull + force_source: yes + +- name: create photoprism data directory + file: + path: "{{ docker_home }}/photoprism/data" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create photoprism photos directory + file: + path: "{{ docker_home }}/photoprism/photos" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create photoprism docker network + docker_network: + name: "{{ photoprism_network_name }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + driver: bridge + ipam_config: + - subnet: "{{ photoprism_subnet }}" + gateway: "{{ photoprism_gateway }}" + +- name: create and deploy photoprism container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "photoprism" + hostname: "photoprism" + image: "{{ custom_registry }}/{{ repo_tag }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + networks: + - name: "{{ photoprism_network_name }}" + ipv4_address: "{{ photoprism_ipv4 }}" + ports: + - "127.0.0.1:{{ photoprism_external_port }}:2342" + state: 'started' + recreate: yes + restart_policy: unless-stopped + volumes: + - "{{ docker_home }}/photoprism/photos:/photoprism/originals" + - "{{ docker_home }}/photoprism/data:/photoprism/storage" + env: + "PHOTOPRISM_ADMIN_USER": "{{ photoprism_admin_user }}" + "PHOTOPRISM_ADMIN_PASSWORD": "{{ photoprism_admin_password }}" + "PHOTOPRISM_AUTH_MODE": "{{ photoprism_auth_mode }}" + "PHOTOPRISM_SITE_URL": "{{ photoprism_site_url }}" + "PHOTOPRISM_DATABASE_DRIVER": "sqlite" + "PHOTOPRISM_DISABLE_PLACES": "true" + +- name: deploy nginx configuration + notify: restart nginx + register: nginx_config + copy: + src: "{{ photoprism_nginx_config }}" + dest: /etc/nginx/sites-available/photoprism.conf + owner: root + group: root + mode: '0644' + +- name: symlink site + file: + src: /etc/nginx/sites-available/photoprism.conf + dest: /etc/nginx/sites-enabled/photoprism.conf + owner: root + group: root + state: link -- cgit v1.2.3