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

Commit 98034c0

Browse files
authored
Merge pull request #91 from dev-sec/docker
use new docker images
2 parents ca24738 + d12627a commit 98034c0

File tree

9 files changed

+170
-88
lines changed

9 files changed

+170
-88
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: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
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
@@ -13,6 +17,11 @@ provisioner:
1317
ansible_verbose: true
1418
roles_path: ../ansible-ssh-hardening/
1519
playbook: default.yml
20+
http_proxy: <%= ENV['http_proxy'] || nil %>
21+
https_proxy: <%= ENV['https_proxy'] || nil %>
22+
23+
transport:
24+
max_ssh_sessions: 5
1625

1726
transport:
1827
max_ssh_sessions: 5
@@ -27,6 +36,11 @@ platforms:
2736
driver_config:
2837
box: opscode-ubuntu-14.04
2938
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box
39+
- name: ubuntu-16.04
40+
driver_config:
41+
box: opscode-ubuntu-16.04
42+
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-16.04_chef-provisionerless.box
43+
- name: centos-6.4
3044
- name: centos-7.2
3145
driver_config:
3246
box: opscode-centos-7.2
@@ -35,6 +49,12 @@ platforms:
3549
driver_config:
3650
box: opscode-centos-6.5
3751
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box
52+
- name: centos-6.8
53+
driver_config:
54+
box: bento/centos-6.8
55+
- name: centos-7
56+
driver_config:
57+
box: bento/centos-7.2
3858
- name: oracle-6.4
3959
driver_config:
4060
box: oracle-6.4
@@ -43,10 +63,9 @@ platforms:
4363
driver_config:
4464
box: oracle-6.5
4565
box_url: https://storage.us2.oraclecloud.com/v1/istoilis-istoilis/vagrant/oel65-64.box
46-
- name: debian-6
66+
- name: oracle-7
4767
driver_config:
48-
box: debian-6
49-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-6.0.10_chef-provisionerless.box
68+
box: boxcutter/ol72
5069
- name: debian-7
5170
driver_config:
5271
box: debian-7
@@ -60,7 +79,7 @@ verifier:
6079
name: inspec
6180
sudo: true
6281
inspec_tests:
63-
- https://github.com/dev-sec/tests-ssh-hardening
82+
- https://github.com/dev-sec/ssh-baseline/
6483

6584
suites:
66-
- name: ssh-ansible_latest
85+
- name: ssh

.kitchen.yml

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
---
22
driver:
33
name: docker
4-
privileged: true
54
use_sudo: false
6-
provision_command:
7-
- "mkdir /var/run/sshd"
5+
privileged: true
6+
http_proxy: <%= ENV['http_proxy'] || nil %>
7+
https_proxy: <%= ENV['https_proxy'] || nil %>
8+
9+
transport:
10+
max_ssh_sessions: 5
811

912
transport:
1013
max_ssh_sessions: 5
@@ -14,48 +17,65 @@ provisioner:
1417
name: ansible_playbook
1518
hosts: all
1619
require_ansible_repo: false
17-
require_ansible_omnibus: true
1820
require_chef_for_busser: false
1921
require_ruby_for_busser: false
2022
ansible_verbose: true
2123
ansible_diff: true
2224
hosts: all
2325
roles_path: ../ansible-ssh-hardening/
26+
http_proxy: <%= ENV['http_proxy'] || nil %>
27+
https_proxy: <%= ENV['https_proxy'] || nil %>
2428
playbook: default.yml
29+
ansible_extra_flags:
30+
- "--skip-tags=sysctl"
2531

