A compliance and infrastructure testing tool
4.0K
Bridge Infrastructure Automation and Compliance Testing
A powerful compliance and infrastructure testing tool that combines Ansible's automation capabilities with InSpec's compliance framework.
# Pull the image
docker pull htunnthuthu/ansible-inspec:latest
# Run compliance check
docker run --rm \
-v $(pwd):/workspace \
-v ~/.ssh:/home/ansibleinspec/.ssh:ro \
htunnthuthu/ansible-inspec:latest \
exec /workspace/profile/ -i /workspace/inventory.yml
linux/amd64 and linux/arm64latest - Latest stable release from main branch0.1.0, 0.1, 0 - Semantic version tagsmain - Latest development builddocker run --rm \
-v $(pwd)/reports:/workspace/.compliance-reports \
htunnthuthu/ansible-inspec:latest \
exec dev-sec/linux-baseline --supermarket \
--target ssh://user@hostname \
--reporter html --output /workspace/.compliance-reports/report.html
# Create inventory.yml
cat > inventory.yml <<EOF
all:
hosts:
webserver:
ansible_host: 192.168.1.10
ansible_user: admin
EOF
# Run compliance test
docker run --rm \
-v $(pwd):/workspace \
-v ~/.ssh:/home/ansibleinspec/.ssh:ro \
htunnthuthu/ansible-inspec:latest \
exec dev-sec/ssh-baseline --supermarket \
-i /workspace/inventory.yml \
--reporter json --output /workspace/compliance-report.json
docker run --rm \
-v $(pwd):/workspace \
htunnthuthu/ansible-inspec:latest \
convert /workspace/my-profile \
--namespace myorg \
--collection-name compliance_baseline
| Mount | Purpose | Example |
|---|---|---|
/workspace | Working directory for profiles and reports | -v $(pwd):/workspace |
/home/ansibleinspec/.ssh | SSH keys for remote connections | -v ~/.ssh:/home/ansibleinspec/.ssh:ro |
/etc/ansible | Ansible configuration files | -v ./ansible.cfg:/etc/ansible/ansible.cfg:ro |
For SSH-based testing, mount your SSH keys:
docker run --rm \
-v ~/.ssh:/home/ansibleinspec/.ssh:ro \
-v $(pwd):/workspace \
htunnthuthu/ansible-inspec:latest \
exec profile/ --target ssh://user@host
# JSON report (InSpec schema-compatible)
docker run --rm \
-v $(pwd):/workspace \
htunnthuthu/ansible-inspec:latest \
exec dev-sec/linux-baseline --supermarket \
-i /workspace/inventory.yml \
--reporter json --output /workspace/compliance.json
# HTML dashboard
docker run --rm \
-v $(pwd):/workspace \
htunnthuthu/ansible-inspec:latest \
exec dev-sec/linux-baseline --supermarket \
-i /workspace/inventory.yml \
--reporter html --output /workspace/compliance.html
# Multiple formats
docker run --rm \
-v $(pwd):/workspace \
htunnthuthu/ansible-inspec:latest \
exec profile/ -i /workspace/inventory.yml \
--reporter "json:/workspace/report.json html:/workspace/report.html"
| Variable | Description | Default |
|---|---|---|
ANSIBLE_CONFIG | Path to ansible.cfg | /etc/ansible/ansible.cfg |
ANSIBLE_INVENTORY | Default inventory path | - |
INSPEC_BACKEND_CACHE | Enable InSpec caching | true |
GitLab CI:
compliance_check:
stage: test
image: htunnthuthu/ansible-inspec:latest
script:
- ansible-inspec exec security-baseline/ -i inventory.yml --reporter junit -o compliance.xml
artifacts:
reports:
junit: compliance.xml
GitHub Actions:
- name: Run Compliance Tests
uses: docker://htunnthuthu/ansible-inspec:latest
with:
args: exec dev-sec/linux-baseline --supermarket -i inventory.yml --reporter json -o report.json
Create an alias for easier use:
alias ansible-inspec='docker run --rm -v $(pwd):/workspace -v ~/.ssh:/home/ansibleinspec/.ssh:ro htunnthuthu/ansible-inspec:latest'
# Then use it like a local command
ansible-inspec exec profile/ -i inventory.yml
ansible-inspec --help
Access these profiles directly from Chef Supermarket:
dev-sec/linux-baseline - OS hardening (56 controls)dev-sec/ssh-baseline - SSH security (28 controls)cis-docker-benchmark - CIS Docker compliancedev-sec/nginx-baseline - Nginx hardeningdev-sec/apache-baseline - Apache securitydev-sec/mysql-baseline - MySQL/MariaDB securitydev-sec/postgres-baseline - PostgreSQL securityGPL-3.0 License - See LICENSE
Contributions welcome! See CONTRIBUTING.md
Note: This project integrates Ansible (GPL-3.0) and InSpec (Apache-2.0). Not officially endorsed by Red Hat or Progress Software.
Content type
Image
Digest
sha256:2e3866b06…
Size
240.7 MB
Last updated
7 months ago
docker pull htunnthuthu/ansible-inspec