From cd028c53be61066a53be3d97655118c4e8a682c6 Mon Sep 17 00:00:00 2001 From: Patrick Neff Date: Mon, 24 Jan 2022 22:13:12 +0100 Subject: [PATCH] initial commit --- files/zoneminder.conf | 58 +++++++++++++++++++++++++++++++++++++++++++ handlers/main.yml | 4 +++ meta/main.yml | 1 + tasks/main.yml | 34 +++++++++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 files/zoneminder.conf create mode 100644 handlers/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml diff --git a/files/zoneminder.conf b/files/zoneminder.conf new file mode 100644 index 0000000..910c8cf --- /dev/null +++ b/files/zoneminder.conf @@ -0,0 +1,58 @@ +# Ansible Managed + +server { + # listen [::]:80 accept_filter=httpready; # for FreeBSD + # listen 80 accept_filter=httpready; # for FreeBSD + listen [::]:80; + listen 80; + + server_name 10.0.0.69; + + # Custom error pages + include h5bp/errors/custom_errors.conf; + + # Include the basic h5bp config set + include h5bp/basic.conf; + + index index.php; + + root /usr/share/zoneminder; + + location /cgi-bin { + auth_basic off; + alias /usr/lib/zoneminder/cgi-bin; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_param HTTP_PROXY ""; + fastcgi_pass unix:/var/run/fcgiwrap.socket; + } + + location /zm/cache { + auth_basic off; + alias /var/cache/zoneminder/cache; + } + + location ~ /zm/api/(css|img|ico) { + auth_basic off; + rewrite ^/zm/api(.+)$ /api/app/webroot/$1 break; + try_files $uri $uri/ =404; + } + + location /zm { + auth_basic off; + alias /usr/share/zoneminder/www; + try_files $uri $uri/ /index.php?$args =404; + location /zm/api { + auth_basic off; + rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last; + } + location ~ \.php$ { + auth_basic off; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_param HTTP_PROXY ""; + fastcgi_index index.php; + fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; + } + } +} diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..9ee5d25 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,4 @@ +- name: restart zoneminder + ansible.builtin.service: + name: zoneminder + state: restarted diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..cd4077f --- /dev/null +++ b/meta/main.yml @@ -0,0 +1 @@ +dependencies: ['ansible-role-nginx'] diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..900f0fa --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,34 @@ +- name: Install dependencies. + ansible.builtin.package: + name: + - apt-transport-https + - gnupg + - php-mysql + - fcgiwrap + +- name: Add zoneminder apt gpg key. + ansible.builtin.apt_key: + url: https://zmrepo.zoneminder.com/debian/archive-keyring.gpg + state: present + +- name: Add zoneminder apt repository + ansible.builtin.apt_repository: + repo: deb https://zmrepo.zoneminder.com/debian/release-1.36 bullseye/ + state: present + update_cache: yes + +- name: Install zoneminder. + ansible.builtin.package: + name: zoneminder + +- name: Configure zoneminder system paths. + ansible.builtin.lineinfile: + path: /etc/zm/conf.d/01-system-paths.conf + regexp: ^ZM_PATH_ZMS + line: ZM_PATH_ZMS=/cgi-bin/nph-zms + +- name: Copy zoneminder nginx config. + ansible.builtin.copy: + src: zoneminder.conf + dest: /etc/nginx/conf.d/zoneminder.conf + notify: reload nginx