mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-12-02 15:39:57 +00:00
Prevented the setup of MSMTP when MODE_RESET
This commit is contained in:
@@ -9,5 +9,8 @@
|
||||
system_service_tpl_on_failure: "{{ SYS_SERVICE_ON_FAILURE_COMPOSE }}"
|
||||
system_service_on_calendar: "{{ SYS_SCHEDULE_HEALTH_MSMTP }}"
|
||||
system_service_timer_enabled: true
|
||||
when:
|
||||
- not MODE_RESET | bool
|
||||
- users['no-reply'].mailu_token | default(false)
|
||||
|
||||
- include_tasks: utils/run_once.yml
|
||||
@@ -3,4 +3,5 @@
|
||||
when:
|
||||
- run_once_sys_svc_msmtp is not defined or run_once_sys_svc_msmtp is false
|
||||
# Just execute when mailu_token is defined
|
||||
- users['no-reply'].mailu_token is defined
|
||||
- users['no-reply'].mailu_token is defined
|
||||
- not MODE_RESET | bool
|
||||
@@ -33,14 +33,20 @@ class TestModeResetIntegration(unittest.TestCase):
|
||||
if fname.lower().endswith(('.yml', '.yaml')):
|
||||
task_files.append(os.path.join(root, fname))
|
||||
|
||||
# Detect any 'MODE_RESET' usage
|
||||
# Detect any *positive* 'MODE_RESET | bool' usage.
|
||||
# Purely negated conditions like `not MODE_RESET | bool`
|
||||
# should NOT force a reset.yml, because the role only
|
||||
# disables behaviour during reset but has no reset logic.
|
||||
mode_reset_found = False
|
||||
mode_reset_pat = re.compile(r'(?<!not\s)MODE_RESET\s*\|\s*bool')
|
||||
|
||||
for fp in task_files:
|
||||
try:
|
||||
with open(fp, 'r', encoding='utf-8') as f:
|
||||
if 'MODE_RESET' in f.read():
|
||||
mode_reset_found = True
|
||||
break
|
||||
content = f.read()
|
||||
if mode_reset_pat.search(content):
|
||||
mode_reset_found = True
|
||||
break
|
||||
except (UnicodeDecodeError, OSError):
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user