mirror of
https://github.com/dev-sec/ansible-nginx-hardening.git
synced 2024-11-22 19:42:02 +01:00
Add travis builds for official nginx role (#21)
* test official nginx role with travis Signed-off-by: szEvEz <szivos.john@gmail.com> * split up test playbook for different distros due to required vars Signed-off-by: szEvEz <szivos.john@gmail.com> * make debian distros use the debian playbook Signed-off-by: szEvEz <szivos.john@gmail.com> * update README Signed-off-by: szEvEz <szivos.john@gmail.com>
This commit is contained in:
parent
7e8da15157
commit
35d821809c
76
.travis.yml
76
.travis.yml
@ -5,49 +5,94 @@ env:
|
|||||||
- distro: centos6
|
- distro: centos6
|
||||||
version: latest
|
version: latest
|
||||||
init: /sbin/init
|
init: /sbin/init
|
||||||
|
test_playbook: test.yml
|
||||||
|
|
||||||
- distro: centos7
|
- distro: centos7
|
||||||
init: /lib/systemd/systemd
|
init: /lib/systemd/systemd
|
||||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
version: latest
|
version: latest
|
||||||
|
test_playbook: test.yml
|
||||||
|
|
||||||
- distro: oracle6
|
- distro: oracle6
|
||||||
version: latest
|
version: latest
|
||||||
init: /sbin/init
|
init: /sbin/init
|
||||||
|
test_playbook: test.yml
|
||||||
# - distro: oracle7
|
|
||||||
# init: /usr/lib/systemd/systemd
|
|
||||||
# run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
|
||||||
# version: latest
|
|
||||||
|
|
||||||
- distro: ubuntu1404
|
- distro: ubuntu1404
|
||||||
version: latest
|
version: latest
|
||||||
init: /sbin/init
|
init: /sbin/init
|
||||||
|
test_playbook: test.yml
|
||||||
|
|
||||||
- distro: ubuntu1604
|
- distro: ubuntu1604
|
||||||
version: latest
|
version: latest
|
||||||
init: /lib/systemd/systemd
|
init: /lib/systemd/systemd
|
||||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
test_playbook: test.yml
|
||||||
|
|
||||||
- distro: ubuntu1804
|
- distro: ubuntu1804
|
||||||
version: latest
|
version: latest
|
||||||
init: /lib/systemd/systemd
|
init: /lib/systemd/systemd
|
||||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
test_playbook: test.yml
|
||||||
|
|
||||||
- distro: debian8
|
- distro: debian8
|
||||||
version: latest
|
version: latest
|
||||||
init: /sbin/init
|
init: /sbin/init
|
||||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
test_playbook: test.yml
|
||||||
|
|
||||||
- distro: debian9
|
- distro: debian9
|
||||||
version: latest
|
version: latest
|
||||||
init: /lib/systemd/systemd
|
init: /lib/systemd/systemd
|
||||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
test_playbook: test.yml
|
||||||
|
|
||||||
|
- distro: centos6
|
||||||
|
version: latest
|
||||||
|
init: /sbin/init
|
||||||
|
test_playbook: official-nginx-role-redhat.yml
|
||||||
|
|
||||||
|
- distro: centos7
|
||||||
|
init: /lib/systemd/systemd
|
||||||
|
container_id: $(mktemp)
|
||||||
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
version: latest
|
||||||
|
test_playbook: official-nginx-role-redhat.yml
|
||||||
|
|
||||||
|
- distro: oracle6
|
||||||
|
version: latest
|
||||||
|
init: /sbin/init
|
||||||
|
test_playbook: official-nginx-role-redhat.yml
|
||||||
|
|
||||||
|
- distro: ubuntu1404
|
||||||
|
version: latest
|
||||||
|
init: /sbin/init
|
||||||
|
test_playbook: official-nginx-role-debian.yml
|
||||||
|
|
||||||
|
- distro: ubuntu1604
|
||||||
|
version: latest
|
||||||
|
init: /lib/systemd/systemd
|
||||||
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
test_playbook: official-nginx-role-debian.yml
|
||||||
|
|
||||||
|
- distro: ubuntu1804
|
||||||
|
version: latest
|
||||||
|
init: /lib/systemd/systemd
|
||||||
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
test_playbook: official-nginx-role-debian.yml
|
||||||
|
|
||||||
|
- distro: debian8
|
||||||
|
version: latest
|
||||||
|
init: /sbin/init
|
||||||
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
test_playbook: official-nginx-role-debian.yml
|
||||||
|
|
||||||
|
- distro: debian9
|
||||||
|
version: latest
|
||||||
|
init: /lib/systemd/systemd
|
||||||
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
test_playbook: official-nginx-role-debian.yml
|
||||||
|
|
||||||
# - distro: amazon
|
|
||||||
# init: /lib/systemd/systemd
|
|
||||||
# version: latest
|
|
||||||
# run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
# Pull container
|
# Pull container
|
||||||
@ -55,18 +100,17 @@ before_install:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- container_id=$(mktemp)
|
- container_id=$(mktemp)
|
||||||
# Run container in detached state.
|
# Run container in detached state
|
||||||
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/ansible-nginx-hardening:ro ${run_opts} rndmh3ro/docker-${distro}-ansible:${version} "${init}" > "${container_id}"'
|
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/ansible-nginx-hardening:ro ${run_opts} rndmh3ro/docker-${distro}-ansible:${version} "${init}" > "${container_id}"'
|
||||||
|
|
||||||
# Install ansible galaxy requirements
|
# Install ansible galaxy requirements
|
||||||
- 'docker exec "$(cat ${container_id})" ansible-galaxy -c install -r /etc/ansible/roles/ansible-nginx-hardening/requirements.yml -p /etc/ansible/roles/'
|
- 'docker exec "$(cat ${container_id})" ansible-galaxy -c install -r /etc/ansible/roles/ansible-nginx-hardening/requirements.yml -p /etc/ansible/roles/'
|
||||||
|
|
||||||
# Test role.
|
# Test role
|
||||||
- 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/ansible-nginx-hardening/tests/test.yml -vv'
|
- 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/ansible-nginx-hardening/tests/"${test_playbook}" -vv'
|
||||||
|
|
||||||
# Verify role
|
# Verify role
|
||||||
#- 'inspec exec https://github.com/dev-sec/nginx-baseline/ -t docker://$(cat ${container_id}) --controls=nginx-01 nginx-02 nginx-03 nginx-04 nginx-05 nginx-06 nginx-07 nginx-08 nginx-09 nginx-10 nginx-12 nginx-13 nginx-14 nginx-15 nginx-17 --no-distinct-exit'
|
|
||||||
- 'inspec exec https://github.com/dev-sec/nginx-baseline/ -t docker://$(cat ${container_id}) --controls=nginx-01 nginx-02 nginx-03 nginx-05 nginx-06 nginx-07 nginx-08 nginx-09 nginx-10 nginx-12 nginx-13 nginx-15 nginx-17 --no-distinct-exit'
|
- 'inspec exec https://github.com/dev-sec/nginx-baseline/ -t docker://$(cat ${container_id}) --controls=nginx-01 nginx-02 nginx-03 nginx-05 nginx-06 nginx-07 nginx-08 nginx-09 nginx-10 nginx-12 nginx-13 nginx-15 nginx-17 --no-distinct-exit'
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
@ -10,6 +10,7 @@ This role provides secure nginx configuration. It is intended to be compliant wi
|
|||||||
|
|
||||||
It works with the following nginx-roles, including, but not limited to:
|
It works with the following nginx-roles, including, but not limited to:
|
||||||
* [geerlingguy.nginx](https://galaxy.ansible.com/geerlingguy/nginx/)
|
* [geerlingguy.nginx](https://galaxy.ansible.com/geerlingguy/nginx/)
|
||||||
|
* [nginxinc.nginx](https://galaxy.ansible.com/nginxinc/nginx)
|
||||||
* [jdauphant.nginx](https://galaxy.ansible.com/jdauphant/nginx/)
|
* [jdauphant.nginx](https://galaxy.ansible.com/jdauphant/nginx/)
|
||||||
* [franklinkim.nginx](https://galaxy.ansible.com/franklinkim/nginx/)
|
* [franklinkim.nginx](https://galaxy.ansible.com/franklinkim/nginx/)
|
||||||
|
|
||||||
|
40
tests/official-nginx-role-debian.yml
Normal file
40
tests/official-nginx-role-debian.yml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
- name: wrapper playbook for kitchen testing "ansible-nginx-hardening" with custom settings
|
||||||
|
hosts: localhost
|
||||||
|
vars:
|
||||||
|
- nginx_main_template_enable: true
|
||||||
|
- nginx_main_template:
|
||||||
|
template_file: nginx.conf.j2
|
||||||
|
conf_file_name: nginx.conf
|
||||||
|
conf_file_location: /etc/nginx/
|
||||||
|
user: www-data
|
||||||
|
worker_processes: auto
|
||||||
|
error_level: warn
|
||||||
|
worker_connections: 1024
|
||||||
|
http_enable: true
|
||||||
|
http_settings:
|
||||||
|
keepalive_timeout: 65
|
||||||
|
cache: false
|
||||||
|
rate_limit: false
|
||||||
|
keyval: false
|
||||||
|
stream_enable: false
|
||||||
|
http_global_autoindex: false
|
||||||
|
pre_tasks:
|
||||||
|
- apt_repository:
|
||||||
|
repo: "deb http://ftp.debian.org/debian jessie-backports main"
|
||||||
|
state: present
|
||||||
|
when: ansible_distribution == 'Debian' and ansible_distribution_major_version == '8'
|
||||||
|
- set_fact:
|
||||||
|
nginx_default_release: "jessie-backports"
|
||||||
|
when: ansible_distribution == 'Debian' and ansible_distribution_major_version == '8'
|
||||||
|
- package: name="{{item}}" state=installed
|
||||||
|
with_items:
|
||||||
|
- "systemd"
|
||||||
|
ignore_errors: true
|
||||||
|
- apt: name="{{item}}" state=installed update_cache=true
|
||||||
|
with_items:
|
||||||
|
- "systemd"
|
||||||
|
ignore_errors: true
|
||||||
|
roles:
|
||||||
|
- nginxinc.nginx
|
||||||
|
- ansible-nginx-hardening
|
15
tests/official-nginx-role-redhat.yml
Normal file
15
tests/official-nginx-role-redhat.yml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
- name: wrapper playbook for kitchen testing "ansible-nginx-hardening" with custom settings
|
||||||
|
hosts: localhost
|
||||||
|
pre_tasks:
|
||||||
|
- package: name="{{item}}" state=installed
|
||||||
|
with_items:
|
||||||
|
- "systemd"
|
||||||
|
ignore_errors: true
|
||||||
|
- apt: name="{{item}}" state=installed update_cache=true
|
||||||
|
with_items:
|
||||||
|
- "systemd"
|
||||||
|
ignore_errors: true
|
||||||
|
roles:
|
||||||
|
- nginxinc.nginx
|
||||||
|
- ansible-nginx-hardening
|
Loading…
Reference in New Issue
Block a user