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

Commit 98e30c4

Browse files
authored
Merge pull request #26 from dev-sec/new_dockerimages
use new docker files
2 parents 143270c + 72344ca commit 98e30c4

16 files changed

+264
-145
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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
driver:
3+
name: vagrant
4+
5+
provisioner:
6+
name: ansible_playbook
7+
hosts: all
8+
require_ansible_repo: false
9+
require_ansible_omnibus: true
10+
require_chef_for_busser: false
11+
require_ruby_for_busser: false
12+
ansible_verbose: true
13+
roles_path: ../ansible-mysql-hardening/
14+
playbook: default.yml
15+
requirements_path: requirements.yml
16+
sudo_command: 'sudo -E -H'
17+
18+
transport:
19+
max_ssh_sessions: 5
20+
21+
platforms:
22+
- name: ubuntu-14.04
23+
- name: ubuntu-16.04
24+
- name: centos-6.8
25+
- name: centos-7.3
26+
- name: oracle-6.8
27+
- name: oracle-7.3
28+
- name: debian-7.11
29+
- name: debian-8.7
30+
31+
verifier:
32+
name: inspec
33+
sudo: true
34+
inspec_tests:
35+
- https://github.com/dev-sec/mysql-baseline/
36+
37+
suites:
38+
- name: mysql

.kitchen.yml

Lines changed: 63 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,77 @@
11
---
22
driver:
3-
name: vagrant
3+
name: docker
4+
privileged: true
5+
use_sudo: false
6+
7+
transport:
8+
max_ssh_sessions: 5
9+
410
provisioner:
511
name: ansible_playbook
6-
test_repo_uri: https://github.com/hardening-io/tests-mysql-hardening.git
712
hosts: all
8-
playbook: default.yml
913
require_ansible_repo: false
1014
require_ansible_omnibus: true
11-
requirements_path: requirements.yml
15+
require_chef_for_busser: false
16+
require_ruby_for_busser: false
1217
ansible_verbose: true
1318
ansible_diff: true
19+
hosts: all
1420
roles_path: ../ansible-mysql-hardening/
21+
playbook: default.yml
22+
requirements_path: requirements.yml
1523
sudo_command: 'sudo -E -H'
1624

1725
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: centos-7.2
35-
driver_config:
36-
box: opscode-centos-7.2
37-
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.2_chef-provisionerless.box
38-
- name: oracle-6.4
39-
driver_config:
40-
box: oracle-6.4
41-
box_url: https://storage.us2.oraclecloud.com/v1/istoilis-istoilis/vagrant/oel64-64.box
42-
- name: oracle-6.5
43-
driver_config:
44-
box: oracle-6.5
45-
box_url: https://storage.us2.oraclecloud.com/v1/istoilis-istoilis/vagrant/oel65-64.box
46-
- name: debian-6
47-
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
50-
- name: debian-7
51-
driver_config:
52-
box: debian-7
53-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.8_chef-provisionerless.box
54-
- name: debian-8
55-
driver_config:
56-
box: debian-8
57-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-8.1_chef-provisionerless.box
26+
- name: centos6-ansible-latest
27+
driver:
28+
image: rndmh3ro/docker-centos6-ansible:latest
29+
platform: centos
30+
- name: centos7-ansible-latest
31+
driver:
32+
image: rndmh3ro/docker-centos7-ansible:latest
33+
platform: centos
34+
- name: oracle6-ansible-latest
35+
driver:
36+
image: rndmh3ro/docker-oracle6-ansible:latest
37+
platform: centos
38+
- name: oracle7-ansible-latest
39+
driver:
40+
image: rndmh3ro/docker-oracle7-ansible:latest
41+
platform: centos
42+
- name: ubuntu1404-ansible-latest
43+
driver:
44+
image: rndmh3ro/docker-ubuntu1404-ansible:latest
45+
platform: ubuntu
46+
- name: ubuntu1604-ansible-latest
47+
driver:
48+
image: rndmh3ro/docker-ubuntu1604-ansible:latest
49+
platform: ubuntu
50+
- name: debian7-ansible-latest
51+
driver:
52+
image: rndmh3ro/docker-debian7-ansible:latest
53+
platform: debian
54+
intermediate_instructions:
55+
- RUN /usr/bin/apt-get update
56+
- RUN /usr/bin/apt-get install -y procps
57+
- name: debian8-ansible-latest
58+
driver:
59+
image: rndmh3ro/docker-debian8-ansible:latest
60+
platform: debian
61+
intermediate_instructions:
62+
- RUN /usr/bin/apt-get update
63+
- RUN /usr/bin/apt-get install -y procps
64+
pid_one_command: /bin/systemd
65+
- name: debian9-ansible-latest
66+
driver:
67+
image: rndmh3ro/docker-debian9-ansible:latest
68+
platform: debian
69+
70+
verifier:
71+
name: inspec
72+
sudo: true
73+
inspec_tests:
74+
- https://github.com/dev-sec/mysql-baseline
75+
5876
suites:
59-
- name: ansible_1.9
60-
provisioner:
61-
ansible_version: 1.9.4
62-
- name: ansible_latest
77+
- name: mysql

