From a6c81972a2c722d1dc3637acb412a8e1e513c998 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 20 Jul 2021 18:00:27 +0100 Subject: [PATCH] ci: use `default` & `repo` InSpec suites * Automated using https://github.com/myii/ssf-formula/pull/348 --- .github/workflows/kitchen.vagrant.yml | 3 + .gitlab-ci.yml | 77 +++++++++++++++----- .travis.yml | 68 +++++++++++++----- kitchen.yml | 100 ++++++++++++++++++++++++++ test/integration/repo/README.md | 50 +++++++++++++ test/integration/repo/inspec.yml | 28 ++++++++ 6 files changed, 293 insertions(+), 33 deletions(-) create mode 100644 test/integration/repo/README.md create mode 100644 test/integration/repo/inspec.yml diff --git a/.github/workflows/kitchen.vagrant.yml b/.github/workflows/kitchen.vagrant.yml index 3840668..9d34048 100644 --- a/.github/workflows/kitchen.vagrant.yml +++ b/.github/workflows/kitchen.vagrant.yml @@ -15,8 +15,11 @@ jobs: matrix: instance: - default-freebsd-130-master-py3 + # - freebsd-130-master-py3 - default-freebsd-122-master-py3 + # - freebsd-122-master-py3 - default-freebsd-114-master-py3 + # - freebsd-114-master-py3 # - default-freebsd-130-3002-6-py3 # - default-freebsd-122-3002-6-py3 # - default-freebsd-114-3002-6-py3 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0d75c0e..8f2c462 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -102,7 +102,7 @@ rubocop: ############################################################################### # Define `test` template ############################################################################### -.test_instance: +.test_instance: &test_instance stage: *stage_test image: *image_dindruby services: *services_docker_dind @@ -117,6 +117,13 @@ rubocop: # Alternative value to consider: `${CI_JOB_NAME}` - 'bin/kitchen verify "${DOCKER_ENV_CI_JOB_NAME}"' +############################################################################### +# Define `test` template (`allow_failure: true`) +############################################################################### +.test_instance_failure_permitted: + <<: *test_instance + allow_failure: true + ############################################################################### # `test` stage: each instance below uses the `test` template above ############################################################################### @@ -135,26 +142,62 @@ rubocop: # default-oraclelinux-7-tiamat-py3: {extends: '.test_instance'} # default-almalinux-8-tiamat-py3: {extends: '.test_instance'} # default-rockylinux-8-tiamat-py3: {extends: '.test_instance'} -default-debian-11-master-py3: {extends: '.test_instance'} -default-debian-10-master-py3: {extends: '.test_instance'} -default-debian-9-master-py3: {extends: '.test_instance'} -default-ubuntu-2004-master-py3: {extends: '.test_instance'} -default-ubuntu-1804-master-py3: {extends: '.test_instance'} -default-centos-8-master-py3: {extends: '.test_instance'} -default-centos-7-master-py3: {extends: '.test_instance'} -default-fedora-34-master-py3: {extends: '.test_instance'} -default-fedora-33-master-py3: {extends: '.test_instance'} -default-opensuse-leap-153-master-py3: {extends: '.test_instance'} -default-opensuse-leap-152-master-py3: {extends: '.test_instance'} +# default-debian-11-master-py3: {extends: '.test_instance'} +# repo-debian-11-master-py3: {extends: '.test_instance'} +debian-11-master-py3: {extends: '.test_instance'} +# default-debian-10-master-py3: {extends: '.test_instance'} +# repo-debian-10-master-py3: {extends: '.test_instance'} +debian-10-master-py3: {extends: '.test_instance'} +# default-debian-9-master-py3: {extends: '.test_instance'} +# repo-debian-9-master-py3: {extends: '.test_instance'} +debian-9-master-py3: {extends: '.test_instance'} +# default-ubuntu-2004-master-py3: {extends: '.test_instance'} +# repo-ubuntu-2004-master-py3: {extends: '.test_instance'} +ubuntu-2004-master-py3: {extends: '.test_instance'} +# default-ubuntu-1804-master-py3: {extends: '.test_instance'} +# repo-ubuntu-1804-master-py3: {extends: '.test_instance'} +ubuntu-1804-master-py3: {extends: '.test_instance'} +# default-centos-8-master-py3: {extends: '.test_instance'} +# repo-centos-8-master-py3: {extends: '.test_instance'} +centos-8-master-py3: {extends: '.test_instance'} +# default-centos-7-master-py3: {extends: '.test_instance'} +# repo-centos-7-master-py3: {extends: '.test_instance'} +centos-7-master-py3: {extends: '.test_instance'} +# default-fedora-34-master-py3: {extends: '.test_instance'} +# repo-fedora-34-master-py3: {extends: '.test_instance'} +fedora-34-master-py3: {extends: '.test_instance'} +# default-fedora-33-master-py3: {extends: '.test_instance'} +# repo-fedora-33-master-py3: {extends: '.test_instance'} +fedora-33-master-py3: {extends: '.test_instance'} +# default-opensuse-leap-153-master-py3: {extends: '.test_instance'} +# repo-opensuse-leap-153-master-py3: {extends: '.test_instance'} +opensuse-leap-153-master-py3: {extends: '.test_instance'} +# default-opensuse-leap-152-master-py3: {extends: '.test_instance'} +# repo-opensuse-leap-152-master-py3: {extends: '.test_instance_failure_permitted'} +opensuse-leap-152-master-py3: {extends: '.test_instance_failure_permitted'} default-opensuse-tmbl-latest-master-py3: {extends: '.test_instance'} -default-amazonlinux-2-master-py3: {extends: '.test_instance'} -default-oraclelinux-8-master-py3: {extends: '.test_instance'} -default-oraclelinux-7-master-py3: {extends: '.test_instance'} +# opensuse-tmbl-latest-master-py3: {extends: '.test_instance'} +# default-amazonlinux-2-master-py3: {extends: '.test_instance'} +# repo-amazonlinux-2-master-py3: {extends: '.test_instance'} +amazonlinux-2-master-py3: {extends: '.test_instance'} +# default-oraclelinux-8-master-py3: {extends: '.test_instance'} +# repo-oraclelinux-8-master-py3: {extends: '.test_instance'} +oraclelinux-8-master-py3: {extends: '.test_instance'} +# default-oraclelinux-7-master-py3: {extends: '.test_instance'} +# repo-oraclelinux-7-master-py3: {extends: '.test_instance'} +oraclelinux-7-master-py3: {extends: '.test_instance'} default-arch-base-latest-master-py3: {extends: '.test_instance'} +# arch-base-latest-master-py3: {extends: '.test_instance'} # default-gentoo-stage3-latest-master-py3: {extends: '.test_instance'} +# gentoo-stage3-latest-master-py3: {extends: '.test_instance'} # default-gentoo-stage3-systemd-master-py3: {extends: '.test_instance'} -default-almalinux-8-master-py3: {extends: '.test_instance'} -default-rockylinux-8-master-py3: {extends: '.test_instance'} +# gentoo-stage3-systemd-master-py3: {extends: '.test_instance'} +# default-almalinux-8-master-py3: {extends: '.test_instance'} +# repo-almalinux-8-master-py3: {extends: '.test_instance'} +almalinux-8-master-py3: {extends: '.test_instance'} +# default-rockylinux-8-master-py3: {extends: '.test_instance'} +# repo-rockylinux-8-master-py3: {extends: '.test_instance'} +rockylinux-8-master-py3: {extends: '.test_instance'} # default-debian-11-3003-1-py3: {extends: '.test_instance'} # default-debian-10-3003-1-py3: {extends: '.test_instance'} # default-debian-9-3003-1-py3: {extends: '.test_instance'} diff --git a/.travis.yml b/.travis.yml index 5706862..df037e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -95,26 +95,62 @@ jobs: # - env: INSTANCE=default-oraclelinux-7-tiamat-py3 # - env: INSTANCE=default-almalinux-8-tiamat-py3 # - env: INSTANCE=default-rockylinux-8-tiamat-py3 - - env: INSTANCE=default-debian-11-master-py3 - - env: INSTANCE=default-debian-10-master-py3 - - env: INSTANCE=default-debian-9-master-py3 - - env: INSTANCE=default-ubuntu-2004-master-py3 - - env: INSTANCE=default-ubuntu-1804-master-py3 - - env: INSTANCE=default-centos-8-master-py3 - - env: INSTANCE=default-centos-7-master-py3 - - env: INSTANCE=default-fedora-34-master-py3 - - env: INSTANCE=default-fedora-33-master-py3 - - env: INSTANCE=default-opensuse-leap-153-master-py3 - - env: INSTANCE=default-opensuse-leap-152-master-py3 + # - env: INSTANCE=default-debian-11-master-py3 + # - env: INSTANCE=repo-debian-11-master-py3 + - env: INSTANCE=debian-11-master-py3 + # - env: INSTANCE=default-debian-10-master-py3 + # - env: INSTANCE=repo-debian-10-master-py3 + - env: INSTANCE=debian-10-master-py3 + # - env: INSTANCE=default-debian-9-master-py3 + # - env: INSTANCE=repo-debian-9-master-py3 + - env: INSTANCE=debian-9-master-py3 + # - env: INSTANCE=default-ubuntu-2004-master-py3 + # - env: INSTANCE=repo-ubuntu-2004-master-py3 + - env: INSTANCE=ubuntu-2004-master-py3 + # - env: INSTANCE=default-ubuntu-1804-master-py3 + # - env: INSTANCE=repo-ubuntu-1804-master-py3 + - env: INSTANCE=ubuntu-1804-master-py3 + # - env: INSTANCE=default-centos-8-master-py3 + # - env: INSTANCE=repo-centos-8-master-py3 + - env: INSTANCE=centos-8-master-py3 + # - env: INSTANCE=default-centos-7-master-py3 + # - env: INSTANCE=repo-centos-7-master-py3 + - env: INSTANCE=centos-7-master-py3 + # - env: INSTANCE=default-fedora-34-master-py3 + # - env: INSTANCE=repo-fedora-34-master-py3 + - env: INSTANCE=fedora-34-master-py3 + # - env: INSTANCE=default-fedora-33-master-py3 + # - env: INSTANCE=repo-fedora-33-master-py3 + - env: INSTANCE=fedora-33-master-py3 + # - env: INSTANCE=default-opensuse-leap-153-master-py3 + # - env: INSTANCE=repo-opensuse-leap-153-master-py3 + - env: INSTANCE=opensuse-leap-153-master-py3 + # - env: INSTANCE=default-opensuse-leap-152-master-py3 + # - env: INSTANCE=repo-opensuse-leap-152-master-py3 + - env: INSTANCE=opensuse-leap-152-master-py3 - env: INSTANCE=default-opensuse-tmbl-latest-master-py3 - - env: INSTANCE=default-amazonlinux-2-master-py3 - - env: INSTANCE=default-oraclelinux-8-master-py3 - - env: INSTANCE=default-oraclelinux-7-master-py3 + # - env: INSTANCE=opensuse-tmbl-latest-master-py3 + # - env: INSTANCE=default-amazonlinux-2-master-py3 + # - env: INSTANCE=repo-amazonlinux-2-master-py3 + - env: INSTANCE=amazonlinux-2-master-py3 + # - env: INSTANCE=default-oraclelinux-8-master-py3 + # - env: INSTANCE=repo-oraclelinux-8-master-py3 + - env: INSTANCE=oraclelinux-8-master-py3 + # - env: INSTANCE=default-oraclelinux-7-master-py3 + # - env: INSTANCE=repo-oraclelinux-7-master-py3 + - env: INSTANCE=oraclelinux-7-master-py3 - env: INSTANCE=default-arch-base-latest-master-py3 + # - env: INSTANCE=arch-base-latest-master-py3 # - env: INSTANCE=default-gentoo-stage3-latest-master-py3 + # - env: INSTANCE=gentoo-stage3-latest-master-py3 # - env: INSTANCE=default-gentoo-stage3-systemd-master-py3 - - env: INSTANCE=default-almalinux-8-master-py3 - - env: INSTANCE=default-rockylinux-8-master-py3 + # - env: INSTANCE=gentoo-stage3-systemd-master-py3 + # - env: INSTANCE=default-almalinux-8-master-py3 + # - env: INSTANCE=repo-almalinux-8-master-py3 + - env: INSTANCE=almalinux-8-master-py3 + # - env: INSTANCE=default-rockylinux-8-master-py3 + # - env: INSTANCE=repo-rockylinux-8-master-py3 + - env: INSTANCE=rockylinux-8-master-py3 # - env: INSTANCE=default-debian-11-3003-1-py3 # - env: INSTANCE=default-debian-10-3003-1-py3 # - env: INSTANCE=default-debian-9-3003-1-py3 diff --git a/kitchen.yml b/kitchen.yml index bc0cb65..9121fe9 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -445,3 +445,103 @@ suites: verifier: inspec_tests: - path: test/integration/default + - name: repo + includes: + - debian-11-tiamat-py3 + - debian-10-tiamat-py3 + - debian-9-tiamat-py3 + - ubuntu-2004-tiamat-py3 + - ubuntu-1804-tiamat-py3 + - centos-8-tiamat-py3 + - centos-7-tiamat-py3 + - amazonlinux-2-tiamat-py3 + - oraclelinux-8-tiamat-py3 + - oraclelinux-7-tiamat-py3 + - almalinux-8-tiamat-py3 + - rockylinux-8-tiamat-py3 + - debian-11-master-py3 + - debian-10-master-py3 + - debian-9-master-py3 + - ubuntu-2004-master-py3 + - ubuntu-1804-master-py3 + - centos-8-master-py3 + - centos-7-master-py3 + - fedora-34-master-py3 + - fedora-33-master-py3 + - opensuse-leap-153-master-py3 + - opensuse-leap-152-master-py3 + - amazonlinux-2-master-py3 + - oraclelinux-8-master-py3 + - oraclelinux-7-master-py3 + - almalinux-8-master-py3 + - rockylinux-8-master-py3 + - debian-11-3003-1-py3 + - debian-10-3003-1-py3 + - debian-9-3003-1-py3 + - ubuntu-2004-3003-1-py3 + - ubuntu-1804-3003-1-py3 + - centos-8-3003-1-py3 + - centos-7-3003-1-py3 + - fedora-34-3003-1-py3 + - fedora-33-3003-1-py3 + - opensuse-leap-153-3003-1-py3 + - opensuse-leap-152-3003-1-py3 + - amazonlinux-2-3003-1-py3 + - oraclelinux-8-3003-1-py3 + - oraclelinux-7-3003-1-py3 + - debian-11-3002-6-py3 + - debian-10-3002-6-py3 + - debian-9-3002-6-py3 + - ubuntu-2004-3002-6-py3 + - ubuntu-1804-3002-6-py3 + - centos-8-3002-6-py3 + - centos-7-3002-6-py3 + - fedora-34-3002-6-py3 + - fedora-33-3002-6-py3 + - amazonlinux-2-3002-6-py3 + - oraclelinux-8-3002-6-py3 + - oraclelinux-7-3002-6-py3 + - opensuse-leap-153-3002-2-py3 + - opensuse-leap-152-3002-2-py3 + - debian-10-3001-7-py3 + - debian-9-3001-7-py3 + - ubuntu-2004-3001-7-py3 + - ubuntu-1804-3001-7-py3 + - centos-8-3001-7-py3 + - centos-7-3001-7-py3 + - fedora-34-3001-7-py3 + - fedora-33-3001-7-py3 + - opensuse-leap-153-3001-7-py3 + - opensuse-leap-152-3001-7-py3 + - amazonlinux-2-3001-7-py3 + - oraclelinux-8-3001-7-py3 + - oraclelinux-7-3001-7-py3 + - debian-10-3000-9-py3 + - debian-9-3000-9-py3 + - ubuntu-1804-3000-9-py3 + - centos-8-3000-9-py3 + - centos-7-3000-9-py3 + - opensuse-leap-153-3000-9-py3 + - opensuse-leap-152-3000-9-py3 + - amazonlinux-2-3000-9-py3 + - oraclelinux-8-3000-9-py3 + - oraclelinux-7-3000-9-py3 + - ubuntu-1804-3000-9-py2 + provisioner: + state_top: + base: + '*': + - postgres._mapdata + - postgres + pillars: + top.sls: + base: + '*': + - postgres + - repo + pillars_from_files: + postgres.sls: test/salt/pillar/postgres.sls + repo.sls: test/salt/pillar/repo.sls + verifier: + inspec_tests: + - path: test/integration/repo diff --git a/test/integration/repo/README.md b/test/integration/repo/README.md new file mode 100644 index 0000000..7a12525 --- /dev/null +++ b/test/integration/repo/README.md @@ -0,0 +1,50 @@ +# InSpec Profile: `repo` + +This shows the implementation of the `repo` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md). + +## Verify a profile + +InSpec ships with built-in features to verify a profile structure. + +```bash +$ inspec check repo +Summary +------- +Location: repo +Profile: profile +Controls: 4 +Timestamp: 2019-06-24T23:09:01+00:00 +Valid: true + +Errors +------ + +Warnings +-------- +``` + +## Execute a profile + +To run all **supported** controls on a local machine use `inspec exec /path/to/profile`. + +```bash +$ inspec exec repo +.. + +Finished in 0.0025 seconds (files took 0.12449 seconds to load) +8 examples, 0 failures +``` + +## Execute a specific control from a profile + +To run one control from the profile use `inspec exec /path/to/profile --controls name`. + +```bash +$ inspec exec repo --controls package +. + +Finished in 0.0025 seconds (files took 0.12449 seconds to load) +1 examples, 0 failures +``` + +See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb). diff --git a/test/integration/repo/inspec.yml b/test/integration/repo/inspec.yml new file mode 100644 index 0000000..635d0f0 --- /dev/null +++ b/test/integration/repo/inspec.yml @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +name: repo +title: postgres formula +maintainer: SaltStack Formulas +license: Apache-2.0 +# yamllint disable-line rule:line-length +summary: Verify that the postgres formula is setup and configured correctly (when installing from the upstream repo) +depends: + - name: share + path: test/integration/share +supports: + - platform-name: debian + - platform-name: ubuntu + - platform-name: centos + - platform-name: fedora + - platform-name: opensuse + - platform-name: suse + - platform-name: freebsd + - platform-name: openbsd + - platform-name: amazon + - platform-name: oracle + - platform-name: arch + - platform-name: gentoo + - platform-name: almalinux + - platform-name: rocky + - platform: windows