Skip to content

Commit c48d421

Browse files
authored
Merge pull request #41 from n-rodriguez/wip/travis
ci(kitchen+travis): test with latest Docker images
2 parents 06b10a3 + ba1f346 commit c48d421

File tree

12 files changed

+328
-95
lines changed

12 files changed

+328
-95
lines changed

.kitchen.yml

-53
This file was deleted.

.travis.yml

+39-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,45 @@
1-
language: ruby
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
stages:
5+
- test
6+
27
sudo: required
38
cache: bundler
4-
rvm:
5-
- 2.3.5
9+
language: ruby
10+
dist: xenial
11+
612
services:
713
- docker
8-
script:
9-
- bundle exec kitchen test
14+
15+
# Make sure the instances listed below match up with
16+
# the `platforms` defined in `kitchen.yml`
1017
env:
1118
matrix:
12-
- DISTRIB=debian:wheezy/7
13-
- DISTRIB=debian:jessie/8
14-
- DISTRIB=debian:stretch/9
15-
- DISTRIB=ubuntu:xenial/16.04
19+
- INSTANCE: default-debian-10-develop-py3
20+
# - INSTANCE: default-ubuntu-1804-develop-py3
21+
# - INSTANCE: default-centos-7-develop-py3
22+
# - INSTANCE: default-fedora-30-develop-py3
23+
# - INSTANCE: default-opensuse-leap-15-develop-py3
24+
# - INSTANCE: default-amazonlinux-2-develop-py2
25+
# - INSTANCE: default-debian-9-2019-2-py3
26+
- INSTANCE: default-ubuntu-1804-2019-2-py3
27+
# - INSTANCE: default-centos-7-2019-2-py3
28+
# - INSTANCE: default-fedora-30-2019-2-py3
29+
# - INSTANCE: default-opensuse-leap-15-2019-2-py3
30+
- INSTANCE: default-amazonlinux-2-2019-2-py2
31+
# - INSTANCE: default-debian-9-2018-3-py2
32+
# - INSTANCE: default-ubuntu-1604-2018-3-py2
33+
# - INSTANCE: default-centos-7-2018-3-py2
34+
- INSTANCE: default-fedora-29-2018-3-py2
35+
- INSTANCE: default-opensuse-leap-15-2018-3-py2
36+
# - INSTANCE: default-amazonlinux-2-2018-3-py2
37+
# - INSTANCE: default-debian-8-2017-7-py2
38+
# - INSTANCE: default-ubuntu-1604-2017-7-py2
39+
- INSTANCE: default-centos-6-2017-7-py2
40+
# - INSTANCE: default-fedora-29-2017-7-py2
41+
# - INSTANCE: default-opensuse-leap-15-2017-7-py2
42+
# - INSTANCE: default-amazonlinux-2-2017-7-py2
43+
44+
script:
45+
- bin/kitchen verify ${INSTANCE}

Gemfile

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
source 'https://rubygems.org'
2-
ruby '2.3.5'
1+
source "https://rubygems.org"
2+
3+
gem 'kitchen-docker', '>= 2.9'
4+
gem 'kitchen-salt', '>= 0.6.0'
5+
gem 'kitchen-inspec', '>= 1.1'
36

4-
gem 'test-kitchen'
5-
gem 'kitchen-docker'
6-
gem 'kitchen-salt'
7-
gem 'kitchen-inspec'
8-
gem 'rake'

bin/kitchen

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'kitchen' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
require "pathname"
12+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13+
Pathname.new(__FILE__).realpath)
14+
15+
bundle_binstub = File.expand_path("../bundle", __FILE__)
16+
17+
if File.file?(bundle_binstub)
18+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19+
load(bundle_binstub)
20+
else
21+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23+
end
24+
end
25+
26+
require "rubygems"
27+
require "bundler/setup"
28+
29+
load Gem.bin_path("test-kitchen", "kitchen")

