Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit 72fd6f1

Browse files
authored
Merge pull request #8 from dev-sec/docker
use new Docker images
2 parents 6e0fc63 + e3073ba commit 72fd6f1

File tree

7 files changed

+155
-85
lines changed

7 files changed

+155
-85
lines changed

.gitignore

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
README.pdf
2-
README.html
3-
shared_test_repo/
4-
test/integration
51
.kitchen
6-
coverage
7-
Vagrantfile.erb
8-
9-
Gemfile.lock
10-
Berksfile.lock
11-
12-
ansible.cfg
132
hosts
3+
Gemfile.lock

.kitchen.vagrant.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
---
22
driver:
33
name: vagrant
4+
driver_config:
5+
http_proxy: <%= ENV['http_proxy'] || nil %>
6+
https_proxy: <%= ENV['https_proxy'] || nil %>
7+
vagrantfiles:
8+
- kitchen_vagrant_block.rb
49

510
provisioner:
611
name: ansible_playbook
7-
test_repo_uri: https://github.com/hardening-io/tests-ssh-hardening.git
812
hosts: all
913
require_ansible_repo: false
1014
require_ansible_omnibus: true
1115
require_chef_for_busser: false
1216
require_ruby_for_busser: false
1317
ansible_verbose: true
14-
roles_path: ../ansible-ssh-hardening/
18+
roles_path: ../ansible-nginx-hardening/
19+
requirements_path: requirements.yml
1520
playbook: default.yml
21+
http_proxy: <%= ENV['http_proxy'] || nil %>
22+
https_proxy: <%= ENV['https_proxy'] || nil %>
23+
24+
transport:
25+
max_ssh_sessions: 5
1626

1727
platforms:
1828
- name: ubuntu-12.04
@@ -23,6 +33,10 @@ platforms:
2333
driver_config:
2434
box: opscode-ubuntu-14.04
2535
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box
36+
- name: ubuntu-16.04
37+
driver_config:
38+
box: opscode-ubuntu-16.04
39+
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-16.04_chef-provisionerless.box
2640
- name: centos-6.4
2741
driver_config:
2842
box: opscode-centos-6.4
@@ -31,6 +45,12 @@ platforms:
3145
driver_config:
3246
box: opscode-centos-6.5
3347
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box
48+
- name: centos-6.8
49+
driver_config:
50+
box: bento/centos-6.8
51+
- name: centos-7
52+
driver_config:
53+
box: bento/centos-7.2
3454
- name: oracle-6.4
3555
driver_config:
3656
box: oracle-6.4
@@ -39,10 +59,9 @@ platforms:
3959
driver_config:
4060
box: oracle-6.5
4161
box_url: https://storage.us2.oraclecloud.com/v1/istoilis-istoilis/vagrant/oel65-64.box
42-
- name: debian-6
62+
- name: oracle-7
4363
driver_config:
44-
box: debian-6
45-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-6.0.10_chef-provisionerless.box
64+
box: boxcutter/ol72
4665
- name: debian-7
4766
driver_config:
4867
box: debian-7
@@ -56,10 +75,7 @@ verifier:
5675
name: inspec
5776
sudo: true
5877
inspec_tests:
59-
- https://github.com/dev-sec/tests-ssh-hardening
78+
- https://github.com/dev-sec/nginx-baseline/
6079

6180
suites:
62-
- name: nginx-ansible_1.9
63-
provisioner:
64-
ansible_version: 1.9.4
65-
- name: nginx-ansible_latest
81+
- name: nginx

.kitchen.yml

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
driver:
33
name: docker
44
use_sudo: false
5+
privileged: true
6+
http_proxy: <%= ENV['http_proxy'] || nil %>
7+
https_proxy: <%= ENV['https_proxy'] || nil %>
58

69
transport:
710
max_ssh_sessions: 5
@@ -10,51 +13,64 @@ provisioner:
1013
name: ansible_playbook
1114
hosts: all
1215
require_ansible_repo: false
13-
require_ansible_omnibus: true
1416
require_chef_for_busser: false
1517
require_ruby_for_busser: false
1618
ansible_verbose: true
1719
ansible_diff: true
18-
requirements_path: requirements.yml
20+
hosts: all
1921
roles_path: ../ansible-nginx-hardening/
22+
http_proxy: <%= ENV['http_proxy'] || nil %>
23+
https_proxy: <%= ENV['https_proxy'] || nil %>
2024
playbook: default.yml
25+
requirements_path: requirements.yml
2126

