diff --git a/roles/photos/tasks/main.yaml b/roles/photos/tasks/main.yaml index 12af023..64ac2da 100644 --- a/roles/photos/tasks/main.yaml +++ b/roles/photos/tasks/main.yaml @@ -1,8 +1,8 @@ --- -- tags: photos_gallery +- tags: photos-gallery import_tasks: photo-gallery.yaml -- tags: photos_mqtt +- tags: photos-mqtt import_tasks: photos2mqtt.yaml - tags: bambulab-fetch diff --git a/roles/photos/tasks/photo-gallery.yaml b/roles/photos/tasks/photo-gallery.yaml index 946b400..675c844 100644 --- a/roles/photos/tasks/photo-gallery.yaml +++ b/roles/photos/tasks/photo-gallery.yaml @@ -1,4 +1,8 @@ --- +- name: Install dependencies + apt: + name: [ nodejs, npm, imagemagick, graphicsmagick ] + - name: Clone source git: repo: https://github.com/bitlair/photo-gallery.git @@ -7,6 +11,15 @@ accept_hostkey: yes notify: restart photo-gallery +- name: Install photo-gallery config file + template: + src: photo-gallery-config.json + dest: /opt/photo-gallery/config.json + owner: root + group: root + mode: 0644 + notify: restart photo-gallery + - name: Install photo-gallery service file template: src: photo-gallery.service diff --git a/roles/photos/templates/bambulab-fetch.timer b/roles/photos/templates/bambulab-fetch.timer index 024b44a..472a8b1 100644 --- a/roles/photos/templates/bambulab-fetch.timer +++ b/roles/photos/templates/bambulab-fetch.timer @@ -1,3 +1,5 @@ +# {{ ansible_managed }} + [Unit] Description=Run every 15 minutes diff --git a/roles/photos/templates/photo-gallery-config.json b/roles/photos/templates/photo-gallery-config.json new file mode 100644 index 0000000..1e16248 --- /dev/null +++ b/roles/photos/templates/photo-gallery-config.json @@ -0,0 +1,12 @@ +{ + "listen": { + "port": 4567 + }, + "pictureFolder": "{{ photos_path }}", + "thumbnails": { + "height": 300, + "quality": 60 + }, + "pathPrefix": "/fotos", + "paginationThreshold": 100 +} diff --git a/roles/photos/templates/photo-gallery.service b/roles/photos/templates/photo-gallery.service index df38be5..2919403 100644 --- a/roles/photos/templates/photo-gallery.service +++ b/roles/photos/templates/photo-gallery.service @@ -1,4 +1,4 @@ -# Managed by Ansible +# {{ ansible_managed }} [Unit] Description=Gallery service @@ -7,7 +7,7 @@ After=network.target [Service] ExecStart=/usr/bin/node /opt/photo-gallery/server.js Restart=always -RestartSec=3 +RestartSec=10 [Install] WantedBy=multi-user.target diff --git a/roles/photos/templates/photos2mqtt.pl b/roles/photos/templates/photos2mqtt.pl index 87a42f5..eee45ea 100644 --- a/roles/photos/templates/photos2mqtt.pl +++ b/roles/photos/templates/photos2mqtt.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Managed by Ansible +# {{ ansible_managed }} use strict; use Net::MQTT::Simple; diff --git a/roles/photos/templates/photos2mqtt.service b/roles/photos/templates/photos2mqtt.service index dbdb130..c5c779e 100644 --- a/roles/photos/templates/photos2mqtt.service +++ b/roles/photos/templates/photos2mqtt.service @@ -1,4 +1,4 @@ -# Managed by Ansible +# {{ ansible_managed }} [Unit] Description=Photos to MQTT