Use a repository plugin file
- Commit an inventory plugin file to a repository connected to your organization. Use the filename suffix required by the plugin.
- Open Inventories > New Inventory. Enter a name, choose VCS, then select the connection, repository, branch and Inventory Path. The connection selector offers GitHub and Azure DevOps connections. Register repository access as a VCS connection, rather than as an Ansible credential.
- Select Create Inventory, open it, and select Sync from VCS.
- Check the completed sync and discovered hosts before selecting the inventory in a job template.
Repository-backed discovery syncs in the platform Ansible image and uses your file and the sync's environment for cloud authentication. Attaching a cloud credential to a separate dynamic source does not authenticate a VCS inventory, and this path mints no Stackweaver OIDC inventory token.
The sync runs with the identity binding
the inventory selects, or inherits from its project or organization. With a binding of an
agent pool it runs on that pool, which must let the inventory's project use it and reach the
repository to clone it; with none, it runs on the hosted capacity. See
Where a VCS inventory's file sync runs.
On an agent pool, a GitHub App connection's sync gets a read-only token for this repository
only. A GitHub token, GitLab, Bitbucket or Azure DevOps connection holds a stored credential,
which reaches the pool only when the organization turns on
Allow stored VCS credentials on agent pools; see
Repository credentials on agent pools.
An azure-workload-identity binding lets an azure_rm file authenticate with no credential;
see Set up Azure workload identity.
Without a binding the sync runs with the platform identity. A runtime identity from a cloud
metadata service (Azure managed identity, Google Application Default Credentials from the
metadata server, an AWS instance profile) then reaches it only when your operator runs the
hosted capacity's launchers in the host-identity network mode; in the default platform
mode the sync cannot reach the metadata service, and a strict hosted deployment refuses
host-identity. Keep secrets out of the repository.
Plugin YAML examples
| Provider | Plugin | Required filename ending |
|---|---|---|
| AWS | amazon.aws.aws_ec2 | aws_ec2.yml or aws_ec2.yaml |
| Azure | azure.azcollection.azure_rm | azure_rm.yml or azure_rm.yaml |
| GCP | google.cloud.gcp_compute | gcp_compute.yml, gcp_compute.yaml, gcp.yml or gcp.yaml |
A provider icon is a UI hint, not proof that Ansible accepts the filename. These filename requirements come from the AWS, Azure and GCP plugin references; use those references for additional options and dependencies.
Save one of these files in your repository, replacing the example region, resource group
or project with your own scope. The AWS example selects running production instances;
Azure lists VMs in rg-production; GCP lists instances in the named project and zone.
Authentication must already be available to a sync on the hosted capacity, as described above.
AWS: inventory/production.aws_ec2.yml
plugin: amazon.aws.aws_ec2
regions:
- eu-west-1
filters:
instance-state-name: running
tag:Environment: production
keyed_groups:
- key: placement.region
prefix: regionAzure: inventory/production.azure_rm.yml
plugin: azure.azcollection.azure_rm
auth_source: auto
include_vm_resource_groups:
- rg-production
hostnames:
- name
keyed_groups:
- key: location
prefix: regionGCP: inventory/production.gcp_compute.yml
plugin: google.cloud.gcp_compute
auth_kind: application
projects:
- my-project-id
zones:
- us-central1-a
keyed_groups:
- key: labels.env
prefix: envFor Azure managed identity, use auth_source: msi instead of auto. Give that identity
read access to the target subscription/resource groups. For GCP, application uses
Application Default Credentials from the sync's environment; it does not attach a
Stackweaver credential to a VCS inventory. Both need the metadata service, which the sync
reaches only in the host-identity network mode described above. After syncing, check Hosts and Groups
for the intended scope before using it in a job.
The file picker hides playbooks, roles, variables, tests, hidden directories and tooling files. If no candidates are found, it offers a typed path. If other candidates appear but yours is missing, check the repository and branch, then use the inventory registration operation in the API explorer. Not every picker accepts an arbitrary path.