From 50bf8716cd1b6f7f527333f76ab8fbff784bf79c Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Mon, 21 Feb 2022 11:31:44 -0600 Subject: [PATCH] Unify template support for classes (#185) --- test/test_unit_template_default.py | 3 +++ test/test_unit_template_esh.py | 2 ++ test/test_unit_template_j2.py | 3 +++ yadm | 1 + 4 files changed, 9 insertions(+) diff --git a/test/test_unit_template_default.py b/test/test_unit_template_default.py index debd3ed..729784e 100644 --- a/test/test_unit_template_default.py +++ b/test/test_unit_template_default.py @@ -21,6 +21,7 @@ default host = >{{{{yadm.hostname}}}}< default user = >{{{{yadm.user}}}}< default distro = >{{{{yadm.distro}}}}< default distro_family = >{{{{yadm.distro_family}}}}< +classes = >{{{{yadm.classes}}}}< {{% if yadm.class == "else1" %}} wrong else 1 {{% else %}} @@ -107,6 +108,8 @@ default host = >{LOCAL_HOST}< default user = >{LOCAL_USER}< default distro = >{LOCAL_DISTRO}< default distro_family = >{LOCAL_DISTRO_FAMILY}< +classes = >{LOCAL_CLASS2} +{LOCAL_CLASS}< Included section from else Included section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated) Multiple lines diff --git a/test/test_unit_template_esh.py b/test/test_unit_template_esh.py index 2c0f73a..7f2f2b9 100644 --- a/test/test_unit_template_esh.py +++ b/test/test_unit_template_esh.py @@ -20,6 +20,7 @@ esh host = ><%=$YADM_HOSTNAME%>< esh user = ><%=$YADM_USER%>< esh distro = ><%=$YADM_DISTRO%>< esh distro_family = ><%=$YADM_DISTRO_FAMILY%>< +esh classes = ><%=$YADM_CLASSES%>< <% if [ "$YADM_CLASS" = "wrongclass1" ]; then -%> wrong class 1 <% fi -%> @@ -99,6 +100,7 @@ esh host = >{LOCAL_HOST}< esh user = >{LOCAL_USER}< esh distro = >{LOCAL_DISTRO}< esh distro_family = >{LOCAL_DISTRO_FAMILY}< +esh classes = >{LOCAL_CLASS2} {LOCAL_CLASS}< Included esh section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated) Included esh section for second class Included esh section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated) diff --git a/test/test_unit_template_j2.py b/test/test_unit_template_j2.py index 8da0dc0..4042a2d 100644 --- a/test/test_unit_template_j2.py +++ b/test/test_unit_template_j2.py @@ -21,6 +21,7 @@ j2 host = >{{{{YADM_HOSTNAME}}}}< j2 user = >{{{{YADM_USER}}}}< j2 distro = >{{{{YADM_DISTRO}}}}< j2 distro_family = >{{{{YADM_DISTRO_FAMILY}}}}< +j2 classes = >{{{{YADM_CLASSES}}}}< {{%- if YADM_CLASS == "wrongclass1" %}} wrong class 1 {{%- endif %}} @@ -102,6 +103,8 @@ j2 host = >{LOCAL_HOST}< j2 user = >{LOCAL_USER}< j2 distro = >{LOCAL_DISTRO}< j2 distro_family = >{LOCAL_DISTRO_FAMILY}< +j2 classes = >{LOCAL_CLASS2} +{LOCAL_CLASS}< Included j2 section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated) Included j2 section for second class Included j2 section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated) diff --git a/yadm b/yadm index daf0669..22343ed 100755 --- a/yadm +++ b/yadm @@ -372,6 +372,7 @@ function template_default() { BEGIN { blank = "[ ]" c["class"] = class + c["classes"] = classes c["arch"] = arch c["os"] = os c["hostname"] = host