Skip to content

Commit 6f7293e

Browse files
authored
Merge pull request #90 from dev-sec/docker
Docker
2 parents e436ebe + 53b52bd commit 6f7293e

File tree

5 files changed

+121
-57
lines changed

5 files changed

+121
-57
lines changed

.kitchen.vagrant.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
driver:
3+
name: vagrant
4+
5+
provisioner:
6+
name: ansible_playbook
7+
test_repo_uri: https://github.com/hardening-io/tests-os-hardening.git
8+
hosts: all
9+
require_ansible_repo: false
10+
require_ansible_omnibus: true
11+
require_chef_for_busser: false
12+
require_ruby_for_busser: false
13+
ansible_verbose: true
14+
roles_path: ../ansible-os-hardening/
15+
playbook: default.yml
16+
17+
platforms:
18+
- name: ubuntu-12.04
19+
driver_config:
20+
box: opscode-ubuntu-12.04
21+
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box
22+
- name: ubuntu-14.04
23+
driver_config:
24+
box: opscode-ubuntu-14.04
25+
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box
26+
- name: centos-6.4
27+
driver_config:
28+
box: opscode-centos-6.4
29+
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box
30+
- name: centos-6.5
31+
driver_config:
32+
box: opscode-centos-6.5
33+
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box
34+
- name: oracle-6.4
35+
driver_config:
36+
box: oracle-6.4
37+
box_url: https://storage.us2.oraclecloud.com/v1/istoilis-istoilis/vagrant/oel64-64.box
38+
- name: oracle-6.5
39+
driver_config:
40+
box: oracle-6.5
41+
box_url: https://storage.us2.oraclecloud.com/v1/istoilis-istoilis/vagrant/oel65-64.box
42+
- name: debian-7
43+
driver_config:
44+
box: debian-7
45+
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.8_chef-provisionerless.box
46+
- name: debian-8
47+
driver_config:
48+
box: debian-8
49+
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-8.1_chef-provisionerless.box
50+
51+
verifier:
52+
name: inspec
53+
sudo: true
54+
inspec_tests:
55+
- https://github.com/dev-sec/tests-os-hardening
56+
57+
suites:
58+
- name: os-ansible_1.9
59+
provisioner:
60+
ansible_version: 1.9.4
61+
- name: os-ansible_latest

.kitchen.yml

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
---
22
driver:
3-
name: vagrant
3+
name: docker
4+
use_sudo: false
5+
privileged: true
6+
7+
transport:
8+
max_ssh_sessions: 5
49

510
provisioner:
611
name: ansible_playbook
@@ -14,53 +19,47 @@ provisioner:
1419
hosts: all
1520
roles_path: ../ansible-os-hardening/
1621
playbook: default.yml
17-
18-
verifier:
19-
name: inspec
20-
sudo: true
21-
inspec_tests:
22-
- https://github.com/dev-sec/tests-os-hardening
22+
ansible_extra_flags:
23+
- "--skip-tags=sysctl"
2324

