ansibleguy.sw_zoneminder/tasks/debian/main.yml

118 lines
3.4 KiB
YAML

---
- name: ZoneMinder | Installing dependencies
ansible.builtin.apt:
name: "{{ ZM_HC.packages.dependencies }}"
state: present
- name: ZoneMinder | Installing admin-tools
ansible.builtin.apt:
name: "{{ ZM_HC.packages.tools }}"
state: present
when: ZM_CONFIG.tools
- name: ZoneMinder | Adding repo-key
ansible.builtin.apt_key:
url: "{{ ZM_HC.repo_key }}"
when: ZM_CONFIG.add_repo
- name: ZoneMinder | Adding package repository
ansible.builtin.apt_repository:
repo: "{{ ZM_HC.repo }}"
state: present
update_cache: yes
filename: 'zoneminder'
when: ZM_CONFIG.add_repo
- name: ZoneMinder | Installing ZoneMinder
ansible.builtin.apt:
name: "{{ ZM_HC.packages.base }}"
state: present
- name: ZoneMinder | Adding zoneminder config
ansible.builtin.template:
src: 'templates/etc/zm/conf.d/custom.conf.j2'
dest: '/etc/zm/conf.d/custom.conf'
owner: 'root'
group: 'www-data'
mode: 0640
no_log: true
tags: [config]
register: zm_cnf
- name: ZoneMinder | Checking for database config
ansible.builtin.stat:
path: '/etc/zm/conf.d/custom_db.conf'
register: zm_db_cnf_file
- name: ZoneMinder | Adding zoneminder database config
ansible.builtin.template:
src: 'templates/etc/zm/conf.d/custom_db.conf.j2'
dest: '/etc/zm/conf.d/custom_db.conf'
owner: 'root'
group: 'www-data'
mode: 0640
no_log: true
tags: [config]
register: zm_db_cnf
when: >
ZM_CONFIG.database.update_password == 'always' or
(force_pwd_change is defined and force_pwd_change) or
not zm_db_cnf_file.stat.exists
- name: ZoneMinder | Pulling existing database password
ansible.builtin.shell: |
set -o pipefail
cat /etc/zm/conf.d/custom_db.conf | grep 'ZM_DB_PASS' | cut -d '=' -f2-
args:
executable: '/bin/bash'
register: zm_db_pwd
when: zm_db_cnf_file.stat.exists
check_mode: false
changed_when: false
- name: ZoneMinder | Updating config-privileges
ansible.builtin.file:
path: '/etc/zm/zm.conf'
state: file
owner: 'root'
group: 'www-data'
mode: 0640
tags: [config]
- name: ZoneMinder | Managing database
ansible.builtin.import_tasks: db.yml
when: ZM_CONFIG.manage.db | bool
- name: ZoneMinder | Unmanaged DB
ansible.builtin.pause:
prompt: "Since this role is not managing the zoneminder-database, you will need to import the database schema initially!
This can be done like this when using a local database: 'cat {{ ZM_HC.database.schema_file }}
| mysql --socket /run/mysqld/mysqld.sock -uroot -p {{ ZM_CONFIG.database.name }}'.
Make sure the schema is imported before continuing!"
when: not ZM_CONFIG.manage.db | bool
- name: ZoneMinder | Managing webserver
ansible.builtin.import_tasks: web.yml
when: ZM_CONFIG.manage.webserver | bool
tags: [config]
- name: ZoneMinder | Unmanaged webserver
ansible.builtin.pause:
prompt: "Since this role is not managing the zoneminder-webserver, you will need to add its custom config as shown
here: https://github.com/ZoneMinder/zoneminder/tree/master/misc"
when: not ZM_CONFIG.manage.webserver | bool
- name: ZoneMinder | Enabling/Starting service
ansible.builtin.systemd:
daemon_reload: yes
name: 'zoneminder.service'
enabled: yes
state: started
- name: ZoneMinder | Restarting service
ansible.builtin.systemd:
name: 'zoneminder.service'
state: restarted
when: zm_cnf.changed