From 265f3b859e362a675f32c7b5909de3024c36c4e7 Mon Sep 17 00:00:00 2001 From: Bastian de Byl Date: Sat, 2 Oct 2021 17:01:42 -0400 Subject: [PATCH] CU-1newj99 Added motion camera deployment to home server --- ansible/deploy_home.yml | 2 + ansible/roles/motion/defaults/main.yml | 6 + ansible/roles/motion/handlers/main.yml | 6 + ansible/roles/motion/meta/main.yml | 3 + ansible/roles/motion/tasks/deps.yml | 7 + ansible/roles/motion/tasks/main.yml | 3 + ansible/roles/motion/tasks/motion.yml | 26 +++ ansible/roles/motion/templates/motion.conf.j2 | 171 ++++++++++++++++++ ansible/vars/vault.yml | Bin 2645 -> 3098 bytes 9 files changed, 224 insertions(+) create mode 100644 ansible/roles/motion/defaults/main.yml create mode 100644 ansible/roles/motion/handlers/main.yml create mode 100644 ansible/roles/motion/meta/main.yml create mode 100644 ansible/roles/motion/tasks/deps.yml create mode 100644 ansible/roles/motion/tasks/main.yml create mode 100644 ansible/roles/motion/tasks/motion.yml create mode 100644 ansible/roles/motion/templates/motion.conf.j2 diff --git a/ansible/deploy_home.yml b/ansible/deploy_home.yml index 689a69f..57b2fb5 100644 --- a/ansible/deploy_home.yml +++ b/ansible/deploy_home.yml @@ -11,3 +11,5 @@ - role: drone - role: nfs tags: nfs + - role: motion + tags: motion diff --git a/ansible/roles/motion/defaults/main.yml b/ansible/roles/motion/defaults/main.yml new file mode 100644 index 0000000..df8a412 --- /dev/null +++ b/ansible/roles/motion/defaults/main.yml @@ -0,0 +1,6 @@ +--- +deps: [ + motion +] + +motion_target_dir: "{{ nfs_root }}/motion" diff --git a/ansible/roles/motion/handlers/main.yml b/ansible/roles/motion/handlers/main.yml new file mode 100644 index 0000000..6c9fc00 --- /dev/null +++ b/ansible/roles/motion/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: restart_motion + become: true + service: + name: motion + state: restarted diff --git a/ansible/roles/motion/meta/main.yml b/ansible/roles/motion/meta/main.yml new file mode 100644 index 0000000..d8bd180 --- /dev/null +++ b/ansible/roles/motion/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - role: nfs diff --git a/ansible/roles/motion/tasks/deps.yml b/ansible/roles/motion/tasks/deps.yml new file mode 100644 index 0000000..3eab821 --- /dev/null +++ b/ansible/roles/motion/tasks/deps.yml @@ -0,0 +1,7 @@ +--- +- name: install motion + become: true + pacman: + name: "{{ deps }}" + state: present + tags: deps diff --git a/ansible/roles/motion/tasks/main.yml b/ansible/roles/motion/tasks/main.yml new file mode 100644 index 0000000..be6c254 --- /dev/null +++ b/ansible/roles/motion/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- import_tasks: deps.yml +- import_tasks: motion.yml diff --git a/ansible/roles/motion/tasks/motion.yml b/ansible/roles/motion/tasks/motion.yml new file mode 100644 index 0000000..ad81238 --- /dev/null +++ b/ansible/roles/motion/tasks/motion.yml @@ -0,0 +1,26 @@ +--- +- name: create motion directory + become: true + file: + path: "{{ motion_target_dir }}" + state: directory + owner: "{{ nfs_user }}" + group: "{{ nfs_group }}" + mode: 0755 + +- name: template motion config + become: true + template: + src: templates/motion.conf.j2 + dest: /etc/motion/motion.conf + mode: 0644 + backup: true + notify: + - restart_motion + +- name: enable (now) motion.service + become: true + service: + name: motion.service + state: started + enabled: true diff --git a/ansible/roles/motion/templates/motion.conf.j2 b/ansible/roles/motion/templates/motion.conf.j2 new file mode 100644 index 0000000..993d09b --- /dev/null +++ b/ansible/roles/motion/templates/motion.conf.j2 @@ -0,0 +1,171 @@ +# Rename this distribution example file to motion.conf +# +# This config file was generated by motion 4.3.2 +# Documentation: /usr/share/doc/motion/motion_guide.html +# +# This file contains only the basic configuration options to get a +# system working. There are many more options available. Please +# consult the documentation for the complete list of all options. +# + +############################################################ +# System control configuration parameters +############################################################ + +# Start in daemon (background) mode and release terminal. +daemon on + +# Start in Setup-Mode, daemon disabled. +setup_mode off + +# File to store the process ID. +; pid_file value + +# File to write logs messages into. If not defined stderr and syslog is used. +; log_file value + +# Level of log messages [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). +log_level 6 + +# Target directory for pictures, snapshots and movies +target_dir {{ motion_target_dir }} + +# Video device (e.g. /dev/video0) to be used for capturing. +; videodevice /dev/video0 + +# Parameters to control video device. See motion_guide.html +; vid_control_params value + +# The full URL of the network camera stream. +netcam_url rtsp://{{ motion_user }}:{{ motion_pass }}@{{ motion_hostname }}:{{ motion_port }}/mpeg4/media.amp + +# Name of mmal camera (e.g. vc.ril.camera for pi camera). +; mmalcam_name value + +# Camera control parameters (see raspivid/raspistill tool documentation) +; mmalcam_control_params value + +############################################################ +# Image Processing configuration parameters +############################################################ + +# Image width in pixels. +width 3840 + +# Image height in pixels. +height 2160 + +# Maximum number of frames to be captured per second. +framerate 20 + +# Text to be overlayed in the lower left corner of images +text_left NatureCam + +# Text to be overlayed in the lower right corner of images. +text_right %Y-%m-%d\n%T-%q + +############################################################ +# Motion detection configuration parameters +############################################################ + +# Always save pictures and movies even if there was no motion. +emulate_motion off + +# Threshold for number of changed pixels that triggers motion. +threshold 165900 + +# Noise threshold for the motion detection. +; noise_level 32 + +# Despeckle the image using (E/e)rode or (D/d)ilate or (l)abel. +despeckle_filter EedDl + +# Number of images that must contain motion to trigger an event. +minimum_motion_frames 1 + +# Gap in seconds of no motion detected that triggers the end of an event. +event_gap 60 + +# The number of pre-captured (buffered) pictures from before motion. +pre_capture 3 + +# Number of frames to capture after motion is no longer detected. +post_capture 0 + +############################################################ +# Script execution configuration parameters +############################################################ + +# Command to be executed when an event starts. +; on_event_start value + +# Command to be executed when an event ends. +; on_event_end value + +# Command to be executed when a movie file is closed. +; on_movie_end value + +############################################################ +# Picture output configuration parameters +############################################################ + +# Output pictures when motion is detected +picture_output off + +# File name(without extension) for pictures relative to target directory +picture_filename %Y%m%d%H%M%S-%q + +############################################################ +# Movie output configuration parameters +############################################################ + +# Create movies of motion events. +movie_output on + +# Maximum length of movie in seconds. +movie_max_time 60 + +# The encoding quality of the movie. (0=use bitrate. 1=worst quality, 100=best) +movie_quality 45 + +# Container/Codec to used for the movie. See motion_guide.html +movie_codec mkv + +# File name(without extension) for movies relative to target directory +movie_filename %t-%v-%Y%m%d%H%M%S + +############################################################ +# Webcontrol configuration parameters +############################################################ + +# Port number used for the webcontrol. +webcontrol_port 8080 + +# Restrict webcontrol connections to the localhost. +webcontrol_localhost on + +# Type of configuration options to allow via the webcontrol. +webcontrol_parms 0 + +############################################################ +# Live stream configuration parameters +############################################################ + +# The port number for the live stream. +stream_port 8081 + +# Restrict stream connections to the localhost. +stream_localhost on + +############################################################## +# Camera config files - One for each camera. +############################################################## +; camera /usr/etc/motion/camera1.conf +; camera /usr/etc/motion/camera2.conf +; camera /usr/etc/motion/camera3.conf +; camera /usr/etc/motion/camera4.conf + +############################################################## +# Directory to read '.conf' files for cameras. +############################################################## +; camera_dir /usr/etc/motion/conf.d diff --git a/ansible/vars/vault.yml b/ansible/vars/vault.yml index 6993c23eda7f18329bafeca8162a1d11998edead..3c3bca973558e1bf9fb676585d735743d5578793 100644 GIT binary patch literal 3098 zcmV+#4CV6xM@dveQdv+`0LGP_=M~hI?b8r*Wc!$^YeTHg!b?{{(HerVo^@bZpst4q zOgdrF3;zp6RJHOlDfK$GZ`rNAQ`fJNHSNc?<7VKH0*x7R&g9Q|J=T8uD#2p-sX*4- z*BvhqCM!;EmfAZ*Dgof!lp9q<<+|-l>iPnpKjlzBm$BYN@Tm$lUCH2Ho_z;AtV~f% zwS3LnuNyI5?|CvNKq`6la->Z~j=3}~=bZgBIEjvJv7?`qp;bqMVmcN1-|Qg6tqaSmsoduOO|N6gQRIu5swnnSfe2LJlYl7FFrTA&Fu~Ez_J%Ibir;B62BP z_Dm6XF{jv<1EUwu>q?Qn=)+hsWlR=$FL-Q$qWYMn+a{btbQD*=s1=uvCF=BXegyOlcm3% zqgyguXc}l^dyp8Q2H-_;34E}66=mb!plJ>>%hxF;dhFxZnYq3U{fM^XQ|S$g2y{6e z)6tqb%@Fiu>mc=Nn=%UTb8(~RqUN1`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