borisskert / ansible-motion

Installs motion as a systemd-managed docker container.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ansible-motion

Installs motion as a systemd-managed docker container.

Requirements

CPU architecture:

  • x86_64 / amd64
  • armv7l / armhf
  • aarch64 / arm64

Operating systems:

  • Ubuntu:
    • 16.04 (xenial)
    • 18.04 (bionic)
    • 20.04 (focal)
  • Debian
    • 9 (stretch)
    • 10 (buster)

Role requirements

  • python-docker package

What this role does

  • Create volume directories
  • Setup motion config
  • Setup motion cam configs
  • Setup Dockerfile and build docker image
  • Setup systemd unit file
  • Restart/start systemd service

Role parameters

Variable Type Mandatory? Default Description
motion_config_volume text yes Where the motion config will be stored
motion_log_volume text yes Where the motion logs will be stored
motion_data_volume text yes Where the motion data (like records) will be stored
motion_cameras array of motion_camera no [] The separate camera configurations

motion_camera definition

Variable Type Mandatory? Default Description
name text yes Configured camera name; Used for the configuration file name
stream_port integer yes The configured cam stream port
target_dir text no The directory to store the records of this cam
options Map of text key/values no [] The motion camera options Read the docs!

Usage

Add to requirements.yml

- name: install-motion
  src: https://github.com/borisskert/ansible-motion.git
  scm: git

example playbook.yml

---
- hosts: all
  become: true

  roles:
    - role: ansible-motion
      motion_config_volume: /srv/motion/config
      motion_log_volume: /srv/motion/log
      motion_data_volume: /srv/motion/data
      motion_cameras:
       - name: usb_cam
         stream_port: 8081
         target_dir: usb_cam
         options:
           videodevice: /dev/video0
           input: -1
           text_left: USB CAM
           width: 1920
           height: 1080
           framerate: 60
           ffmpeg_video_codec: mpeg4
       - name: video_card_cam
         stream_port: 8082
         options:
           videodevice: /dev/video1
           input: 1
           text_left: VIDEO CAM

Testing

Requirements:

Run within docker

molecule test

Run within Vagrant

 molecule test --scenario-name vagrant --parallel

I recommend to use pyenv for local testing. Within the Github Actions pipeline I use my own molecule Docker image.

License

MIT

Author Information

Links

About

Installs motion as a systemd-managed docker container.

License:MIT License