Skip to content

Commit 2f3d9a6

Browse files
authored
Merge pull request #7099 from ggbecker/fix-ansible-checks-test
Only enable ansible/yaml lint tests when playbooks are built
2 parents 722793d + dd273ee commit 2f3d9a6

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

cmake/SSGCommon.cmake

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -302,24 +302,40 @@ macro(ssg_build_remediations PRODUCT)
302302
if ("${PRODUCT_ANSIBLE_REMEDIATION_ENABLED}")
303303
# only enable the ansible syntax checks if we are using openscap 1.2.17 or higher
304304
# older openscap causes syntax errors, see https://github.com/OpenSCAP/openscap/pull/977
305-
if (ANSIBLE_PLAYBOOK_EXECUTABLE AND "${OSCAP_VERSION}" VERSION_GREATER "1.2.16")
305+
if (SSG_ANSIBLE_PLAYBOOKS_ENABLED AND ANSIBLE_PLAYBOOK_EXECUTABLE AND "${OSCAP_VERSION}" VERSION_GREATER "1.2.16")
306306
add_test(
307307
NAME "ansible-playbook-syntax-check-${PRODUCT}"
308308
COMMAND "${CMAKE_SOURCE_DIR}/tests/ansible_playbook_check.sh" "${ANSIBLE_PLAYBOOK_EXECUTABLE}" "${CMAKE_BINARY_DIR}/ansible" "${PRODUCT}"
309309
)
310310
endif()
311311
if (ANSIBLE_CHECKS)
312-
if (ANSIBLE_LINT_EXECUTABLE AND "${OSCAP_VERSION}" VERSION_GREATER "1.2.16")
313-
add_test(
314-
NAME "ansible-playbook-ansible-lint-check-${PRODUCT}"
315-
COMMAND "${CMAKE_SOURCE_DIR}/tests/ansible_playbook_check.sh" "${ANSIBLE_LINT_EXECUTABLE}" "${CMAKE_BINARY_DIR}/${PRODUCT}/playbooks" "${CMAKE_SOURCE_DIR}/tests/ansible-lint_config.yml"
316-
)
312+
if (SSG_ANSIBLE_PLAYBOOKS_PER_RULE_ENABLED)
313+
if (ANSIBLE_LINT_EXECUTABLE)
314+
add_test(
315+
NAME "ansible-playbook-per-rule-ansible-lint-check-${PRODUCT}"
316+
COMMAND "${CMAKE_SOURCE_DIR}/tests/ansible_playbook_check.sh" "${ANSIBLE_LINT_EXECUTABLE}" "${CMAKE_BINARY_DIR}/${PRODUCT}/playbooks" "${CMAKE_SOURCE_DIR}/tests/ansible-lint_config.yml"
317+
)
318+
endif()
319+
if (YAMLLINT_EXECUTABLE)
320+
add_test(
321+
NAME "ansible-playbook-per-rule-yamllint-check-${PRODUCT}"
322+
COMMAND "${CMAKE_SOURCE_DIR}/tests/ansible_playbook_check.sh" "${YAMLLINT_EXECUTABLE}" "${CMAKE_BINARY_DIR}/${PRODUCT}/playbooks" "${CMAKE_SOURCE_DIR}/tests/yamllint_config.yml"
323+
)
324+
endif()
317325
endif()
318-
if (YAMLLINT_EXECUTABLE AND "${OSCAP_VERSION}" VERSION_GREATER "1.2.16")
319-
add_test(
320-
NAME "ansible-playbook-yamllint-check-${PRODUCT}"
321-
COMMAND "${CMAKE_SOURCE_DIR}/tests/ansible_playbook_check.sh" "${YAMLLINT_EXECUTABLE}" "${CMAKE_BINARY_DIR}/${PRODUCT}/playbooks" "${CMAKE_SOURCE_DIR}/tests/yamllint_config.yml"
322-
)
326+
if (SSG_ANSIBLE_PLAYBOOKS_ENABLED)
327+
if (ANSIBLE_LINT_EXECUTABLE AND "${OSCAP_VERSION}" VERSION_GREATER "1.2.16")
328+
add_test(
329+
NAME "ansible-playbook-per-profile-ansible-lint-check-${PRODUCT}"
330+
COMMAND "${CMAKE_SOURCE_DIR}/tests/ansible_playbook_check.sh" "${ANSIBLE_LINT_EXECUTABLE}" "${CMAKE_BINARY_DIR}/ansible" "${CMAKE_SOURCE_DIR}/tests/ansible-lint_config.yml"
331+
)
332+
endif()
333+
if (YAMLLINT_EXECUTABLE AND "${OSCAP_VERSION}" VERSION_GREATER "1.2.16")
334+
add_test(
335+
NAME "ansible-playbook-per-profile-yamllint-check-${PRODUCT}"
336+
COMMAND "${CMAKE_SOURCE_DIR}/tests/ansible_playbook_check.sh" "${YAMLLINT_EXECUTABLE}" "${CMAKE_BINARY_DIR}/ansible" "${CMAKE_SOURCE_DIR}/tests/yamllint_config.yml"
337+
)
338+
endif()
323339
endif()
324340
endif()
325341
endif()

0 commit comments

Comments
 (0)