2
0

refactor(kitchen+travis+inspec): use pre-salted images

* Semi-automated using https://github.com/myii/ssf-formula/pull/36
* Restructure all tests according to updated test suites
* Improve tests where necessary (code style, new platforms and package versions)
This commit is contained in:
Imran Iqbal 2019-09-17 22:56:38 +01:00
parent cb726afb10
commit fc1d0b15a3
No known key found for this signature in database
GPG Key ID: 6D8629439D2B7819
25 changed files with 472 additions and 212 deletions

View File

@ -24,31 +24,24 @@ env:
# slow down the entire run at the end (i.e. `centos-6` and `opensuse`) # slow down the entire run at the end (i.e. `centos-6` and `opensuse`)
# However, the groupings needed to be maintained in some semblance of order # However, the groupings needed to be maintained in some semblance of order
# so this is a best-effort matrix, in the circumstances # so this is a best-effort matrix, in the circumstances
# - INSTANCE: v201707-py2-debian-8-2017-7-py2
# develop-py3 - INSTANCE: v201707-py2-ubuntu-1604-2017-7-py2
- INSTANCE: develop-py3-debian-9 - INSTANCE: v201707-py2-centos-6-2017-7-py2
- INSTANCE: develop-py3-opensuse-150 # - INSTANCE: v201707-py2-amazonlinux-2-2017-7-py2
# - INSTANCE: develop-py3-ubuntu-1804 # - INSTANCE: v201803-py2-debian-9-2018-3-py2
# - INSTANCE: v201803-py2-ubuntu-1604-2018-3-py2
# 2017.7-py2 - INSTANCE: v201803-py2-centos-7-2018-3-py2
- INSTANCE: v2017-7-py2-bootstrap-centos-6 - INSTANCE: v201803-py2-amazonlinux-2-2018-3-py2
# - INSTANCE: v2017-7-py2-debian-8 - INSTANCE: v201902-py2-debian-9-2019-2-py2
- INSTANCE: v2017-7-py2-ubuntu-1604 - INSTANCE: v201902-py2-ubuntu-1804-2019-2-py2
# - INSTANCE: v201902-py2-centos-7-2019-2-py2
# 2018.3-py2 # - INSTANCE: v201902-py2-opensuse-leap-15-2019-2-py2
# - INSTANCE: v2018-3-py2-centos-7 # - INSTANCE: v201902-py2-amazonlinux-2-2019-2-py2
- INSTANCE: v2018-3-py2-debian-8 # - INSTANCE: v201902-py3-debian-9-2019-2-py3
- INSTANCE: v2018-3-py2-forced-version-fedora-29 # - INSTANCE: v201902-py3-ubuntu-1804-2019-2-py3
# - INSTANCE: v2018-3-py2-ubuntu-1604 # - INSTANCE: v201902-py3-centos-7-2019-2-py3
- INSTANCE: v201902-py3-fedora-30-2019-2-py3
# 2019.2-py2 - INSTANCE: v201902-py3-opensuse-leap-15-2019-2-py3
- INSTANCE: v2019-2-py2-centos-7
- INSTANCE: v2019-2-py2-fedora-30
# 2019.2-py3
# - INSTANCE: v2019-2-py3-debian-9
- INSTANCE: v2019-2-py3-opensuse-150
- INSTANCE: v2019-2-py3-ubuntu-1804
script: script:
- bin/kitchen verify ${INSTANCE} - bin/kitchen verify ${INSTANCE}

View File