.travis.yml

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,75 @@
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+
run_opts: "--privileged"
8+
init: /sbin/init
9+
10+
- distro: centos7
11+
init: /usr/lib/systemd/systemd
12+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
13+
version: latest
14+
15+
- distro: oracle6
16+
version: latest
17+
run_opts: "--privileged"
18+
init: /sbin/init
19+
20+
- distro: oracle7
21+
init: /usr/lib/systemd/systemd
22+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
23+
version: latest
24+
25+
# see https://github.com/dev-sec/mysql-baseline/issues/35
26+
# - distro: ubuntu1604
27+
# version: latest
28+
# init: /lib/systemd/systemd
29+
# run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
30+
31+
# - distro: ubuntu1404
32+
# version: latest
33+
# run_opts: "--privileged"
34+
# init: /sbin/init
35+
36+
- distro: debian7
37+
version: latest
38+
run_opts: "--privileged"
39+
init: /sbin/init
40+
41+
# - distro: debian8
42+
# version: latest
43+
# init: /bin/systemd
44+
# run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
45+
46+
# - distro: debian9
47+
# version: latest
48+
# init: /lib/systemd/systemd
49+
# run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
1050

1151
before_install:
12-
- sudo apt-get update -qq
13-
- sudo apt-get install -qq python-apt python-pycurl python-mysqldb
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
52+
# Pull container
53+
- 'docker pull rndmh3ro/docker-${distro}-ansible:${version}'
1854

1955
script:
20-
- ansible-playbook --syntax-check spec/travis.yml
21-
- ansible-playbook --sudo -v --diff spec/travis.yml
56+
- container_id=$(mktemp)
57+
# Run container in detached state.
58+
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/ansible-mysql-hardening:ro ${run_opts} rndmh3ro/docker-${distro}-ansible:${version} "${init}" > "${container_id}"'
59+
60+
# Install ansible galaxy requirements
61+
- 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/ansible-mysql-hardening/requirements.yml -p /etc/ansible/roles/'
62+
63+
# Test role.
64+
- 'travis_wait docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/ansible-mysql-hardening/default.yml'
65+
66+
# Verify role
67+
- 'inspec exec https://github.com/rndmh3ro/mysql-baseline/ -t docker://$(cat ${container_id})'
68+
69+
after_failure:
70+
# Check MySQL settings.
71+
- 'docker exec --tty ${container_id} env TERM=xterm cat /var/log/mysql/error.log'
72+
- 'docker exec --tty ${container_id} env TERM=xterm cat /var/log/mysql.err'
73+
- 'docker exec --tty ${container_id} env TERM=xterm cat /var/log/mysql.log'
74+
notifications:
75+
webhooks: https://galaxy.ansible.com/api/v1/notifications/

Gemfile

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,15 @@
22

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

5-
group :test do
6-
gem 'rake'
7-
# gem 'chefspec', '~> 4.2.0'
8-
gem 'foodcritic', '~> 4.0'
9-
gem 'thor-foodcritic'
10-
# gem 'rubocop', '~> 0.28.0'
11-
gem 'coveralls', require: false
12-
end
13-
14-
group :development do
15-
gem 'guard'
16-
gem 'guard-rspec'
17-
gem 'guard-kitchen'
18-
# gem 'guard-rubocop'
19-
# gem 'guard-foodcritic'
20-
end
21-
225
group :integration do
236
gem 'test-kitchen', '~> 1.0'
247
gem 'kitchen-ansible'
258
gem 'kitchen-vagrant'
9+
gem 'kitchen-inspec'
2610
gem 'kitchen-sharedtests', '~> 0.2.0'
27-
end
28-
29-
group :openstack do
30-
gem 'kitchen-openstack'
11+
gem 'kitchen-sync'
12+
gem 'kitchen-transport-rsync'
13+
gem 'kitchen-docker'
3114
end
3215

3316
group :tools do

README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,20 @@ Further information is already available at [Deutsche Telekom (German)](http://w
5050

5151
## Local Testing
5252

53-
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).
53+
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.
54+
55+
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).
5456

5557
Next install test-kitchen:
5658

5759
```bash
5860
# Install dependencies
5961
gem install bundler
6062
bundle install
63+
```
6164

62-
# Fetch tests
63-
bundle exec thor kitchen:fetch-remote-tests
64-
65-
# download a MySQL-installation role
66-
ansible-galaxy install -p roles/ bennojoy.mysql
67-
68-
# change password in MySQL-installation role to match the one from testing
69-
sed -i 's/foobar/iloverandompasswordsbutthiswilldo/g' roles/bennojoy.mysql/defaults/main.yml
70-
65+
### Testing with Docker
66+
```
7167
# fast test on one machine
7268
bundle exec kitchen test default-ubuntu-1204
7369
@@ -79,8 +75,19 @@ bundle exec kitchen create default-ubuntu-1204
7975
bundle exec kitchen converge default-ubuntu-1204
8076
```
8177

82-
For more information see [test-kitchen](http://kitchen.ci/docs/getting-started)
78+
### Testing with Virtualbox
79+
```
80+
# fast test on one machine
81+
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen test default-ubuntu-1404
82+
83+
# test on all machines
84+
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen test
8385
86+
# for development
87+
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen create default-ubuntu-1404
88+
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen converge default-ubuntu-1404
89+
```
90+
For more information see [test-kitchen](http://kitchen.ci/docs/getting-started)
8491

8592
## License and Author
8693

TODO.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

Thorfile

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

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

0 commit comments

Comments
 (0)