aboutsummaryrefslogtreecommitdiff
path: root/roles/services/containers/photoprism
diff options
context:
space:
mode:
authorSam Chudnick <sam@chudnick.com>2023-06-25 09:52:36 -0400
committerSam Chudnick <sam@chudnick.com>2023-06-25 09:52:36 -0400
commit95b73daa36b23565a8566f71f9b202d3459b685f (patch)
treecb17b021be70e7868d0ec235a761f0ecdc80f3f2 /roles/services/containers/photoprism
Initial CommitHEADmaster
Diffstat (limited to 'roles/services/containers/photoprism')
-rw-r--r--roles/services/containers/photoprism/defaults/main.yml10
-rw-r--r--roles/services/containers/photoprism/handlers/main.yml4
-rw-r--r--roles/services/containers/photoprism/tasks/main.yml115
3 files changed, 129 insertions, 0 deletions
diff --git a/roles/services/containers/photoprism/defaults/main.yml b/roles/services/containers/photoprism/defaults/main.yml
new file mode 100644
index 0000000..ceca8c3
--- /dev/null
+++ b/roles/services/containers/photoprism/defaults/main.yml
@@ -0,0 +1,10 @@
1photoprism_admin_user: "admin"
2photoprism_auth_mode: "password"
3photoprism_site_url: "https://photos.chudnick.com"
4photoprism_external_port: 2342
5photoprism_nginx_config: data/photoprism/photoprism.conf
6photoprism_network_name: photoprism_net
7photoprism_subnet: 172.25.15.0/24
8photoprism_gateway: 172.25.15.1
9photoprism_ipv4: 172.25.15.2
10nextcloud_external_port: 8006
diff --git a/roles/services/containers/photoprism/handlers/main.yml b/roles/services/containers/photoprism/handlers/main.yml
new file mode 100644
index 0000000..5463835
--- /dev/null
+++ b/roles/services/containers/photoprism/handlers/main.yml
@@ -0,0 +1,4 @@
1- name: restart nginx
2 service:
3 name: nginx
4 state: restarted
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 @@
1- name: set image fact
2 set_fact:
3 image: photoprism/photoprism:221118-jammy
4
5- name: set other facts
6 vars:
7 array: "{{ image.split('/', 1) }}"
8 set_fact:
9 repo_tag: "{{ array.1 }}"
10 custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}"
11
12- name: create photoprism directory
13 file:
14 path: "{{ docker_home }}/photoprism"
15 state: directory
16 owner: "{{ docker_username }}"
17 group: "{{ docker_username }}"
18 mode: '0755'
19
20- name: login to docker registry
21 become: yes
22 become_user: "{{ docker_username }}"
23 environment:
24 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
25 docker_login:
26 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
27 registry_url: "{{ docker_registry_url }}"
28 username: "{{ docker_registry_username }}"
29 password: "{{ docker_registry_password }}"
30
31- name: get photoprism image
32 become: yes
33 become_user: "{{ docker_username }}"
34 environment:
35 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
36 docker_image:
37 name: "{{ image }}"
38 repository: "{{ custom_registry }}/{{ repo_tag }}"
39 push: yes
40 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
41 source: pull
42 force_source: yes
43
44- name: create photoprism data directory
45 file:
46 path: "{{ docker_home }}/photoprism/data"
47 state: directory
48 owner: "{{ docker_username }}"
49 group: "{{ docker_username }}"
50 mode: '0755'
51
52- name: create photoprism photos directory
53 file:
54 path: "{{ docker_home }}/photoprism/photos"
55 state: directory
56 owner: "{{ docker_username }}"
57 group: "{{ docker_username }}"
58 mode: '0755'
59
60- name: create photoprism docker network
61 docker_network:
62 name: "{{ photoprism_network_name }}"
63 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
64 driver: bridge
65 ipam_config:
66 - subnet: "{{ photoprism_subnet }}"
67 gateway: "{{ photoprism_gateway }}"
68
69- name: create and deploy photoprism container
70 become: yes
71 become_user: "{{ docker_username }}"
72 environment:
73 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
74 docker_container:
75 name: "photoprism"
76 hostname: "photoprism"
77 image: "{{ custom_registry }}/{{ repo_tag }}"
78 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
79 purge_networks: yes
80 networks:
81 - name: "{{ photoprism_network_name }}"
82 ipv4_address: "{{ photoprism_ipv4 }}"
83 ports:
84 - "127.0.0.1:{{ photoprism_external_port }}:2342"
85 state: 'started'
86 recreate: yes
87 restart_policy: unless-stopped
88 volumes:
89 - "{{ docker_home }}/photoprism/photos:/photoprism/originals"
90 - "{{ docker_home }}/photoprism/data:/photoprism/storage"
91 env:
92 "PHOTOPRISM_ADMIN_USER": "{{ photoprism_admin_user }}"
93 "PHOTOPRISM_ADMIN_PASSWORD": "{{ photoprism_admin_password }}"
94 "PHOTOPRISM_AUTH_MODE": "{{ photoprism_auth_mode }}"
95 "PHOTOPRISM_SITE_URL": "{{ photoprism_site_url }}"
96 "PHOTOPRISM_DATABASE_DRIVER": "sqlite"
97 "PHOTOPRISM_DISABLE_PLACES": "true"
98
99- name: deploy nginx configuration
100 notify: restart nginx
101 register: nginx_config
102 copy:
103 src: "{{ photoprism_nginx_config }}"
104 dest: /etc/nginx/sites-available/photoprism.conf
105 owner: root
106 group: root
107 mode: '0644'
108
109- name: symlink site
110 file:
111 src: /etc/nginx/sites-available/photoprism.conf
112 dest: /etc/nginx/sites-enabled/photoprism.conf
113 owner: root
114 group: root
115 state: link