@ -1,55 +1,96 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=yaml # vim: ft=yaml
--- ---
# For help on this file's format, see https://kitchen.ci/
driver: driver:
name: docker name: docker
use_sudo: false use_sudo: false
privileged: true privileged: true
provision_command: mkdir -p /run/sshd
run_command: /lib/systemd/systemd run_command: /lib/systemd/systemd
# Make sure the platforms listed below match up with
# the `env.matrix` instances defined in `.travis.yml`
platforms: platforms:
# Latest distros ## SALT `2017.7`
- name: debian-9 - name: debian-8-2017-7-py2
- name: ubuntu-18.04
- name: centos-7
- name: fedora-30
- name: opensuse-15.0
driver: driver:
image: opensuse/leap:15.0 image: netmanagers/salt-2017.7-py2:debian-8
- name: ubuntu-1604-2017-7-py2
driver:
image: netmanagers/salt-2017.7-py2:ubuntu-16.04
- name: centos-6-2017-7-py2
driver:
image: netmanagers/salt-2017.7-py2:centos-6
run_command: /sbin/init
- name: amazonlinux-2-2017-7-py2
driver:
image: netmanagers/salt-2017.7-py2:amazonlinux-2
## SALT `2018.3`
- name: debian-9-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:debian-9
- name: ubuntu-1604-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:ubuntu-16.04
- name: centos-7-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:centos-7
- name: amazonlinux-2-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:amazonlinux-2
## SALT `2019.2`
- name: debian-9-2019-2-py2
driver:
image: netmanagers/salt-2019.2-py2:debian-9
- name: ubuntu-1804-2019-2-py2
driver:
image: netmanagers/salt-2019.2-py2:ubuntu-18.04
- name: centos-7-2019-2-py2
driver:
image: netmanagers/salt-2019.2-py2:centos-7
- name: opensuse-leap-15-2019-2-py2
driver:
image: netmanagers/salt-2019.2-py2:opensuse-leap-15
run_command: /usr/lib/systemd/systemd
# Workaround to avoid intermittent failures on `opensuse-leap-15`:
# => SCP did not finish successfully (255): (Net::SCP::Error)
transport:
max_ssh_sessions: 1
- name: amazonlinux-2-2019-2-py2
driver:
image: netmanagers/salt-2019.2-py2:amazonlinux-2
- name: debian-9-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:debian-9
- name: ubuntu-1804-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:ubuntu-18.04
- name: centos-7-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:centos-7
- name: fedora-30-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:fedora-30
- name: opensuse-leap-15-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:opensuse-leap-15
run_command: /usr/lib/systemd/systemd run_command: /usr/lib/systemd/systemd
provision_command:
- systemctl enable sshd.service
# Workaround to avoid intermittent failures on `opensuse-leap-15`: # Workaround to avoid intermittent failures on `opensuse-leap-15`:
# => SCP did not finish successfully (255): (Net::SCP::Error) # => SCP did not finish successfully (255): (Net::SCP::Error)
transport: transport:
max_ssh_sessions: 1 max_ssh_sessions: 1
# Previous distros
- name: debian-8
- name: ubuntu-16.04
- name: fedora-29
# centos-6 guest fails on Debian hosts due to vsyscall issues, see
# https://hub.docker.com/_/centos, "A note about vsyscall"
- name: centos-6
driver:
run_command: /sbin/init
provisioner: provisioner:
name: salt_solo name: salt_solo
salt_bootstrap_options: -X -d git %s
log_level: info log_level: info
salt_install: none
require_chef: false require_chef: false
formula: salt formula: salt
salt_copy_filter: salt_copy_filter:
- .kitchen - .kitchen
- .git - .git
state_top:
base:
'*':
- salt.pkgrepo
- salt.master
- salt.minion
verifier: verifier:
# https://www.inspec.io/ # https://www.inspec.io/
@ -60,158 +101,105 @@ verifier:
- cli - cli
suites: suites:
# Latest distros, salt develop, python3 - name: v201902-py3
# These distros have py3 packages available in salt's repo
- name: develop-py3
includes: includes:
- debian-9 - debian-9-2019-2-py3
- ubuntu-18.04 - ubuntu-1804-2019-2-py3
- opensuse-15.0 - centos-7-2019-2-py3
- fedora-30-2019-2-py3
- opensuse-leap-15-2019-2-py3
provisioner: provisioner:
salt_bootstrap_options: -X -x python3 -d git %s state_top:
salt_version: 'develop' base:
'*':
- salt.pkgrepo
- salt.master
- salt.minion
pillars: pillars:
top.sls: top.sls:
base: base:
'*': '*':
- salt - salt
- develop-py3 - v201902-py3
pillars_from_files: pillars_from_files:
salt.sls: test/salt/pillar/salt.sls salt.sls: test/salt/pillar/salt.sls
develop-py3.sls: test/salt/pillar/develop-py3.sls v201902-py3.sls: test/salt/pillar/v201902-py3.sls
verifier: verifier:
inspec_tests: inspec_tests:
- path: test/integration/develop - path: test/integration/v201902-py3
- name: v201902-py2
# Latest distros, latest salt, python3
# These distros have py3 packages available in salt's repo
- name: v2019-2-py3
includes: includes:
- debian-9 - debian-9-2019-2-py2
- ubuntu-18.04 - ubuntu-1804-2019-2-py2
- opensuse-15.0 - centos-7-2019-2-py2
- opensuse-leap-15-2019-2-py2
- amazonlinux-2-2019-2-py2
provisioner: provisioner:
salt_bootstrap_options: -X -x python3 -d git %s state_top:
salt_version: '2019.2' base:
'*':
- salt.pkgrepo
- salt.master
- salt.minion
pillars: pillars:
top.sls: top.sls:
base: base:
'*': '*':
- salt - salt
- v2019-2-py3 - v201902-py2
pillars_from_files: pillars_from_files:
salt.sls: test/salt/pillar/salt.sls salt.sls: test/salt/pillar/salt.sls
v2019-2-py3.sls: test/salt/pillar/v2019-2-py3.sls v201902-py2.sls: test/salt/pillar/v201902-py2.sls
verifier: verifier:
inspec_tests: inspec_tests:
- path: test/integration/2019-2 - path: test/integration/v201902-py2
- name: v201803-py2
# Latest distros, latest salt, python2
# Fedora ships updated py2 versions in their own repos
- name: v2019-2-py2
includes: includes:
- centos-7 - debian-9-2018-3-py2
- fedora-30 - ubuntu-1604-2018-3-py2
- centos-7-2018-3-py2
- amazonlinux-2-2018-3-py2
provisioner: provisioner:
salt_version: '2019.2' state_top:
base:
'*':
- salt.pkgrepo
- salt.master
- salt.minion
pillars: pillars:
top.sls: top.sls:
base: base:
'*': '*':
- salt - salt
- v2019-2-py2 - v201803-py2
pillars_from_files: pillars_from_files:
salt.sls: test/salt/pillar/salt.sls salt.sls: test/salt/pillar/salt.sls
v2019-2-py2.sls: test/salt/pillar/v2019-2-py2.sls v201803-py2.sls: test/salt/pillar/v201803-py2.sls
verifier: verifier:
inspec_tests: inspec_tests:
- path: test/integration/2019-2 - path: test/integration/v201803-py2
- name: v201707-py2
# Previous distros, previous salt, python2
- name: v2018-3-py2
includes: includes:
- debian-8 - debian-8-2017-7-py2
- ubuntu-16.04 - ubuntu-1604-2017-7-py2
- centos-7 - centos-6-2017-7-py2
- amazonlinux-2-2017-7-py2
provisioner: provisioner:
# We require an old version of salt in the provisioner or, state_top:
# the salt formula fails to downgrade to the desired version to test base:
salt_version: '2018.3' '*':
- salt.pkgrepo
- salt.master
- salt.minion
pillars: pillars:
top.sls: top.sls:
base: base:
'*': '*':
- salt - salt
- v2018-3-py2 - v201707-py2
pillars_from_files: pillars_from_files:
salt.sls: test/salt/pillar/salt.sls salt.sls: test/salt/pillar/salt.sls
v2018-3-py2.sls: test/salt/pillar/v2018-3-py2.sls v201707-py2.sls: test/salt/pillar/v201707-py2.sls
verifier: verifier:
inspec_tests: inspec_tests:
- path: test/integration/2018-3 - path: test/integration/v201707-py2
# To test fedora 29 & salt v2018.3, we need to force the package version
# otherwise the image, which includes the 'updates' repo, will install 2019.2
- name: v2018-3-py2-forced-version
includes:
- fedora-29
provisioner:
# We require an old version of salt in the provisioner or,
# the salt formula fails to downgrade to the desired version to test
salt_version: '2018.3'
pillars:
top.sls:
base:
'*':
- salt
- v2018-3-py2-forced-version
pillars_from_files:
salt.sls: test/salt/pillar/salt.sls
v2018-3-py2-forced-version.sls: test/salt/pillar/v2018-3-py2-forced-version.sls
verifier:
inspec_tests:
- path: test/integration/2018-3
# Previous distros, oldest salt, python2
- name: v2017-7-py2
includes:
- debian-8
- ubuntu-16.04
provisioner:
# We require an old version of salt in the provisioner or,
# the salt formula fails to downgrade to the desired version to test
salt_version: '2017.7'
pillars:
top.sls:
base:
'*':
- salt
- v2017-7-py2
pillars_from_files:
salt.sls: test/salt/pillar/salt.sls
v2017-7-py2.sls: test/salt/pillar/v2017-7-py2.sls
verifier:
inspec_tests:
- path: test/integration/2017-7
# centos-6 ships with python2.6, so it requires extra bootstrapping parameters
# to install python2.7
- name: v2017-7-py2-bootstrap
includes:
- centos-6
provisioner:
# As centos-6 ships with python2.6, we use the bootstrapper to install python2.7
salt_bootstrap_options: -X -d stable %s
salt_version: '2017.7'
pillars:
top.sls:
base:
'*':
- salt
- v2017-7-py2
pillars_from_files:
salt.sls: test/salt/pillar/salt.sls
v2017-7-py2.sls: test/salt/pillar/v2017-7-py2.sls
verifier:
inspec_tests:
- path: test/integration/2017-7

