Skip to content

Commit 4a9b7e7

Browse files
authored
Merge pull request #7 from n-rodriguez/wip/ci
Add tofs, use pre-salted images
2 parents 16169a5 + f27ec2e commit 4a9b7e7

30 files changed

+720
-343
lines changed

.travis.yml

+21-4
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,31 @@ language: ruby
1111
services:
1212
- docker
1313

14+
# Make sure the instances listed below match up with
15+
# the `platforms` defined in `kitchen.yml`
1416
env:
1517
matrix:
16-
- DISTRIB=debian:stretch/9
17-
- DISTRIB=ubuntu:xenial/16.04
18-
- DISTRIB=ubuntu:bionic/18.04
18+
- INSTANCE: default-debian-9-2019-2-py3
19+
- INSTANCE: default-ubuntu-1804-2019-2-py3
20+
- INSTANCE: default-centos-7-2019-2-py3
21+
- INSTANCE: default-fedora-29-2019-2-py3
22+
- INSTANCE: default-opensuse-leap-15-2019-2-py3
23+
# - INSTANCE: default-debian-9-2018-3-py2
24+
# - INSTANCE: default-ubuntu-1604-2018-3-py2
25+
# - INSTANCE: default-centos-7-2018-3-py2
26+
# - INSTANCE: default-fedora-29-2018-3-py2
27+
# TODO: Use this when fixed instead of `opensuse-leap-42`
28+
# Ref: https://github.com/netmanagers/salt-image-builder/issues/2
29+
# - INSTANCE: default-opensuse-leap-15-2018-3-py2
30+
# - INSTANCE: default-opensuse-leap-42-2018-3-py2
31+
# - INSTANCE: default-debian-8-2017-7-py2
32+
# - INSTANCE: default-ubuntu-1604-2017-7-py2
33+
# - INSTANCE: default-centos-6-2017-7-py2
34+
# - INSTANCE: default-fedora-28-2017-7-py2
35+
# - INSTANCE: default-opensuse-leap-42-2017-7-py2
1936

2037
script:
21-
- bundle exec kitchen test
38+
- bundle exec kitchen verify ${INSTANCE}
2239

2340
jobs:
2441
include:

kitchen.yml

+94-29
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,103 @@
1-
<%
2-
distrib, infos = ENV.fetch('DISTRIB', 'debian:stretch/9').split(':')
3-
codename, version = infos.split('/')
4-
%>
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
53
---
4+
# For help on this file's format, see https://kitchen.ci/
65
driver:
76
name: docker
87
use_sudo: false
98
privileged: true
9+
run_command: /lib/systemd/systemd
1010

11-
provisioner:
12-
name: salt_solo
13-
formula: ufw
11+
# Make sure the platforms listed below match up with
12+
# the `env.matrix` instances defined in `.travis.yml`
13+
platforms:
14+
## SALT 2019.2
15+
- name: debian-9-2019-2-py3
16+
driver:
17+
image: netmanagers/salt-2019.2-py3:debian-9
18+
provision_command:
19+
- apt-get update && apt-get install -y locales
20+
- echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
21+
- locale-gen en_US.UTF-8
22+
- name: ubuntu-1804-2019-2-py3
23+
driver:
24+
image: netmanagers/salt-2019.2-py3:ubuntu-18.04
25+
- name: centos-7-2019-2-py3
26+
driver:
27+
image: netmanagers/salt-2019.2-py3:centos-7
28+
- name: fedora-29-2019-2-py3
29+
driver:
30+
image: netmanagers/salt-2019.2-py3:fedora-29
31+
- name: opensuse-leap-15-2019-2-py3
32+
driver:
33+
image: netmanagers/salt-2019.2-py3:opensuse-leap-15
34+
run_command: /usr/lib/systemd/systemd
1435

15-
# Install Salt from official repositories
16-
salt_install: apt
17-
salt_version: latest
18-
salt_apt_repo: https://repo.saltstack.com/apt/<%= distrib %>/<%= version %>/amd64
19-
salt_apt_repo_key: https://repo.saltstack.com/apt/<%= distrib %>/<%= version %>/amd64/latest/SALTSTACK-GPG-KEY.pub
36+
## SALT 2018.3
37+
- name: debian-9-2018-3-py2
38+
driver:
39+
image: netmanagers/salt-2018.3-py2:debian-9
40+
provision_command:
41+
- apt-get update && apt-get install -y locales
42+
- echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
43+
- locale-gen en_US.UTF-8
44+
- name: ubuntu-1604-2018-3-py2
45+
driver:
46+
image: netmanagers/salt-2018.3-py2:ubuntu-16.04
47+
- name: centos-7-2018-3-py2
48+
driver:
49+
image: netmanagers/salt-2018.3-py2:centos-7
50+
- name: fedora-29-2018-3-py2
51+
driver:
52+
image: netmanagers/salt-2018.3-py2:fedora-29
53+
# TODO: Use this when fixed instead of `opensuse-leap-42`
54+
# Ref: https://github.com/netmanagers/salt-image-builder/issues/2
55+
# - name: opensuse-leap-15-2018-3-py2
56+
# driver:
57+
# image: netmanagers/salt-2018.3-py2:opensuse-leap-15
58+
# run_command: /usr/lib/systemd/systemd
59+
- name: opensuse-leap-42-2018-3-py2
60+
driver:
61+
image: netmanagers/salt-2018.3-py2:opensuse-leap-42
62+
run_command: /usr/lib/systemd/systemd
2063