2632
platforms:
27-
- name: ubuntu-12.04
33+
- name: centos6-ansible-latest
34+
driver:
35+
image: rndmh3ro/docker-centos6-ansible:latest
36+
platform: centos
37+
- name: centos7-ansible-latest
38+
driver:
39+
image: rndmh3ro/docker-centos7-ansible:latest
40+
platform: centos
41+
- name: oracle6-ansible-latest
2842
driver:
29-
image: ubuntu:12.04
30-
- name: ubuntu-14.04
43+
image: rndmh3ro/docker-oracle6-ansible:latest
44+
platform: centos
45+
- name: oracle7-ansible-latest
3146
driver:
32-
image: ubuntu:14.04
33-
- name: ubuntu-16.04
47+
image: rndmh3ro/docker-oracle7-ansible:latest
48+
platform: centos
49+
- name: ubuntu1204-ansible-latest
3450
driver:
35-
image: ubuntu:16.04
36-
- name: centos-6.6
51+
image: rndmh3ro/docker-ubuntu1204-ansible:latest
52+
platform: ubuntu
53+
- name: ubuntu1404-ansible-latest
3754
driver:
38-
image: centos:6.6
39-
- name: centos-6.7
55+
image: rndmh3ro/docker-ubuntu1404-ansible:latest
56+
platform: ubuntu
57+
- name: ubuntu1604-ansible-latest
4058
driver:
41-
image: centos:6.7
42-
- name: centos-7
59+
image: rndmh3ro/docker-ubuntu1604-ansible:latest
60+
platform: ubuntu
61+
- name: debian7-ansible-latest
4362
driver:
44-
image: centos:7
45-
privileged: true
46-
run_command: /usr/sbin/init
47-
- name: debian-7
63+
image: rndmh3ro/docker-debian7-ansible:latest
64+
platform: debian
65+
- name: debian8-ansible-latest
4866
driver:
49-
image: debian:7
50-
- name: debian-8
67+
image: rndmh3ro/docker-debian8-ansible:latest
68+
platform: debian
69+
- name: debian9-ansible-latest
5170
driver:
52-
image: debian:8
71+
image: rndmh3ro/docker-debian9-ansible:latest
72+
platform: debian
5373

5474
verifier:
5575
name: inspec
5676
sudo: true
5777
inspec_tests:
58-
- https://github.com/dev-sec/tests-ssh-hardening
78+
- https://github.com/dev-sec/ssh-baseline
5979

6080
suites:
61-
- name: ssh-ansible_latest
81+
- name: ssh

.travis.yml

Lines changed: 59 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,66 @@
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
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"
48+
949

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

1854
script:
19-
- ansible-playbook --syntax-check spec/travis.yml
20-
- ansible-playbook --sudo -v --diff spec/travis.yml
21-
- ansible-playbook --sudo -v --diff spec/travis.yml --extra-vars "network_ipv6_enable=true ssh_allow_root_with_key=true ssh_client_password_login=true ssh_client_cbc_required=true ssh_server_weak_hmac=true ssh_client_weak_kex=true sftp_enabled=true"
55+
- container_id=$(mktemp)
56+
# Run container in detached state.
57+
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/ansible-ssh-hardening:ro ${run_opts} rndmh3ro/docker-${distro}-ansible:${version} "${init}" > "${container_id}"'
58+
59+
# Test role.
60+
- 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/ansible-ssh-hardening/default.yml'
61+
62+
# Verify role
63+
- 'inspec exec https://github.com/dev-sec/ssh-baseline/ -t docker://$(cat ${container_id})'
64+
65+
notifications:
66+
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

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

default.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
---
2-
3-
- name: wrapper playbook for kitchen testing "ansible-ssh-hardening" with custom settings
4-
hosts: localhost
5-
roles:
6-
- ansible-ssh-hardening
7-
vars:
8-
network_ipv6_enable: true
9-
ssh_allow_root_with_key: true
10-
ssh_client_password_login: true
11-
ssh_client_cbc_required: true
12-
ssh_server_weak_hmac: true
13-
ssh_client_weak_kex: true
14-
152
- name: wrapper playbook for kitchen testing "ansible-ssh-hardening" with default settings
163
hosts: localhost
4+
pre_tasks:
5+
- package: name="{{item}}" state=installed
6+
with_items:
7+
- "openssh-clients"
8+
- "openssh-server"
9+
ignore_errors: true
10+
- apt: name="{{item}}" state=installed update_cache=true
11+
with_items:
12+
- "openssh-client"
13+
- "openssh-server"
14+
ignore_errors: true
15+
- file: path="/var/run/sshd" state=directory
1716
roles:
1817
- ansible-ssh-hardening

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

spec/travis.yml

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

0 commit comments

Comments
 (0)