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.
- install Go: official installation guide
- install Terraform: official installation guide
- install AWX: official installation guide
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.
You will need to install golangci-lint to run linters.
Run make lint
Run make test
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:
Create an admin user for the AAP instance and set the following environment variables:
export AAP_USERNAME=<your admin username>
export AAP_PASSWORD=<your admin password>
export AAP_INSECURE_SKIP_VERIFY=true
export AAP_HOST=<your aap instance host url> # "http://localhost:9080" or "https://localhost:8043"
In order to run the acceptance tests for the job resource, you must have templates for job and worklow already in your AAP instance. The templates must be set to require an inventory on launch and the Workflow Template must be named "Demo Workflow Job Template". Export the IDs of these job templates:
export AAP_TEST_JOB_TEMPLATE_ID=<the ID of a job template in your AAP instance>
export AAP_TEST_WORKFLOW_JOB_TEMPLATE_ID=<the ID of a workflow job template in your AAP instance>
The inventory resource test requires the AAP instance to have a second organization with the name Non-Default
and export that ID:
export AAP_TEST_ORGANIZATION_ID=<the ID of the second organization 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.
The examples subdirectory contains usage examples for this provider.
See the generated changelog.
To release a new version of the provider:
- Run
make generatedocs
to format the example files and regenerate docs using terraform-plugin-docs tfplugindocs installation guide. - Run
antsibull-changelog release --version <version>
to release a new version of the project. - Commit changes
- 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.
- Verify the new version is published at https://registry.terraform.io/providers/ansible/aap/latest
- Linux / AMD64
GNU General Public License v3.0. See LICENSE for full text.