21-
# Don't install Chef
22-
require_chef: false
64+
## SALT 2017.7
65+
- name: debian-8-2017-7-py2
66+
driver:
67+
image: netmanagers/salt-2017.7-py2:debian-8
68+
provision_command:
69+
- apt-get update && apt-get install -y locales
70+
- echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
71+
- locale-gen en_US.UTF-8
72+
- name: ubuntu-1604-2017-7-py2
73+
driver:
74+
image: netmanagers/salt-2017.7-py2:ubuntu-16.04
75+
- name: centos-6-2017-7-py2
76+
driver:
77+
image: netmanagers/salt-2017.7-py2:centos-6
78+
run_command: /sbin/init
79+
run_options: -v /lib/modules:/lib/modules:ro
80+
- name: fedora-28-2017-7-py2
81+
driver:
82+
image: netmanagers/salt-2017.7-py2:fedora-28
83+
- name: opensuse-leap-42-2017-7-py2
84+
driver:
85+
image: netmanagers/salt-2017.7-py2:opensuse-leap-42
86+
run_command: /usr/lib/systemd/systemd
2387

24-
# Configure Salt
88+
provisioner:
89+
name: salt_solo
90+
log_level: info
91+
salt_install: none
92+
require_chef: false
93+
formula: ufw
94+
salt_copy_filter:
95+
- .kitchen
96+
- .git
2597
state_top:
2698
base:
2799
'*':
28100
- ufw
29-
30101
pillars:
31102
top.sls:
32103
base:
@@ -67,21 +138,15 @@ provisioner:
67138
protocol: tcp
68139
comment: Allow HTTPS
69140

70-
platforms:
71-
- name: <%= distrib %>-<%= codename %>
72-
driver_config:
73-
image: "<%= distrib %>:<%= codename %>"
74-
platform: <%= distrib %>
75-
provision_command:
76-
- apt-get update && apt-get install -y locales
77-
- echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
78-
- locale-gen en_US.UTF-8
79-
run_command: /lib/systemd/systemd
80-
81141
verifier:
142+
# https://www.inspec.io/
82143
name: inspec
144+
sudo: true
145+
# cli, documentation, html, progress, json, json-min, json-rspec, junit
83146
reporter:
84-
- progress
147+
- cli
148+
inspec_tests:
149+
- path: test/integration/default
85150

86151
suites:
87-
- name: ufw
152+
- name: default
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
control 'UFW configuration' do
2+
3+
title 'Test UFW configuration'
4+
5+
describe directory('/etc/ufw') do
6+
it { should exist }
7+
end
8+
9+
describe file('/etc/ufw/ufw.conf') do
10+
its('content') { should include 'ENABLED=' }
11+
its('content') { should include 'LOGLEVEL=' }
12+
end
13+
14+
describe command('ufw status verbose | grep Status') do
15+
its('exit_status') { should eq 0 }
16+
its('stdout') { should match /active/ }
17+
end
18+
19+
describe command('ufw status verbose | grep Logging') do
20+
its('exit_status') { should eq 0 }
21+
its('stdout') { should match /low/ }
22+
end
23+
24+
describe command('ufw status | grep MySQL') do
25+
its('exit_status') { should eq 0 }
26+
its('stdout') { should match /ALLOW/ }
27+
end
28+
29+
describe command('ufw status | grep Postgresql') do
30+
its('exit_status') { should eq 0 }
31+
its('stdout') { should match /LIMIT/ }
32+
end
33+
34+
describe command('ufw status | grep SSH223') do
35+
its('exit_status') { should eq 0 }
36+
its('stdout') { should match /DENY/ }
37+
end
38+
39+
describe command('ufw status | grep 10.0.0.0') do
40+
its('exit_status') { should eq 0 }
41+
its('stdout') { should match /DENY/ }
42+
end
43+
44+
describe command('ufw status | grep 22/tcp') do
45+
its('exit_status') { should eq 0 }
46+
its('stdout') { should match /LIMIT/ }
47+
end
48+
49+
describe command('ufw status | grep 80/tcp') do
50+
its('exit_status') { should eq 0 }
51+
its('stdout') { should match /DENY/ }
52+
end
53+
54+
describe command('ufw status | grep 443/tcp') do
55+
its('exit_status') { should eq 0 }
56+
its('stdout') { should match /ALLOW/ }
57+
end
58+
59+
describe command('ufw status | grep 10.0.0.1') do
60+
its('exit_status') { should eq 0 }
61+
its('stdout') { should match /DENY/ }
62+
end
63+
64+
describe command('ufw status | grep 10.0.0.2') do
65+
its('exit_status') { should eq 0 }
66+
its('stdout') { should match /DENY/ }
67+
end
68+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
control 'UFW package' do
2+
title 'should be installed'
3+
4+
describe package('ufw') do
5+
it { should be_installed }
6+
end
7+
end

test/integration/default/inspec.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: ufw
2+
title: UFW Formula
3+
maintainer: Alexandre Anriot
4+
license: Apache-2.0
5+
summary: Verify that the ufw formula is setup and configured correctly
6+
supports:
7+
- os-name: debian
8+
- os-name: ubuntu
9+
- os-name: centos
10+
- os-name: fedora
11+
- os-name: opensuse
12+
- os-name: suse

test/integration/ufw/controls/ufw.rb

-71
This file was deleted.

test/integration/ufw/inspec.yml

-10
This file was deleted.

0 commit comments

Comments
 (0)