This commit is contained in:
anon8675309 2025-05-05 13:10:38 +00:00 committed by GitHub
commit a6ed26d4cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 69 additions and 4 deletions

View File

@ -3,6 +3,7 @@
NONE_VALUES: [none, '', ' ']
random_pwd_length: '50'
tmp_pwd_file_prefix: '/tmp/.ansibleguy.sw_zoneminder'
zm_php_version_override: '7.4'
ZM_HC:
packages:
@ -12,7 +13,7 @@ ZM_HC:
repo_key: "https://zmrepo.zoneminder.com/{{ ansible_distribution | lower }}/archive-keyring.gpg"
repo: "deb https://zmrepo.zoneminder.com/{{ ansible_distribution | lower }}/release {{ ansible_lsb.codename | default('buster') }}/"
php_version: '7.4'
php_version: '{{zm_php_version_override}}'
apache:
modules: ['ssl', 'headers', 'rewrite', 'http2', 'cgi']

64
filter_plugins/utils.py Normal file
View File

@ -0,0 +1,64 @@
from re import sub as regex_replace
class FilterModule(object):
def filters(self):
return {
"safe_key": self.safe_key,
"all_true": self.all_true,
"prepare_letsencrypt": self.prepare_letsencrypt,
"ensure_list": self.ensure_list,
"enmod_list": self.enmod_list,
"mod_list": self.mod_list,
"mgmt_pwd": self.mgmt_pwd,
}
@staticmethod
def safe_key(key: str) -> str:
return regex_replace(r'[^0-9a-zA-Z\.]+', '', key.replace(' ', '_'))
@staticmethod
def all_true(data: list) -> bool:
return all(data)
@staticmethod
def prepare_letsencrypt(site: dict, name: str) -> dict:
domains = [site['domain']]
domains.extend(site['aliases'])
return {
name: {
'domains': domains,
'key_size': site['letsencrypt']['key_size'],
'email': site['letsencrypt']['email'],
'state': site['state'],
}
}
@classmethod
def enmod_list(cls, present: list, absent: list) -> str:
absent_list = cls.ensure_list(absent)
return ' '.join([mod for mod in cls.ensure_list(present) if mod not in absent_list])
@classmethod
def mod_list(cls, mods: (str, list)) -> str:
return ' '.join(cls.ensure_list(mods))
@staticmethod
def ensure_list(data: (str, list)) -> list:
# if user supplied a string instead of a list => convert it to match our expectations
if isinstance(data, list):
return data
return [data]
def mgmt_pwd(self, instance: dict) -> str:
return self.fallback(opt1=instance['ansible_pwd'], opt2=instance['root_pwd'])
@staticmethod
def fallback(opt1: str, opt2: str) -> str:
if opt1 not in [None, '', 'None', 'none', ' ']:
return opt1
return opt2

View File

@ -2,7 +2,7 @@
galaxy_info:
author: 'AnsibleGuy <guy@ansibleguy.net>'
namespace: 'ansibleguy'
namespace: 'anon8675309'
license: 'MIT'
issue_tracker_url: 'https://github.com/ansibleguy/sw_zoneminder/issues'
min_ansible_version: '2.14'

View File

@ -9,6 +9,6 @@ collections:
- 'community.crypto'
roles:
- src: 'ansibleguy.infra_apache'
- src: 'anon8675309.infra_apache'
- src: 'ansibleguy.infra_certs'
- src: 'ansibleguy.infra_mariadb'

View File

@ -2,7 +2,7 @@
- name: ZoneMinder | Webserver | Managing Apache2
ansible.builtin.include_role:
name: ansibleguy.infra_apache
name: anon8675309.infra_apache
vars:
apache:
security: "{{ ZM_CONFIG.apache.security }}"