2227
platforms:
23-
- name: ubuntu-12.04
28+
- name: centos6-ansible-latest
29+
driver:
30+
image: rndmh3ro/docker-centos6-ansible:latest
31+
platform: centos
32+
- name: centos7-ansible-latest
33+
driver:
34+
image: rndmh3ro/docker-centos7-ansible:latest
35+
platform: centos
36+
- name: oracle6-ansible-latest
2437
driver:
25-
image: ubuntu:12.04
26-
- name: ubuntu-14.04
38+
image: rndmh3ro/docker-oracle6-ansible:latest
39+
platform: centos
40+
- name: oracle7-ansible-latest
2741
driver:
28-
image: ubuntu:14.04
29-
- name: ubuntu-16.04
42+
image: rndmh3ro/docker-oracle7-ansible:latest
43+
platform: centos
44+
- name: ubuntu1204-ansible-latest
3045
driver:
31-
image: ubuntu:16.04
32-
- name: centos-6.7
46+
image: rndmh3ro/docker-ubuntu1204-ansible:latest
47+
platform: ubuntu
48+
- name: ubuntu1404-ansible-latest
3349
driver:
34-
image: centos:6.7
35-
- name: centos-6.8
50+
image: rndmh3ro/docker-ubuntu1404-ansible:latest
51+
platform: ubuntu
52+
- name: ubuntu1604-ansible-latest
3653
driver:
37-
image: centos:6.8
38-
- name: centos-7
54+
image: rndmh3ro/docker-ubuntu1604-ansible:latest
55+
platform: ubuntu
56+
- name: debian7-ansible-latest
3957
driver:
40-
image: centos:7
41-
privileged: true
42-
run_command: /usr/sbin/init
43-
- name: debian-7
58+
image: rndmh3ro/docker-debian7-ansible:latest
59+
platform: debian
60+
- name: debian8-ansible-latest
4461
driver:
45-
image: debian:7
46-
- name: debian-8
62+
image: rndmh3ro/docker-debian8-ansible:latest
63+
platform: debian
64+
- name: debian9-ansible-latest
4765
driver:
48-
image: debian:8
66+
image: rndmh3ro/docker-debian9-ansible:latest
67+
platform: debian
4968

5069
verifier:
5170
name: inspec
5271
sudo: true
5372
inspec_tests:
54-
- https://github.com/dev-sec/tests-nginx-hardening
73+
- https://github.com/dev-sec/nginx-baseline
5574

5675
suites:
57-
- name: nginx-ansible_1.9
58-
provisioner:
59-
ansible_version: 1.9.4
60-
- name: nginx-ansible_latest
76+
- name: nginx

.travis.yml

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,65 @@
11
---
2-
notifications:
3-
webhooks: https://galaxy.ansible.com/api/v1/notifications/
4-
language: python
5-
python: "2.7"
2+
services: docker
63

74
env:
8-
- ANSIBLE_VERSION=latest
9-
- ANSIBLE_VERSION=1.9.4
5+
- distro: centos6
6+
version: latest
7+
init: /sbin/init
8+
9+
- distro: centos7
10+
init: /usr/lib/systemd/systemd
11+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
12+
version: latest
13+
14+
- distro: oracle6
15+
version: latest
16+
init: /sbin/init
17+
18+
- distro: oracle7
19+
init: /usr/lib/systemd/systemd
20+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
21+
version: latest
22+
23+
- distro: ubuntu1604
24+
version: latest
25+
init: /lib/systemd/systemd
26+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
27+
28+
- distro: ubuntu1404
29+
version: latest
30+
init: /sbin/init
31+
32+
# - distro: debian7
33+
# version: latest
34+
# init: /sbin/init
35+
36+
- distro: debian8
37+
version: latest
38+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
39+
init: /sbin/init
40+
41+
- distro: debian9
42+
version: latest
43+
init: /lib/systemd/systemd
44+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
1045

