From bfb779de087c8f5dad9948ccab418e4e4a5fe287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20MERLE?= <95630726+smerle33@users.noreply.github.com> Date: Thu, 16 Nov 2023 09:30:56 +0100 Subject: [PATCH] chore(goss): moving all sanity checks to goss (#906) * chore(goss): moving all sanity checks to goss * remove goss retry and add some logs * adding back installed packages list * fixup --- build-jenkins-agent-ubuntu.pkr.hcl | 2 +- goss/goss-linux.yaml | 128 +++++++++++++++++++++++++---- provisioning/ubuntu-provision.sh | 61 +------------- 3 files changed, 114 insertions(+), 77 deletions(-) diff --git a/build-jenkins-agent-ubuntu.pkr.hcl b/build-jenkins-agent-ubuntu.pkr.hcl index f05f420b6..d7b1dd212 100644 --- a/build-jenkins-agent-ubuntu.pkr.hcl +++ b/build-jenkins-agent-ubuntu.pkr.hcl @@ -50,7 +50,7 @@ build { inline = [ "source /home/jenkins/.asdf/asdf.sh", # Required as this is a non-interactive and non-login `bash` "goss --version", - "goss --gossfile /tmp/goss-linux.yaml validate --retry-timeout 5s", + "goss --gossfile /tmp/goss-linux.yaml --loglevel DEBUG validate", ] } diff --git a/goss/goss-linux.yaml b/goss/goss-linux.yaml index d533ce064..e3ea02edb 100644 --- a/goss/goss-linux.yaml +++ b/goss/goss-linux.yaml @@ -1,3 +1,4 @@ +--- command: asdf: exec: asdf version @@ -9,16 +10,16 @@ command: exit-status: 0 stdout: - 2.13.35 - azurecli: - exec: az --version - exit-status: 0 - stdout: - - 2.54.0 azcopy: exec: azcopy --version exit-status: 0 stdout: - 10.21.2 + azurecli: + exec: az --version + exit-status: 0 + stdout: + - 2.54.0 bundle: exec: bundle -v exit-status: 0 @@ -61,11 +62,21 @@ command: exit-status: 0 stdout: - 2.42.0 - jdk8: - exec: /opt/jdk-8/bin/java -version + git_lfs: + exec: git-lfs --version exit-status: 0 - stderr: - - 1.8.0_392 + stdout: + - 3.4.0 + goss: + exec: goss --version + exit-status: 0 + stdout: + - 0.4.4 + hadolint: + exec: hadolint -v + exit-status: 0 + stdout: + - 2.12.0 jdk11: exec: /opt/jdk-11/bin/java --version exit-status: 0 @@ -81,29 +92,110 @@ command: exit-status: 0 stdout: - 21.0.1+12 - trivy: - exec: trivy --version + jdk8: + exec: /opt/jdk-8/bin/java -version + exit-status: 0 + stderr: + - 1.8.0_392 + jq: + exec: jq --version exit-status: 0 stdout: - - 0.47.0 - npm: - exec: npm version + - jq-1.6 + jx-release-version: + exec: jx-release-version -version + exit-status: 0 + stdout: + - 2.7.0 + kubectl: + exec: kubectl version --client + exit-status: 0 + stdout: + - 1.23.13 + launchable: + exec: launchable --version + exit-status: 0 + stdout: + - 1.66.0 + make: + exec: make --version + exit-status: 0 + maven: + exec: mvn -v + exit-status: 0 + stdout: + - 3.9.5 + netlify-deploy: + exec: netlify-deploy --help exit-status: 0 nodejs: exec: node --version exit-status: 0 stdout: - 18.18.2 + npm: + exec: npm version + exit-status: 0 + packer: + exec: packer -v + exit-status: 0 + stdout: + - 1.9.4 + parallel: + exec: parallel --version + exit-status: 0 playwright_version: exec: playwright --version exit-status: 0 stdout: - 1.39.0 + python3: + exec: python3 --version + exit-status: 0 + stdout: + - 3.10.12 + ruby: + exec: ruby -v + exit-status: 0 + stdout: + - 2.6.10 + ssh_agent: + exec: command -v ssh-agent + exit-status: 0 + terraform: + exec: terraform -v + exit-status: 0 + stdout: + - 1.6.3 + trivy: + exec: trivy --version + exit-status: 0 + stdout: + - 0.47.0 + unzip: + exec: unzip -v + exit-status: 0 + updatecli: + exec: updatecli version + exit-status: 0 + stderr: + - 0.66.1 + vagrant: + exec: vagrant -v + exit-status: 0 + yq: + exec: yq --version + exit-status: 0 + stdout: + - 4.25.3 + zip: + exec: zip -v + exit-status: 0 file: /home/jenkins: + contains: [] exists: true - mode: "0750" - owner: jenkins - group: jenkins filetype: directory - contains: [] + group: jenkins + mode: '0750' + owner: jenkins diff --git a/provisioning/ubuntu-provision.sh b/provisioning/ubuntu-provision.sh index e63296f13..a655bd223 100755 --- a/provisioning/ubuntu-provision.sh +++ b/provisioning/ubuntu-provision.sh @@ -615,63 +615,6 @@ function cleanup() { sync } -function sanity_check() { - echo "== Sanity Check of installed tools, running as user ${username}" - su - "${username}" -c "source ${asdf_install_dir}/asdf.sh \ - && echo 'git-lfs version:' \ - && git-lfs --version \ - && echo 'goss version:' \ - && goss --version \ - && echo 'hadolint version:' \ - && hadolint -v \ - && echo 'java version:' \ - && java -version \ - && echo 'jq version:' \ - && jq --version \ - && echo 'jx-release-version version:' \ - && jx-release-version -version \ - && echo 'kubectl version:' \ - && kubectl version --client \ - && echo 'make version:' \ - && make --version \ - && echo 'maven version:' \ - && mvn -v \ - && echo 'netlify-deploy version:' \ - && netlify-deploy --help \ - && echo 'ssh-agent version:' \ - && command -v ssh-agent \ - && echo 'packer version:' \ - && packer -v \ - && echo 'parallel version:' \ - && parallel --version \ - && echo 'python3 version:' \ - && python3 --version \ - && echo 'ruby version:' \ - && ruby -v \ - && echo 'terraform version:' \ - && terraform -v \ - && echo 'unzip version:' \ - && unzip -v \ - && echo 'updatecli version:' \ - && updatecli version \ - && echo 'vagrant version:' \ - && vagrant -v \ - && echo 'yq version:' \ - && yq --version \ - && echo 'zip version:' \ - && zip -v \ - && echo 'npm version:' \ - && npm --version \ - && echo 'playwright version:' \ - && playwright --version \ - && echo 'launchable version:' \ - && launchable --version - " - echo "== End of sanity check" - echo "== Installed packages:" - dpkg -l -} - function main() { check_commands copy_custom_scripts @@ -711,8 +654,10 @@ function main() { install_nodejs install_playwright install_launchable + + echo "== Installed packages:" + dpkg -l } main -sanity_check cleanup