Skip to content

ansible/example-opa-policy-for-aap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Example OPA Policies for Ansible Automation Platform

This repository contains example policies and use cases demonstrating how to use Policy as Code feature in Ansible Automation Platform (AAP). These examples will guide you through implementing various policy enforcement scenarios using Open Policy Agent (OPA).

Overview

Policy as Code allows you to define and enforce policies across your Ansible Automation Platform using OPA and the Rego language. This repository provides practical examples of common policy enforcement scenarios.

Prerequisites

For detailed setup instructions, see "Setting up Policy as Code for Ansible Automation Platform" in the official documentation.

Repository Structure

.
├── aap_policy_examples/     # Example policy implementations
├── example_input_data/     # Sample input data for testing
├── test_aap_policy_examples/ # Test cases and validation
├── openshift/             # OpenShift-specific configurations
├── tools/                # Utility scripts and tools
├── bin/                  # Binary and executable files
├── .github/             # GitHub-specific configurations
├── POLICY_INPUT_DATA.md # Documentation of input data structure
└── POLICY_OUTPUT_DATA.md # Documentation of output data structure

Example Policies

The repository includes several example policies demonstrating different use cases:

  1. Prevent job execution at various policy enforcement points
  2. Prevent job execution by platform admin
  3. Prevent job execution during maintenance window
  4. Prevent job execution using credential with no Organization
  5. Prevent job execution using mismatching resources
  6. Enforce extra_vars based policies
  7. Source code controls
  8. Enforce Naming Standards - ensure Job Template name conforms to our standards
  9. Restrict usage of an Inventory to an Organization - restrict inventory usage by organization

Each policy example includes:

  • Detailed explanation of the use case
  • Example Rego policy implementation
  • Sample input and output data
  • Testing instructions

Getting Started

  1. Clone this repository
  2. Review the example policies in the aap_policy_examples/ directory
  3. Use the provided test cases in test_aap_policy_examples/ to validate your policies
  4. Customize the policies according to your needs

Testing

The repository includes test cases and example input data to help you validate your policies. See the test_aap_policy_examples/ directory for more details.

Documentation

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is dedicated to the public domain under The Unlicense. See the LICENSE file for details.

The Unlicense is a template for disclaiming copyright monopoly interest in software you've written; in other words, it is a template for dedicating your software to the public domain.

About

Example OPA policy for Ansible Automation Platform

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5