View File

@ -1,12 +0,0 @@
control 'salt packages' do
title 'should be installed'
%w(
salt-master
salt-minion
).each do |p|
describe package(p) do
it { should be_installed }
end
end
end

View File

@ -0,0 +1,50 @@
# InSpec Profile: `v201707-py2`
This shows the implementation of the `v201707-py2` 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 v201707-py2
Summary
-------
Location: v201707-py2
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 v201707-py2
..
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 v201707-py2 --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).

View File

@ -1,13 +1,15 @@
case os[:name] version =
when 'centos' case platform[:family]
version = '2019.2.0-1.el7' when 'redhat'
when 'fedora' case platform[:name]
version = '2019.2.0-1.fc30' when 'amazon'
when 'opensuse' '2017.7.8-1.el7'
version = '2019.2.0-lp150.3.33.1' when 'centos'
when 'debian', 'ubuntu' '2017.7.8-1.el6'
version = '2019.2.0+ds-1' end
end when 'debian'
'2017.7.8+ds-1'
end
control 'salt packages' do control 'salt packages' do
title 'should be installed' title 'should be installed'

View File

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
name: v201707-py2
title: salt formula
maintainer: SaltStack Formulas
license: Apache-2.0
summary: Verify that Salt `v201707-py2` is setup and configured
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