kitchen.yml

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
# For help on this file's format, see https://kitchen.ci/
5+
driver:
6+
name: docker
7+
use_sudo: false
8+
privileged: true
9+
run_command: /lib/systemd/systemd
10+
11+
# Make sure the platforms listed below match up with
12+
# the `env.matrix` instances defined in `.travis.yml`
13+
platforms:
14+
## SALT `develop`
15+
- name: debian-10-develop-py3
16+
driver:
17+
image: netmanagers/salt-develop-py3:debian-10
18+
provision_command:
19+
- curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com
20+
- sh bootstrap-salt.sh -XdPbfrq -x python3 git develop
21+
- name: ubuntu-1804-develop-py3
22+
driver:
23+
image: netmanagers/salt-develop-py3:ubuntu-18.04
24+
provision_command:
25+
- curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com
26+
- sh bootstrap-salt.sh -XdPbfrq -x python3 git develop
27+
- name: centos-7-develop-py3
28+
driver:
29+
image: netmanagers/salt-develop-py3:centos-7
30+
provision_command:
31+
- curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com
32+
- sh bootstrap-salt.sh -XdPbfrq -x python3 git develop
33+
- name: fedora-30-develop-py3
34+
driver:
35+
image: netmanagers/salt-develop-py3:fedora-30
36+
provision_command:
37+
- curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com
38+
- sh bootstrap-salt.sh -XdPbfrq -x python3 git develop
39+
- name: opensuse-leap-15-develop-py3
40+
driver:
41+
image: netmanagers/salt-develop-py3:opensuse-leap-15
42+
provision_command:
43+
- curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com
44+
- sh bootstrap-salt.sh -XdPbfrq -x python3 git develop
45+
run_command: /usr/lib/systemd/systemd
46+
- name: amazonlinux-2-develop-py2
47+
driver:
48+
image: netmanagers/salt-develop-py2:amazonlinux-2
49+
provision_command:
50+
- curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com
51+
- sh bootstrap-salt.sh -XdPbfrq -x python2 git develop
52+
53+
## SALT `2019.2`
54+
- name: debian-9-2019-2-py3
55+
driver:
56+
image: netmanagers/salt-2019.2-py3:debian-9
57+
- name: ubuntu-1804-2019-2-py3
58+
driver:
59+
image: netmanagers/salt-2019.2-py3:ubuntu-18.04
60+
- name: centos-7-2019-2-py3
61+
driver:
62+
image: netmanagers/salt-2019.2-py3:centos-7
63+
- name: fedora-30-2019-2-py3
64+
driver:
65+
image: netmanagers/salt-2019.2-py3:fedora-30
66+
- name: opensuse-leap-15-2019-2-py3
67+
driver:
68+
image: netmanagers/salt-2019.2-py3:opensuse-leap-15
69+
run_command: /usr/lib/systemd/systemd
70+
- name: amazonlinux-2-2019-2-py2
71+
driver:
72+
image: netmanagers/salt-2019.2-py2:amazonlinux-2
73+
74+
## SALT `2018.3`
75+
- name: debian-9-2018-3-py2
76+
driver:
77+
image: netmanagers/salt-2018.3-py2:debian-9
78+
- name: ubuntu-1604-2018-3-py2
79+
driver:
80+
image: netmanagers/salt-2018.3-py2:ubuntu-16.04
81+
- name: centos-7-2018-3-py2
82+
driver:
83+
image: netmanagers/salt-2018.3-py2:centos-7
84+
- name: fedora-29-2018-3-py2
85+
driver:
86+
image: netmanagers/salt-2018.3-py2:fedora-29
87+
- name: opensuse-leap-15-2018-3-py2
88+
driver:
89+
image: netmanagers/salt-2018.3-py2:opensuse-leap-15
90+
run_command: /usr/lib/systemd/systemd
91+
- name: amazonlinux-2-2018-3-py2
92+
driver:
93+
image: netmanagers/salt-2018.3-py2:amazonlinux-2
94+
95+
## SALT `2017.7`
96+
- name: debian-8-2017-7-py2
97+
driver:
98+
image: netmanagers/salt-2017.7-py2:debian-8
99+
- name: ubuntu-1604-2017-7-py2
100+
driver:
101+
image: netmanagers/salt-2017.7-py2:ubuntu-16.04
102+
- name: centos-6-2017-7-py2
103+
driver:
104+
image: netmanagers/salt-2017.7-py2:centos-6
105+
run_command: /sbin/init
106+
- name: fedora-29-2017-7-py2
107+
driver:
108+
image: netmanagers/salt-2017.7-py2:fedora-29
109+
- name: opensuse-leap-15-2017-7-py2
110+
driver:
111+
image: netmanagers/salt-2017.7-py2:opensuse-leap-15
112+
run_command: /usr/lib/systemd/systemd
113+
- name: amazonlinux-2-2017-7-py2
114+
driver:
115+
image: netmanagers/salt-2017.7-py2:amazonlinux-2
116+
117+
provisioner:
118+
name: salt_solo
119+
log_level: info
120+
salt_install: none
121+
require_chef: false
122+
formula: vim
123+
salt_copy_filter:
124+
- .kitchen
125+
- .git
126+
127+
verifier:
128+
# https://www.inspec.io/
129+
name: inspec
130+
sudo: true
131+
# cli, documentation, html, progress, json, json-min, json-rspec, junit
132+
reporter:
133+
- cli
134+
135+
suites:
136+
- name: default
137+
provisioner:
138+
state_top:
139+
base:
140+
'*':
141+
- vim
142+
pillars:
143+
top.sls:
144+
base:
145+
'*':
146+
- vim
147+
pillars_from_files:
148+
vim.sls: test/salt/pillar/vim.sls
149+
verifier:
150+
inspec_tests:
151+
- path: test/integration/default