1146
before_install:
12-
- sudo apt-get update -qq
13-
- sudo apt-get install -qq python-apt python-pycurl
14-
install:
15-
- if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible; else pip install ansible==$ANSIBLE_VERSION; fi
16-
- echo -e 'localhost ansible_connection=local' > spec/inventory
17-
- echo -e '[defaults]\nroles_path = ../\nhostfile = ./spec/inventory' > ansible.cfg
47+
# Pull container
48+
- 'docker pull rndmh3ro/docker-${distro}-ansible:${version}'
1849

1950
script:
20-
- ansible-galaxy install -r requirements.yml
21-
- ansible-playbook --syntax-check spec/travis.yml
22-
- ansible-playbook --sudo -v --diff spec/travis.yml
23-
- ansible-playbook --sudo -v --diff spec/travis.yml --extra-vars "nginx_remove_default_site=false"
51+
- container_id=$(mktemp)
52+
# Run container in detached state.
53+
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/ansible-nginx-hardening:ro ${run_opts} rndmh3ro/docker-${distro}-ansible:${version} "${init}" > "${container_id}"'
54+
55+
# Install ansible galaxy requirements
56+
- 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/ansible-nginx-hardening/requirements.yml -p /etc/ansible/roles/'
57+
58+
# Test role.
59+
- 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/ansible-nginx-hardening/default.yml -vv'
60+
61+
# Verify role
62+
- 'inspec exec https://github.com/dev-sec/nginx-baseline/ -t docker://$(cat ${container_id})'
63+
64+
notifications:
65+
webhooks: https://galaxy.ansible.com/api/v1/notifications/

Gemfile

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,6 @@
22

33
source 'https://rubygems.org'
44

5-
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.2')
6-
gem 'rack', '< 2.0'
7-
gem 'ruby_dep', '< 1.4.0'
8-
gem 'listen', '< 3.0.0'
9-
end
10-
11-
group :test do
12-
gem 'rake'
13-
gem 'foodcritic', '~> 4.0'
14-
gem 'thor-foodcritic'
15-
gem 'coveralls', require: false
16-
end
17-
18-
group :development do
19-
gem 'guard'
20-
gem 'guard-rspec'
21-
gem 'guard-kitchen'
22-
end
23-
245
group :integration do
256
gem 'test-kitchen', '~> 1.0'
267
gem 'kitchen-ansible'
@@ -32,10 +13,6 @@ group :integration do
3213
gem 'kitchen-docker'
3314
end
3415

35-
group :openstack do
36-
gem 'kitchen-openstack'
37-
end
38-
3916
group :tools do
4017
gem 'github_changelog_generator', '~> 1'
4118
end

ansible.cfg

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# config file for ansible -- http://ansible.com/
2+
# ==============================================
3+
4+
# nearly all parameters can be overridden in ansible-playbook
5+
# or with command line flags. ansible will read ANSIBLE_CONFIG,
6+
# ansible.cfg in the current working directory, .ansible.cfg in
7+
# the home directory or /etc/ansible/ansible.cfg, whichever it
8+
# finds first
9+
10+
[defaults]
11+
ansible_managed = Ansible managed: {file} modified on %Y-%m-%d by {uid} on {host}
12+
13+
role_path = /vagrant
14+
scp_if_ssh = True

kitchen_vagrant_block.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This is a Vagrant block to allow proxy settings to be carried into Kitchen
2+
# You need this for all of yum/apt etc. to work!
3+
unless ENV['http_proxy'].empty? || Vagrant.has_plugin?("vagrant-proxyconf")
4+
raise "Missing required plugin 'vagrant-proxyconf' to support HTTP(S) proxies, run `vagrant plugin install vagrant-proxyconf`"
5+
end
6+
7+
Vagrant.configure(2) do |config|
8+
config.proxy.http = "#{ENV['http_proxy']}"
9+
config.proxy.https = "#{ENV['https_proxy']}"
10+
config.proxy.no_proxy = "localhost,127.0.0.1"
11+
12+
# You may have vagrant-vbguest plugin installed to keep your images up to date
13+
# - but will probably have VBoxAddition build issues with the foreign boxes listed in .kitchen.vagrant.yml
14+
config.vbguest.auto_update = false
15+
end

0 commit comments

Comments
 (0)