Optimized injection layer on lua base, as replace for nginx replace. Also optimized cloudflare cache deletion(no everytime for cleanup). Still CDN is required for logout mechanism via JS and Nextcloud deploy is buggy after changing from nginx to openresty. Propably some variable overwritte topic. Should be solved tomorrow.

This commit is contained in:
2025-07-24 19:13:13 +02:00
parent f62355e490
commit 27973c2773
36 changed files with 483 additions and 115 deletions

View File

@@ -0,0 +1,30 @@
from ansible.errors import AnsibleFilterError
try:
import tld
from tld.exceptions import TldDomainNotFound, TldBadUrl
except ImportError:
raise AnsibleFilterError("The 'tld' Python package is required for the to_primary_domain filter. Install with 'pip install tld'.")
class FilterModule(object):
''' Custom filter to extract the primary/zone domain from a full domain name '''
def filters(self):
return {
'to_primary_domain': self.to_primary_domain,
}
def to_primary_domain(self, domain):
"""
Converts a full domain or subdomain into its primary/zone domain.
E.g. 'foo.bar.example.co.uk' -> 'example.co.uk'
"""
if not isinstance(domain, str):
raise AnsibleFilterError("Input to to_primary_domain must be a string")
try:
res = tld.get_fld(domain, fix_protocol=True)
if not res:
raise AnsibleFilterError(f"Could not extract primary domain from: {domain}")
return res
except (TldDomainNotFound, TldBadUrl) as exc:
raise AnsibleFilterError(str(exc))