Skip to content

Commit cc32672

Browse files
committed
configuring travis-ci tests, using Kitchen with Docker, and Inspec
1 parent 0e697c6 commit cc32672

8 files changed

Lines changed: 135 additions & 17 deletions

File tree

.kitchen.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
driver:
3+
name: docker
4+
5+
driver_config:
6+
use_sudo: false
7+
privileged: true
8+
provision_command: mkdir -p /run/sshd
9+
run_command: /lib/systemd/systemd
10+
11+
platforms:
12+
- name: debian-9
13+
# - name: ubuntu-18.04
14+
# - name: fedora-27
15+
# - name: centos-7
16+
17+
provisioner:
18+
name: salt_solo
19+
log_level: info
20+
require_chef: false
21+
salt_install: bootstrap
22+
salt_version: latest
23+
salt_bootstrap_url: https://bootstrap.saltstack.com
24+
salt_bootstrap_options: -X -p git -p curl -p sudo
25+
26+
formula: haproxy
27+
dependencies:
28+
- name: hosts
29+
path: ./test/salt/salt
30+
31+
pillars_from_files:
32+
haproxy.sls: pillar.example
33+
hosts.sls: ./test/salt/pillar/hosts.sls
34+
35+
pillars:
36+
top.sls:
37+
base:
38+
"*":
39+
- hosts
40+
- haproxy
41+
42+
state_top:
43+
base:
44+
'*':
45+
- hosts
46+
- haproxy
47+
48+
verifier:
49+
name: inspec
50+
reporter:
51+
- cli
52+
inspec_tests:
53+
- path: test/integration/default
54+
55+
suites:
56+
- name: default
57+

.travis.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
sudo: required
2+
cache: bundler
3+
language: ruby
4+
5+
services:
6+
- docker
7+
8+
before_install:
9+
- bundle install
10+
11+
env:
12+
matrix:
13+
- INSTANCE: default-debian-9
14+
# - INSTANCE: default-ubuntu-1804
15+
# - INSTANCE: default-fedora-27
16+
# - INSTANCE: default-centos-7
17+
18+
script:
19+
- bundle exec kitchen verify ${INSTANCE}
20+

Gemfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gem 'test-kitchen'
6+
gem 'kitchen-docker'
7+
gem 'kitchen-salt'
8+
gem 'kitchen-inspec'
9+

pillar.example

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,23 @@ haproxy:
121121
- "X-Forwarded-Proto:\\ http"
122122
default_backend: www-backend
123123

124-
www-https:
125-
bind: "*:443 ssl crt /etc/ssl/private/certificate-chain-and-key-combined.pem"
126-
logformat: "%ci:%cp\\ [%t]\\ %ft\\ %b/%s\\ %Tq/%Tw/%Tc/%Tr/%Tt\\ %ST\\ %B\\ %CC\\ %CS\\ %tsc\\ %ac/%fc/%bc/%sc/%rc\\ %sq/%bq\\ %hr\\ %hs\\ %{+Q}r\\ ssl_version:%sslv\\ ssl_cipher:%sslc"
127-
reqadds:
128-
- "X-Forwarded-Proto:\\ https"
129-
default_backend: www-backend
130-
acls:
131-
- url_static path_beg -i /static /images /javascript /stylesheets
132-
- url_static path_end -i .jpg .gif .png .css .js
133-
use_backends:
134-
- static-backend if url_static
135-
extra: "rspadd Strict-Transport-Security:\ max-age=15768000"
136-
some-services:
137-
bind:
138-
- "*:8080"
139-
- "*:8088"
140-
default_backend: api-backend
124+
# www-https:
125+
# bind: "*:443 ssl crt /etc/ssl/private/certificate-chain-and-key-combined.pem"
126+
# logformat: "%ci:%cp\\ [%t]\\ %ft\\ %b/%s\\ %Tq/%Tw/%Tc/%Tr/%Tt\\ %ST\\ %B\\ %CC\\ %CS\\ %tsc\\ %ac/%fc/%bc/%sc/%rc\\ %sq/%bq\\ %hr\\ %hs\\ %{+Q}r\\ ssl_version:%sslv\\ ssl_cipher:%sslc"
127+
# reqadds:
128+
# - "X-Forwarded-Proto:\\ https"
129+
# default_backend: www-backend
130+
# acls:
131+
# - url_static path_beg -i /static /images /javascript /stylesheets
132+
# - url_static path_end -i .jpg .gif .png .css .js
133+
# use_backends:
134+
# - static-backend if url_static
135+
# extra: "rspadd Strict-Transport-Security:\ max-age=15768000"
136+
# some-services:
137+
# bind:
138+
# - "*:8080"
139+
# - "*:8088"
140+
# default_backend: api-backend
141141

142142
backends:
143143
backend1:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
title 'Verify haproxy installation'
2+
3+
describe package('haproxy') do
4+
it { should be_installed }
5+
end
6+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: default
2+
title: Default Profile
3+
version: 0.1.0
4+
supports:
5+
- os-name: debian
6+

test/salt/pillar/hosts.sls

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
hosts:
2+
- server1: 127.0.0.1
3+
- server2: 127.0.0.1
4+
- web1.example.com: 127.0.0.1
5+
- web2.example.com: 127.0.0.1
6+
- web3.example.com: 127.0.0.1
7+
- apiserver1.example.com: 127.0.0.1
8+
- apiserver2.example.com: 127.0.0.1
9+

test/salt/salt/hosts/init.sls

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
{% set hosts = salt['pillar.get']('hosts', []) %}
3+
4+
{% for host in hosts %}
5+
{% for name, ip in host.items() %}
6+
{{ name }}:
7+
host.present:
8+
- ip: {{ ip }}
9+
{% endfor %}
10+
{% endfor %}
11+

0 commit comments

Comments
 (0)