Getting Started

Introduction

ansible-inspec combines the power of Ansible's infrastructure automation with InSpec's compliance testing framework, allowing you to:

  • Test infrastructure configurations programmatically

  • Validate compliance and security requirements

  • Integrate testing into your automation workflows

  • Use Ansible inventory for test targeting

Prerequisites

  • Python 3.8 or higher

  • Basic knowledge of Ansible

  • Basic knowledge of InSpec or infrastructure testing

Installation

From PyPI (when available)

pip install ansible-inspec

From Source

Verify Installation

Quick Start

1. Create Your First Compliance Profile

This creates a directory structure:

2. Write a Simple Test

Edit controls/example.rb:

3. Run Tests Against a Target

Using with Ansible Inventory

Create an Inventory File

Run Tests

Example Compliance Tests

File Permissions Test

Service Configuration Test

Package Compliance Test

Next Steps

Common Issues

Permission Denied

If you get permission errors when testing files:

Connection Issues

If you can't connect to remote hosts:

Getting Help

Last updated