From a1fcefa17d2a7dca5e50080416f9e58984d65efc Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Wed, 14 Jul 2021 14:57:51 -0400 Subject: [PATCH] mgr/cephadm/templates: add jinja2 lint This adds a jinja2 lint environment in tox for testing the cephadm jinja2 templates. This patch fixes some minor jinja2 syntax for ganesha and keepalived even if the current templates work perfectly. Tags should have one (and only one) space Signed-off-by: Dimitri Savineau (cherry picked from commit 9eac2fba90a3b179087455100e494d7da6b0910e) --- src/pybind/mgr/CMakeLists.txt | 2 +- .../cephadm/templates/services/ingress/keepalived.conf.j2 | 2 +- .../mgr/cephadm/templates/services/nfs/ganesha.conf.j2 | 2 +- src/pybind/mgr/tox.ini | 8 ++++++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/CMakeLists.txt b/src/pybind/mgr/CMakeLists.txt index 679d0d9ae58ba..833faf1aa0846 100644 --- a/src/pybind/mgr/CMakeLists.txt +++ b/src/pybind/mgr/CMakeLists.txt @@ -6,7 +6,7 @@ if(WITH_MGR_ROOK_CLIENT) endif() if(WITH_TESTS) include(AddCephTest) - add_tox_test(mgr ${CMAKE_CURRENT_SOURCE_DIR} TOX_ENVS py3 mypy flake8) + add_tox_test(mgr ${CMAKE_CURRENT_SOURCE_DIR} TOX_ENVS py3 mypy flake8 jinjalint) endif() # Location needs to match default setting for mgr_module_path, currently: diff --git a/src/pybind/mgr/cephadm/templates/services/ingress/keepalived.conf.j2 b/src/pybind/mgr/cephadm/templates/services/ingress/keepalived.conf.j2 index 2c4e326f6db1f..4caeebf51f9e0 100644 --- a/src/pybind/mgr/cephadm/templates/services/ingress/keepalived.conf.j2 +++ b/src/pybind/mgr/cephadm/templates/services/ingress/keepalived.conf.j2 @@ -19,7 +19,7 @@ vrrp_instance VI_0 { } unicast_src_ip {{ host_ip }} unicast_peer { - {% for ip in other_ips %} + {% for ip in other_ips %} {{ ip }} {% endfor %} } diff --git a/src/pybind/mgr/cephadm/templates/services/nfs/ganesha.conf.j2 b/src/pybind/mgr/cephadm/templates/services/nfs/ganesha.conf.j2 index aae3b671eaf7c..6fb47945427f7 100644 --- a/src/pybind/mgr/cephadm/templates/services/nfs/ganesha.conf.j2 +++ b/src/pybind/mgr/cephadm/templates/services/nfs/ganesha.conf.j2 @@ -25,7 +25,7 @@ NFSv4 { RADOS_KV { UserId = "{{ user }}"; - nodeid = "{{ nodeid}}"; + nodeid = "{{ nodeid }}"; pool = "{{ pool }}"; namespace = "{{ namespace }}"; } diff --git a/src/pybind/mgr/tox.ini b/src/pybind/mgr/tox.ini index 4835fa1157a99..9a2cc0fc8c34b 100644 --- a/src/pybind/mgr/tox.ini +++ b/src/pybind/mgr/tox.ini @@ -5,6 +5,7 @@ envlist = test, fix flake8 + jinjalint skipsdist = true requires = cython @@ -102,3 +103,10 @@ modules = commands = flake8 --config=tox.ini {posargs} \ {posargs:{[testenv:flake8]modules}} + +[testenv:jinjalint] +basepython = python3 +deps = + jinjaninja +commands = + jinja-ninja cephadm/templates -- 2.39.5