From 89b54c6ee8d9841f2cbb8a3d197e2398fdfc0c61 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Sun, 14 Jul 2019 05:04:03 +0100 Subject: [PATCH] chore: use `semantic-release` cross-formula standard structure * Automated using `ssf-formula` (v0.1.0-rc.1) --- .gitignore | 9 ++++++ .travis.yml | 7 ++-- Gemfile | 1 + bin/kitchen | 29 +++++++++++++++++ kitchen.yml | 43 +++++++++++-------------- test/integration/default/README.md | 50 +++++++++++++++++++++++++++++ test/integration/default/inspec.yml | 14 ++++++++ 7 files changed, 124 insertions(+), 29 deletions(-) create mode 100755 bin/kitchen create mode 100644 test/integration/default/README.md create mode 100644 test/integration/default/inspec.yml diff --git a/.gitignore b/.gitignore index ba07ed8..0bbb03c 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ coverage.xml .kitchen .kitchen.local.yml kitchen.local.yml +junit-*.xml # Translations *.mo @@ -111,3 +112,11 @@ docs/*.md # Vim *.sw? + +## Collected when centralising formulas (check and sort) +# `collectd-formula` +.pytest_cache/ +/.idea/ +Dockerfile.*_* +ignore/ +tmp/ diff --git a/.travis.yml b/.travis.yml index 88ae206..f7b4f05 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ stages: sudo: required cache: bundler language: ruby +dist: xenial services: - docker @@ -29,19 +30,15 @@ env: # - INSTANCE: default-ubuntu-1604-2018-3-py2 # - INSTANCE: default-centos-7-2018-3-py2 # - INSTANCE: default-fedora-29-2018-3-py2 - # TODO: Use this when fixed instead of `opensuse-leap-42` - # Ref: https://github.com/netmanagers/salt-image-builder/issues/2 - # - INSTANCE: default-opensuse-leap-15-2018-3-py2 - INSTANCE: default-opensuse-leap-42-2018-3-py2 # - INSTANCE: default-debian-8-2017-7-py2 # - INSTANCE: default-ubuntu-1604-2017-7-py2 - # TODO: Enable after improving the formula to work with other than `systemd` - INSTANCE: default-centos-6-2017-7-py2 # - INSTANCE: default-fedora-28-2017-7-py2 # - INSTANCE: default-opensuse-leap-42-2017-7-py2 script: - - bundle exec kitchen verify ${INSTANCE} + - bin/kitchen verify ${INSTANCE} jobs: include: diff --git a/Gemfile b/Gemfile index c13c0a2..3b36de3 100644 --- a/Gemfile +++ b/Gemfile @@ -3,3 +3,4 @@ source "https://rubygems.org" gem 'kitchen-docker', '>= 2.9' gem 'kitchen-salt', '>= 0.6.0' gem 'kitchen-inspec', '>= 1.1' + diff --git a/bin/kitchen b/bin/kitchen new file mode 100755 index 0000000..1cd44f3 --- /dev/null +++ b/bin/kitchen @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'kitchen' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("test-kitchen", "kitchen") diff --git a/kitchen.yml b/kitchen.yml index 5020691..c0a366b 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -44,7 +44,7 @@ platforms: - sh bootstrap-salt.sh -XdPbfrq -x python3 git develop run_command: /usr/lib/systemd/systemd - ## SALT 2019.2 + ## SALT `2019.2` - name: debian-9-2019-2-py3 driver: image: netmanagers/salt-2019.2-py3:debian-9 @@ -62,7 +62,7 @@ platforms: image: netmanagers/salt-2019.2-py3:opensuse-leap-15 run_command: /usr/lib/systemd/systemd - ## SALT 2018.3 + ## SALT `2018.3` - name: debian-9-2018-3-py2 driver: image: netmanagers/salt-2018.3-py2:debian-9 @@ -75,25 +75,18 @@ platforms: - name: fedora-29-2018-3-py2 driver: image: netmanagers/salt-2018.3-py2:fedora-29 - # TODO: Use this when fixed instead of `opensuse-leap-42` - # Ref: https://github.com/netmanagers/salt-image-builder/issues/2 - # - name: opensuse-leap-15-2018-3-py2 - # driver: - # image: netmanagers/salt-2018.3-py2:opensuse-leap-15 - # run_command: /usr/lib/systemd/systemd - name: opensuse-leap-42-2018-3-py2 driver: image: netmanagers/salt-2018.3-py2:opensuse-leap-42 run_command: /usr/lib/systemd/systemd - ## SALT 2017.7 + ## SALT `2017.7` - name: debian-8-2017-7-py2 driver: image: netmanagers/salt-2017.7-py2:debian-8 - name: ubuntu-1604-2017-7-py2 driver: image: netmanagers/salt-2017.7-py2:ubuntu-16.04 - # TODO: Modify the formula to work for non-`systemd` platforms - name: centos-6-2017-7-py2 driver: image: netmanagers/salt-2017.7-py2:centos-6 @@ -115,18 +108,6 @@ provisioner: salt_copy_filter: - .kitchen - .git - state_top: - base: - '*': - - bind - - bind.config - pillars: - top.sls: - base: - '*': - - bind - pillars_from_files: - bind.sls: test/salt/pillar/default.sls verifier: # https://www.inspec.io/ @@ -135,8 +116,22 @@ verifier: # cli, documentation, html, progress, json, json-min, json-rspec, junit reporter: - cli - inspec_tests: - - path: test/integration/default suites: - name: default + provisioner: + state_top: + base: + '*': + - bind + - bind.config + pillars: + top.sls: + base: + '*': + - bind + pillars_from_files: + bind.sls: test/salt/pillar/default.sls + verifier: + inspec_tests: + - path: test/integration/default diff --git a/test/integration/default/README.md b/test/integration/default/README.md new file mode 100644 index 0000000..37cf963 --- /dev/null +++ b/test/integration/default/README.md @@ -0,0 +1,50 @@ +# InSpec Profile: `default` + +This shows the implementation of the `default` 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 default +Summary +------- +Location: default +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 default +.. + +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 default --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/default/inspec.yml b/test/integration/default/inspec.yml new file mode 100644 index 0000000..beb70fc --- /dev/null +++ b/test/integration/default/inspec.yml @@ -0,0 +1,14 @@ +name: default +title: bind formula +maintainer: SaltStack Formulas +license: Apache-2.0 +summary: Verify that the bind formula is setup and configured correctly +supports: + - platform-name: debian + - platform-name: ubuntu + - platform-name: centos + - platform-name: fedora + - platform-name: opensuse + - platform-name: suse + - platform-name: freebsd + - platform-name: amazon