This Packer provisioner plugin integrates with Ansible Automation Platform (AAP) to dynamically create inventories, hosts, and credentials, launch job templates, and manage the provisioning process during Packer builds.
- Dynamic Resource Management: Automatically creates temporary inventories, hosts, and SSH credentials
- Flexible Authentication: Support for both username/password and access token authentication
- Automatic Cleanup: Removes temporary resources in dependency-safe order
- Job Monitoring: Polls job status with configurable intervals and timeouts
- Stdout Retrieval: Fetches and displays job output for debugging
- Extra Variables: Pass custom variables to job templates
- Resource Retention: Option to keep temporary inventories for debugging
-
Build the plugin:
packer-sdc mapstructure-to-hcl2 -type Config pkgs/config/config.go goreleaser release --clean --skip=validate,publish
-
Install the plugin: Install from the dist of the goreleaser for your given arch. For darwin arm64, the command would be:
packer plugins install --path $PWD/dist/packer-provisioner-ansible-aap_darwin_arm64_v8.0/packer-plugin-ansible-aap github.com/rptcloud/ansible-aap
See Examples Directory.
tower_host: AAP API endpoint (e.g.,https://aap.example.com)organization_id: ID of the organization for dynamic inventories (required whendynamic_inventoryis true)
job_template_id: ID of the job template to runworkflow_template_id: ID of the workflow template to run
username+password: Basic authenticationaccess_token: Bearer token authentication (preferred)
inventory_id: Use an existing inventory instead of creating a new onedynamic_inventory: Whether to create a temporary inventory (default: true)keep_temp_inventory: Whether to keep temporary inventories after the build (default: false)
create_credential: Whether to create temporary credentials (default: true)keep_temp_credential: Whether to keep temporary credentials after the build (default: false)
extra_vars: Map of extra variables to pass to the job templatetimeout: Maximum time to wait for job completion (default: "15m")poll_interval: Interval for polling job status (default: "10s")
insecure_skip_verify: Skip SSL certificate verification (default: false)
The provisioner follows this workflow:
- Create Inventory: Creates a temporary inventory in the specified organization
- Add Host: Adds the target host to the inventory with proper Ansible variables
- Create Credential: Creates an SSH credential using the specified private key
- Launch Job: Launches the job template with the inventory and credential
- Poll Status: Monitors job status until completion or failure
- Fetch Output: Retrieves and displays job stdout
- Cleanup: Removes temporary resources (inventory, host, credential)
- Packer with SSH communicator enabled
- AAP with API access and a valid job template
- SSH private key file for target host authentication
MIT
- @David Joo for the original work.