From 4d093735ecd37e16e2e56249114ce20b30fd48f0 Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Fri, 18 Oct 2024 14:41:23 -0400 Subject: [PATCH] prevent state from failing if versionlock plugin not installed --- salt/versionlock/init.sls | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/salt/versionlock/init.sls b/salt/versionlock/init.sls index 278809aee..a310356b4 100644 --- a/salt/versionlock/init.sls +++ b/salt/versionlock/init.sls @@ -3,16 +3,17 @@ # https://securityonion.net/license; you may not use this file except in compliance with the # Elastic License 2.0. -{% from 'versionlock/map.jinja' import VERSIONLOCKMERGED %} - -{% for pkg in VERSIONLOCKMERGED.hold %} +{% if grains.os_family == 'Debian' or (grains.os_family == 'RedHat' and salt['pkg.version']('python3-dnf-plugin-versionlock') != "") %} +{% from 'versionlock/map.jinja' import VERSIONLOCKMERGED %} +{% for pkg in VERSIONLOCKMERGED.hold %} {{pkg}}_held: pkg.held: - name: {{pkg}} -{% endfor %} +{% endfor %} -{% for pkg in VERSIONLOCKMERGED.UNHOLD %} +{% for pkg in VERSIONLOCKMERGED.UNHOLD %} {{pkg}}_unheld: pkg.unheld: - name: {{pkg}} -{% endfor %} +{% endfor %} +{% endif %}