test/integration/default/README.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# InSpec Profile: `default`
2+
3+
This shows the implementation of the `default` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md).
4+
5+
## Verify a profile
6+
7+
InSpec ships with built-in features to verify a profile structure.
8+
9+
```bash
10+
$ inspec check default
11+
Summary
12+
-------
13+
Location: default
14+
Profile: profile
15+
Controls: 4
16+
Timestamp: 2019-06-24T23:09:01+00:00
17+
Valid: true
18+
19+
Errors
20+
------
21+
22+
Warnings
23+
--------
24+
```
25+
26+
## Execute a profile
27+
28+
To run all **supported** controls on a local machine use `inspec exec /path/to/profile`.
29+
30+
```bash
31+
$ inspec exec default
32+
..
33+
34+
Finished in 0.0025 seconds (files took 0.12449 seconds to load)
35+
8 examples, 0 failures
36+
```
37+
38+
## Execute a specific control from a profile
39+
40+
To run one control from the profile use `inspec exec /path/to/profile --controls name`.
41+
42+
```bash
43+
$ inspec exec default --controls package
44+
.
45+
46+
Finished in 0.0025 seconds (files took 0.12449 seconds to load)
47+
1 examples, 0 failures
48+
```
49+
50+
See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
control 'Vim configuration' do
2+
title 'should match desired lines'
3+
4+
config_file =
5+
case os[:family]
6+
when 'debian'
7+
'/etc/vim/vimrc'
8+
else
9+
'/etc/vimrc'
10+
end
11+
12+
describe file(config_file) do
13+
# Custom config from pillar
14+
its('content') { should include 'syntax on' }
15+
its('content') { should include 'set number' }
16+
end
17+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
control 'Vim package' do
2+
title 'should be installed'
3+
4+
package_name =
5+
case os[:family]
6+
when 'debian', 'suse'
7+
'vim'
8+
else
9+
'vim-enhanced'
10+
end
11+
12+
describe package(package_name) do
13+
it { should be_installed }
14+
end
15+
end

0 commit comments

Comments
 (0)