Skip to content

ansible/terraform-provider-aap

Repository files navigation

Terraform Provider for Ansible Automation Platform (AAP)

The AAP Provider allows Terraform to manage AAP resources. It provides a means of executing automation jobs on infrastructure provisioned by Terraform, leveraging the AAP API to manage inventories and launch jobs.

The provider can be found on the Terraform registry.

Requirements

Installation for Local Development

Run make build. This will build a terraform-provider-aap binary in the top level of the project. To get Terraform to use this binary, configure the development overrides for the provider installation. The easiest way to do this will be to create a config file with the following contents:

provider_installation {
  dev_overrides {
    "ansible/aap" = "/path/to/project/root"
  }

  direct {}
}

The /path/to/project/root should point to the location where you have cloned this repo, where the terraform-provider-aap binary will be built. You can then set the TF_CLI_CONFIG_FILE environment variable to point to this config file, and Terraform will use the provider binary you just built.

Testing

Linters

You will need to install golangci-lint to run linters.

Run make lint

Unit tests

Run make test

Acceptance tests

Acceptance tests apply test terraform configurations to a running AAP instance and make changes to resources in that instance, use with caution!

To run acceptance tests locally, start a local AAP instance following the docker-compose instructions for local AWX development. Create an admin user for the AAP instance and save the credentials to these environment variables:

export AAP_USERNAME=<your admin username>
export AAP_PASSWORD=<your admin password>

In order to run the acceptance tests for the job resource, you must have a working job template already in your AAP instance. The job template must be set to require an inventory on launch. Export the id of this job template:

export AAP_TEST_JOB_TEMPLATE_ID=<the ID of a job template in your AAP instance>

Then you can run acceptance tests with make testacc.

WARNING: running acceptance tests for the job resource will launch several jobs for the specified job template. It's strongly recommended that you create a "check" type job template for testing to ensure the launched jobs do not deploy any actual infrastructure.

Examples

The examples subdirectory contains usage examples for this provider.

Release notes

See the generated changelog.

Releasing

To release a new version of the provider:

  1. Run make generatedocs to format the example files and regenerate docs using terraform-plugin-docs tfplugindocs installation guide.
  2. Run antsibull-changelog release --version <version> to release a new version of the project.
  3. Commit changes
  4. Push a new tag (this should trigger an automated release process to the Terraform Registry). The tag version must start with "v", for example, v1.2.3.
  5. Verify the new version is published at https://registry.terraform.io/providers/ansible/aap/latest

Licensing

GNU General Public License v3.0. See LICENSE for full text.