Bläddra i källkod

[timelapse] Add timelapse role

Colin Powell 3 år sedan
förälder
incheckning
4a07183895

+ 5 - 0
ansible/roles/nginx/handlers/main.yml

@@ -0,0 +1,5 @@
+---
+- name: Nginx restarted
+  service:
+    name: nginx
+    state: restarted

+ 25 - 0
ansible/roles/timelapse/files/index.html

@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html class="no-js" lang="en">
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="x-ua-compatible" content="ie=edge">
+    <title>Timelapse Videos</title>
+    <meta name="description" content="">
+    <meta name="viewport" content=
+    "width=device-width, initial-scale=1">
+    <link rel="apple-touch-icon" href="/apple-touch-icon.png">
+    <!-- Place favicon.ico in the root directory -->
+</head>
+<body>
+    <!--[if lt IE 8]>
+            <p class="browserupgrade">
+            You are using an <strong>outdated</strong> browser. Please
+            <a href="http://browsehappy.com/">upgrade your browser</a> to improve
+            your experience.
+            </p>
+        <![endif]-->
+    <a href="east-cam.mp4">East Cam</a><br>
+    <br>
+    <a href="west-cam.mp4">West Cam</a>
+</body>
+</html>

+ 3 - 0
ansible/roles/timelapse/files/nginx.conf

@@ -0,0 +1,3 @@
+location /t {
+    alias /var/www/timelapse;
+}

+ 5 - 0
ansible/roles/timelapse/files/timelapse_go.sh

@@ -0,0 +1,5 @@
+#!/usr/bin/env sh
+cd /media/photos/webcams/east
+ffmpeg -framerate 7 -pattern_type glob -i "east_weather_cam-*.jpg" -y /media/photos/webcams/timelapse/east-cam.mp4
+cd /media/photos/webcams/weather
+ffmpeg -framerate 7 -pattern_type glob -i "weather_cam-*.jpg" -y /media/photos/webcams/timelapse/west-cam.mp4

+ 44 - 0
ansible/roles/timelapse/tasks/main.yml

@@ -0,0 +1,44 @@
+---
+- name: Dependencies installed
+  community.general.pkgng:
+    name: "ffmpeg"
+    state: latest
+
+- name: Timelapse www folder exists
+  file:
+    path: /var/www/timelapse
+    owner: root
+    mode: 0755
+    state: directory
+
+- name: Index html file installed
+  copy:
+    src: "index.html"
+    dest: "/var/www/timelapse/index.html"
+    mode: 0644
+  notify: Nginx restarted
+
+- name: East cam file linked
+  file: src=/media/photos/webcams/timelapse/east-cam.mp4 dest=/var/www/timelapse/east-cam.mp4 state=link
+
+- name: West cam file linked
+  file: src=/media/photos/webcams/timelapse/west-cam.mp4 dest=/var/www/timelapse/west-cam.mp4 state=link
+
+- name: Nginx conf file installed
+  copy:
+    src: "nginx.conf"
+    dest: "/usr/local/etc/nginx/locations/timelapse.conf"
+    mode: 0644
+  notify: Nginx restarted
+
+- name: timelapse_go script installed
+  copy:
+    src: "timelapse_go.sh"
+    dest: /usr/local/bin/timelapse_go
+    mode: 0775
+
+- name: Run timelapse_go every 12 hours
+  ansible.builtin.cron:
+    name: "timelapse_go"
+    hour: "*/12"
+    job: "/usr/local/bin/timelapse_go > /dev/null"