Skip to content

Commit 987a333

Browse files
authored
Merge pull request #110 from dev-sec/docker
use new Docker images
2 parents 0779022 + dfc5056 commit 987a333

File tree

11 files changed

+117
-99
lines changed

11 files changed

+117
-99
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: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ driver:
99

1010
provisioner:
1111
name: ansible_playbook
12-
test_repo_uri: https://github.com/hardening-io/tests-os-hardening.git
1312
hosts: all
1413
require_ansible_repo: false
1514
require_ansible_omnibus: true
@@ -21,6 +20,9 @@ provisioner:
2120
http_proxy: <%= ENV['http_proxy'] || nil %>
2221
https_proxy: <%= ENV['https_proxy'] || nil %>
2322

23+
transport:
24+
max_ssh_sessions: 5
25+
2426
platforms:
2527
- name: ubuntu-12.04
2628
driver_config:
@@ -30,6 +32,10 @@ platforms:
3032
driver_config:
3133
box: opscode-ubuntu-14.04
3234
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box
35+
- name: ubuntu-16.04
36+
driver_config:
37+
box: opscode-ubuntu-16.04
38+
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-16.04_chef-provisionerless.box
3339
- name: centos-6.4
3440
driver_config:
3541
box: opscode-centos-6.4
@@ -68,10 +74,7 @@ verifier:
6874
name: inspec
6975
sudo: true
7076
inspec_tests:
71-
- https://github.com/dev-sec/tests-os-hardening
77+
- https://github.com/dev-sec/linux-baseline/
7278

7379
suites:
74-
- name: os-ansible_1.9
75-
provisioner:
76-
ansible_version: 1.9.4
77-
- name: os-ansible_latest
80+
- name: os

.kitchen.yml

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ provisioner:
1313
name: ansible_playbook
1414
hosts: all
1515
require_ansible_repo: false
16-
require_ansible_omnibus: true
1716
require_chef_for_busser: false
1817
require_ruby_for_busser: false
1918
ansible_verbose: true
@@ -27,44 +26,46 @@ provisioner:
2726
- "--skip-tags=sysctl"
2827

2928
platforms:
30-
- name: ubuntu-12.04
29+
- name: centos6-ansible-latest
3130
driver:
32-
image: ubuntu:12.04
33-
- name: ubuntu-14.04
31+
image: rndmh3ro/docker-centos6-ansible:latest
32+
platform: centos
33+
- name: centos7-ansible-latest
3434
driver:
35-
image: ubuntu:14.04
36-
- name: ubuntu-16.04
35+
image: rndmh3ro/docker-centos7-ansible:latest
36+
platform: centos
37+
- name: oracle6-ansible-latest
3738
driver:
38-
image: ubuntu:16.04
39-
provision_command:
40-
- "apt-get install initramfs-tools -y"
41-
- name: centos-6.6
39+
image: rndmh3ro/docker-oracle6-ansible:latest
40+
platform: centos
41+
- name: oracle7-ansible-latest
4242
driver:
43-
image: centos:6.6
44-
- name: centos-6.7
43+
image: rndmh3ro/docker-oracle7-ansible:latest
44+
platform: centos
45+
- name: ubuntu1204-ansible-latest
4546
driver:
46-
image: centos:6.7
47-
- name: centos-7
47+
image: rndmh3ro/docker-ubuntu1204-ansible:latest
48+
platform: ubuntu
49+
- name: ubuntu1404-ansible-latest
4850
driver:
49-
image: centos:7
50-
privileged: true
51-
run_command: /usr/sbin/init
52-
- name: oracle-6
51+
image: rndmh3ro/docker-ubuntu1404-ansible:latest
52+
platform: ubuntu
53+
- name: ubuntu1604-ansible-latest
5354
driver:
54-
image: oraclelinux:6
55-
platform: rhel
56-
- name: oracle-7
55+
image: rndmh3ro/docker-ubuntu1604-ansible:latest
56+
platform: ubuntu
57+
- name: debian7-ansible-latest
5758
driver:
58-
image: oraclelinux:7
59-
platform: rhel
60-
privileged: true
61-
run_command: /usr/sbin/init
62-
- name: debian-7
59+
image: rndmh3ro/docker-debian7-ansible:latest
60+
platform: debian
61+
- name: debian8-ansible-latest
6362
driver:
64-
image: debian:7
65-
- name: debian-8
63+
image: rndmh3ro/docker-debian8-ansible:latest
64+
platform: debian
65+
- name: debian9-ansible-latest
6666
driver:
67-
image: debian:8
67+
image: rndmh3ro/docker-debian9-ansible:latest
68+
platform: debian
6869

