Skip to content

Commit

Permalink
Inspec (#232)
Browse files Browse the repository at this point in the history
* Remove privileges from Docker container
* Inspec setup
* Use RedHat QE Jenkins profile and generating attributes from template
  • Loading branch information
abraverm authored Jun 26, 2018
1 parent 4925888 commit 3dfaf60
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ build
.coverage
coverage.xml
htmlcov/
.pytest_cache/
**/*.lock
tests/profile.yml
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ before_install:
- travis_retry pip install -U pip
- pip --version
install:
- travis_retry gem install inspec
- travis_retry pip install tox
- tox --version
script:
Expand Down
8 changes: 7 additions & 1 deletion scripts/master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ ansible -i /dev/null \
detach=true \
command='/usr/lib/systemd/systemd \
--system' \
privileged=true"
capabilities=SYS_ADMIN \
$([[ $TRAVIS = true ]] && echo privileged=true)"
# Fedora is lacking python in base image
docker exec -it "${container_name}" "${pkg_mgr}" install -y python
ansible -i "${inventory}" \
Expand All @@ -45,6 +46,11 @@ ansible-playbook -i "${inventory}" \
"${cinch}/cinch/site.yml" \
-e jenkins_user_password=somedummyvalue
########################################################
# Run inspec against the container
########################################################
erb "${cinch}/tests/profile.yml.erb" > "${cinch}/tests/profile.yml"
inspec exec "${cinch}/tests/cinch" --attrs "${cinch}/tests/profile.yml" -t "docker://${container_name}"
########################################################
# Finish and close up the container
########################################################
echo "Saving image"
Expand Down
3 changes: 3 additions & 0 deletions tests/cinch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Cinch InSpec Profile

This example shows the implementation of an InSpec profile.
1 change: 1 addition & 0 deletions tests/cinch/controls/cinch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include_controls "jenkins"
12 changes: 12 additions & 0 deletions tests/cinch/inspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: cinch
title: Cinch Profile
maintainer: Alexander Braverman Masis
copyright: Red Hat
copyright_email: abraverm@redhat.com
license: GPL-3.0
summary: Cinch Compliance Profile
version: 0.1.0
depends:
- name: jenkins
git: https://github.com/RedHatQe/jenkins-profile.git
branch: master
Empty file added tests/cinch/libraries/.gitkeep
Empty file.
18 changes: 18 additions & 0 deletions tests/profile.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2.60.3-1.1
jenkins_home: /var/lib/jenkins
ports:
- 8080
jenkins_url: http://localhost:8080
jenkins_settings:
- key: "hudson/useSecurity"
value:
- 'true'
- key: "hudson/securityRealm/@class"
value:
- 'hudson.security.HudsonPrivateSecurityRealm'
- key: hudson/slaveAgentPort
value:
- '50000'

jenkins_plugins:
<%= %x(cat cinch/files/jenkins-plugin-lists/default.txt | awk -F '==' '{print " -", $1}') %>
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ deps =
{[testenv]deps}
docker-py
commands = bash ./tests/fedora_master.sh

[testenv:inspec_master]
commands = bash -c "inspec exec tests/cinch -t docker://jmaster"

0 comments on commit 3dfaf60

Please sign in to comment.