2425
platforms:
2526
- name: ubuntu-12.04
26-
driver_config:
27-
box: opscode-ubuntu-12.04
28-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box
27+
driver:
28+
image: ubuntu:12.04
2929
- name: ubuntu-14.04
30-
driver_config:
31-
box: opscode-ubuntu-14.04
32-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box
33-
- name: centos-6.4
34-
driver_config:
35-
box: opscode-centos-6.4
36-
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box
37-
- name: centos-6.5
38-
driver_config:
39-
box: opscode-centos-6.5
40-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box
41-
- name: centos-7.2
42-
driver_config:
43-
box: opscode-centos-7.2
44-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.2_chef-provisionerless.box
45-
- name: oracle-6.4
46-
driver_config:
47-
box: oracle-6.4
48-
box_url: https://storage.us2.oraclecloud.com/v1/istoilis-istoilis/vagrant/oel64-64.box
49-
- name: oracle-6.5
50-
driver_config:
51-
box: oracle-6.5
52-
box_url: https://storage.us2.oraclecloud.com/v1/istoilis-istoilis/vagrant/oel65-64.box
30+
driver:
31+
image: ubuntu:14.04
32+
- name: ubuntu-16.04
33+
driver:
34+
image: ubuntu:16.04
35+
provision_command:
36+
- "apt-get install initramfs-tools -y"
37+
- name: centos-6.6
38+
driver:
39+
image: centos:6.6
40+
- name: centos-6.7
41+
driver:
42+
image: centos:6.7
43+
- name: centos-7
44+
driver:
45+
image: centos:7
46+
privileged: true
47+
run_command: /usr/sbin/init
5348
- name: debian-7
54-
driver_config:
55-
box: debian-7
56-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.8_chef-provisionerless.box
49+
driver:
50+
image: debian:7
5751
- name: debian-8
58-
driver_config:
59-
box: debian-8
60-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-8.1_chef-provisionerless.box
52+
driver:
53+
image: debian:8
54+
55+
verifier:
56+
name: inspec
57+
sudo: true
58+
inspec_tests:
59+
- https://github.com/dev-sec/tests-os-hardening
6160

6261
suites:
63-
- name: os-ansible_1.9
62+
- name: os_ansible_1.9
6463
provisioner:
6564
ansible_version: 1.9.4
66-
- name: os-ansible_latest
65+
- name: os_ansible_latest

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ group :integration do
1919
gem 'test-kitchen', '~> 1.0'
2020
gem 'kitchen-ansible'
2121
gem 'kitchen-vagrant'
22-
gem 'kitchen-inspec', '~> 0.9'
22+
gem 'kitchen-inspec'
2323
gem 'kitchen-sharedtests', '~> 0.2.0'
2424
gem 'kitchen-sync'
2525
gem 'kitchen-transport-rsync'
26+
gem 'kitchen-docker'
2627
end
2728

2829
group :openstack do

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,20 @@ Alternatively you can change Ansible's [hash-behaviour](https://docs.ansible.com
137137

138138
## Local Testing
139139

140-
For local testing you can use vagrant and Virtualbox of VMWare to run tests locally. You will have to install Virtualbox and Vagrant on your system. See [Vagrant Downloads](http://downloads.vagrantup.com/) for a vagrant package suitable for your system. For all our tests we use `test-kitchen`. If you are not familiar with `test-kitchen` please have a look at [their guide](http://kitchen.ci/docs/getting-started).
140+
The preferred way of locally testing the role is to use Docker. You will have to install Docker on your system. See [Get started](https://docs.docker.com/) for a Docker package suitable to for your system.
141+
142+
You can also use vagrant and Virtualbox or VMWare to run tests locally. You will have to install Virtualbox and Vagrant on your system. See [Vagrant Downloads](http://downloads.vagrantup.com/) for a vagrant package suitable for your system. For all our tests we use `test-kitchen`. If you are not familiar with `test-kitchen` please have a look at [their guide](http://kitchen.ci/docs/getting-started).
141143

142144
Next install test-kitchen:
143145

144146
```bash
145147
# Install dependencies
146148
gem install bundler
147149
bundle install
150+
```
148151

149-
# Fetch tests
150-
bundle exec thor kitchen:fetch-remote-tests
151-
152+
### Testing with Docker
153+
```
152154
# fast test on one machine
153155
bundle exec kitchen test default-ubuntu-1204
154156
@@ -160,8 +162,19 @@ bundle exec kitchen create default-ubuntu-1204
160162
bundle exec kitchen converge default-ubuntu-1204
161163
```
162164

163-
For more information see [test-kitchen](http://kitchen.ci/docs/getting-started)
165+
### Testing with Virtualbox
166+
```
167+
# fast test on one machine
168+
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen test default-ubuntu-1204
169+
170+
# test on all machines
171+
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen test
164172
173+
# for development
174+
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen create default-ubuntu-1204
175+
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen converge default-ubuntu-1204
176+
```
177+
For more information see [test-kitchen](http://kitchen.ci/docs/getting-started)
165178

166179
## Contributors + Kudos
167180

Thorfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)