Skip to content

Commit

Permalink
Merge pull request #716 from darshitpp/ansible-nas-ispyagentdvr
Browse files Browse the repository at this point in the history
Support iSpy AgentDVR
  • Loading branch information
davestephens authored Oct 9, 2024
2 parents 24f4ab4 + 5ab867a commit 8178085
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ If you have a spare domain name you can configure applications to be accessible
* [Heimdall](https://heimdall.site/) - Home server dashboard
* [Home Assistant](https://www.home-assistant.io) - Open source home automation
* [Homebridge](https://github.com/nfarina/homebridge) - Emulate the iOS HomeKit API
* [iSpy Agent DVR](https://www.ispyconnect.com/) - iSpy - Agent DVR is a video surveillance software
* [Jackett](https://github.com/Jackett/Jackett) - API Support for your favorite torrent trackers
* [Jellyfin](https://jellyfin.github.io) - The Free Software Media System
* [Joomla](https://www.joomla.org/) - Open source content management system
Expand Down
8 changes: 8 additions & 0 deletions group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ samba_shares:
browseable: yes
path: "{{ code_root }}"

- name: recordings
comment: "Recordings"
guest_ok: yes
public: yes
writable: yes
browseable: yes
path: "{{ recordings_root }}"

###
### NFS
###
Expand Down
4 changes: 4 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@
tags:
- homepage

- role: ispyagentdvr
tags:
- ispyagentdvr

- role: jackett
tags:
- jackett
Expand Down
23 changes: 23 additions & 0 deletions roles/ispyagentdvr/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
ispyagentdvr_enabled: false
ispyagentdvr_available_externally: false

# directories
ispyagentdvr_config_directory: "{{ docker_home }}/ispyagentdvr/config"
ispyagentdvr_commands_directory: "{{ docker_home }}/ispyagentdvr/commands"
ispyagentdvr_recordings_directory: "{{ downloads_root }}/recordings"

# uid / gid
ispyagentdvr_user_id: "1000"
ispyagentdvr_group_id: "1000"

# network
ispyagentdvr_webui_port: "8097"
ispyagentdvr_turn_port: "3478"
ispyagentdvr_agentdvr_host_port: "50000-50010"

# specs
ispyagentdvr_memory: 1g

# docker
ispyagentdvr_container_name: ispyagentdvr
11 changes: 11 additions & 0 deletions roles/ispyagentdvr/docs/ispyagentdvr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# iSpyAgentDVR

Homepage: <https://www.ispyconnect.com/>

iSpy - Agent DVR is a video surveillance software.

## Usage

Set `ispyagentdvr_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.

The iSpyAgentDVR UI can be accessed from <http://ansible_nas_host_or_ip:8097>.
6 changes: 6 additions & 0 deletions roles/ispyagentdvr/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
ispyagentdvr_enabled: true
10 changes: 10 additions & 0 deletions roles/ispyagentdvr/molecule/default/side_effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Stop
hosts: all
become: true
tasks:
- name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role"
ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars:
ispyagentdvr_enabled: false
18 changes: 18 additions & 0 deletions roles/ispyagentdvr/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Get container state
community.docker.docker_container_info:
name: "{{ ispyagentdvr_container_name }}"
register: result

- name: Check iSpyAgentDVR is running
ansible.builtin.assert:
that:
- result.container['State']['Status'] == "running"
- result.container['State']['Restarting'] == false
18 changes: 18 additions & 0 deletions roles/ispyagentdvr/molecule/default/verify_stopped.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Try and stop and remove iSpyAgentDVR
community.docker.docker_container:
name: "{{ ispyagentdvr_container_name }}"
state: absent
register: result

- name: Check iSpyAgentDVR is stopped
ansible.builtin.assert:
that:
- not result.changed
54 changes: 54 additions & 0 deletions roles/ispyagentdvr/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
- name: Start iSpyAgentDVR
block:
- name: Create iSpyAgentDVR Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
# mode: 0755
with_items:
- "{{ ispyagentdvr_config_directory }}"
- "{{ ispyagentdvr_commands_directory }}"
- "{{ ispyagentdvr_recordings_directory }}"

- name: Create iSpyAgentDVR Docker Container
community.docker.docker_container:
name: "{{ ispyagentdvr_container_name }}"
image: mekayelanik/ispyagentdvr:latest
pull: true
volumes:
- "{{ ispyagentdvr_config_directory }}:/AgentDVR/Media/XML:rw"
- "{{ ispyagentdvr_commands_directory }}:/AgentDVR/Commands:rw"
- "{{ ispyagentdvr_recordings_directory }}:/AgentDVR/Media/WebServerRoot/Media:rw"
ports:
- "{{ ispyagentdvr_webui_port }}:8090"
- "{{ ispyagentdvr_turn_port }}:3478/udp"
- "{{ ispyagentdvr_agentdvr_host_port }}:50000-50010/udp"
env:
TZ: "{{ ansible_nas_timezone }}"
WEBUI_PORT: "{{ ispyagentdvr_webui_port }}"
PUID: "{{ ispyagentdvr_user_id }}"
PGID: "{{ ispyagentdvr_group_id }}"
restart_policy: unless-stopped
memory: "{{ ispyagentdvr_memory }}"
labels:
traefik.enable: "{{ ispyagentdvr_available_externally | string }}"
traefik.http.routers.ispyagentdvr.rule: "Host(`ispyagentdvr.{{ ansible_nas_domain }}`)"
traefik.http.routers.ispyagentdvr.tls.certresolver: "letsencrypt"
traefik.http.routers.ispyagentdvr.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.ispyagentdvr.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.ispyagentdvr.loadbalancer.server.port: "8097"
homepage.group: Monitoring
homepage.name: iSpy AgentDVR
homepage.icon: ispy.png
homepage.href: "http://{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:{{ ispyagentdvr_webui_port }}"
homepage.description: Camera Monitoring software
when: ispyagentdvr_enabled is true

- name: Stop iSpyAgentDVR
block:
- name: Stop iSpyAgentDVR
community.docker.docker_container:
name: "{{ ispyagentdvr_container_name }}"
state: absent
when: ispyagentdvr_enabled is false

0 comments on commit 8178085

Please sign in to comment.