6970
verifier:
7071
name: inspec
@@ -73,7 +74,4 @@ verifier:
7374
- https://github.com/dev-sec/tests-os-hardening
7475

7576
suites:
76-
- name: os_ansible_1.9
77-
provisioner:
78-
ansible_version: 1.9.4
79-
- name: os_ansible_latest
77+
- name: os

.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: ubuntu1204
33+
version: latest
34+
init: /sbin/init
35+
36+
- distro: debian7
37+
version: latest
38+
init: /sbin/init
39+
40+
- distro: debian8
41+
version: latest
42+
init: /sbin/init
43+
44+
- distro: debian9
45+
version: latest
46+
init: /lib/systemd/systemd
47+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
1048

1149
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
50+
# Pull container
51+
- 'docker pull rndmh3ro/docker-${distro}-ansible:${version}'
1852

1953
script:
20-
- ansible-playbook --syntax-check spec/travis.yml
21-
- ansible-playbook --sudo -v --diff spec/travis.yml --skip-tags "sysctl" --extra-vars "os_security_users_allow=change_user os_security_kernel_enable_core_dump=true os_security_suid_sgid_remove_from_unknown=true"
22-
- ansible-playbook --sudo -v --diff spec/travis.yml --tags "pam" --extra-vars "os_auth_pam_passwdqc_enable=false"
23-
- ansible-playbook --sudo -v --diff spec/travis.yml --skip-tags "sysctl" --extra-vars "os_security_users_allow=change_user"
54+
- container_id=$(mktemp)
55+
# Run container in detached state.
56+
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/ansible-os-hardening:ro ${run_opts} rndmh3ro/docker-${distro}-ansible:${version} "${init}" > "${container_id}"'
57+
58+
# Test role.
59+
- 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/ansible-os-hardening/default.yml --skip-tags "sysctl"'
60+
61+
# Verify role
62+
- 'inspec exec https://github.com/dev-sec/linux-baseline/ -t docker://$(cat ${container_id}) --controls=os-01 os-02 os-03 os-04 os-05 os-06 os-07 package-01 package-02 package-03 package-04 package-05 package-06'
63+
64+
notifications:
65+
webhooks: https://galaxy.ansible.com/api/v1/notifications/

Gemfile

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

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

5-
group :test do
6-
gem 'rake'
7-
gem 'foodcritic', '~> 4.0'
8-
gem 'thor-foodcritic'
9-
gem 'coveralls', require: false
10-
end
11-
12-
group :development do
13-
gem 'guard'
14-
gem 'guard-rspec'
15-
gem 'guard-kitchen'
16-
end
17-
185
group :integration do
196
gem 'test-kitchen', '~> 1.0'
207
gem 'kitchen-ansible'
@@ -26,10 +13,6 @@ group :integration do
2613
gem 'kitchen-docker'
2714
end
2815

29-
group :openstack do
30-
gem 'kitchen-openstack'
31-
end
32-
3316
group :tools do
3417
gem 'github_changelog_generator', '~> 1'
3518
end

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ It will not:
2727

2828
## Requirements
2929

30-
* Ansible
30+
* Ansible 2.2.1
3131

3232
## Variables
3333

ansible.cfg

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
# additional paths to search for roles in, colon separated
14+
roles_path = ../
15+

kitchen_vagrant_block.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
# This is a Vagrant block to allow proxy settings to be carried into Kitchen
22
# 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
63

74
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
155
end

meta/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ galaxy_info:
44
description: 'This Ansible role provides numerous security-related configurations, providing all-round base protection.'
55
company: Hardening Framework Team
66
license: Apache License 2.0
7-
min_ansible_version: '1.9'
7+
min_ansible_version: '2.2.1'
88
platforms:
99
- name: EL
1010
versions:

spec/travis.yml

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

0 commit comments

Comments
 (0)