View File

@ -0,0 +1,50 @@
# InSpec Profile: `v201803-py2`
This shows the implementation of the `v201803-py2` 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 v201803-py2
Summary
-------
Location: v201803-py2
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 v201803-py2
..
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 v201803-py2 --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).

View File

@ -1,9 +1,10 @@
case os[:name] version =
when 'centos' case platform[:family]
version = '2017.7.8-1.el6' when 'redhat'
when 'debian', 'ubuntu' '2018.3.4-1.el7'
version = '2017.7.8+ds-1' when 'debian'
end '2018.3.4+ds-1'
end
control 'salt packages' do control 'salt packages' do
title 'should be installed' title 'should be installed'

View File

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
name: v201803-py2
title: salt formula
maintainer: SaltStack Formulas
license: Apache-2.0
summary: Verify that Salt `v201803-py2` is setup and configured
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

View File

@ -0,0 +1,50 @@
# InSpec Profile: `v201902-py2`
This shows the implementation of the `v201902-py2` 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 v201902-py2
Summary
-------
Location: v201902-py2
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 v201902-py2
..
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 v201902-py2 --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).

View File

@ -1,11 +1,14 @@
case os[:name] version =
when 'centos' case platform[:family]
version = '2018.3.4-1.el7' when 'redhat'
when 'debian', 'ubuntu' '2019.2.0-1.el7'
version = '2018.3.4+ds-1' when 'fedora'
when 'fedora' '2019.2.0-1.fc30'
version = '2018.3.2-5.fc29' when 'suse'
end '2019.2.0-lp151.5.3.1'
when 'debian'
'2019.2.0+ds-1'
end
control 'salt packages' do control 'salt packages' do
title 'should be installed' title 'should be installed'

View File

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
name: v201902-py2
title: salt formula
maintainer: SaltStack Formulas
license: Apache-2.0
summary: Verify that Salt `v201902-py2` is setup and configured
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

View File

@ -0,0 +1,50 @@
# InSpec Profile: `v201902-py3`
This shows the implementation of the `v201902-py3` 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 v201902-py3
Summary
-------
Location: v201902-py3
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 v201902-py3
..
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 v201902-py3 --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).

View File

@ -0,0 +1,30 @@
version =
case platform[:family]
when 'redhat'
case platform[:name]
when 'amazon'
'2019.2.0-1.el7'
when 'centos'
'2019.2.0-2.el7'
end
when 'fedora'
'2019.2.0-1.fc30'
when 'suse'
'2019.2.0-lp151.5.3.1'
when 'debian'
'2019.2.0+ds-1'
end
control 'salt packages' do
title 'should be installed'
%w(
salt-master
salt-minion
).each do |p|
describe package(p) do
it { should be_installed }
its('version') { should eq version }
end
end
end

View File

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
name: v201902-py3
title: salt formula
maintainer: SaltStack Formulas
license: Apache-2.0
summary: Verify that Salt `v201902-py3` is setup and configured
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

View File

@ -1,6 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
salt:
release: 'latest'
py_ver: 'py3'

View File

@ -1,7 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
salt:
release: '2018.3'
py_ver: 'py2'
version: '2018.3.2-5.fc29'