Skip to content

Conversation

@spencerhughes
Copy link

@spencerhughes spencerhughes commented Sep 20, 2025

SUMMARY

Update the inventory plugins to allow templating variable values.

Currently, the inventory plugins require the configuration values to be included in plain-text. This is suboptimal for values such as the password value when configuring an HTTP backend. This change allows the plugins to parse templates when setting the values in the inventory plugin configs. For example, this allows a user to use a lookup plugin to set the backend authorization values from an external secret manager or from an environment variable.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

terraform_state
terraform_provider

ADDITIONAL INFORMATION

Example inventory file:

plugin: cloud.terraform.terraform_state
backend_type: http
backend_config:
  address: https://gitlab.example.com/api/v4/projects/1/terraform/state/default
  lock_address: https://gitlab.example.com/api/v4/projects/1/terraform/state/default/lock
  unlock_address: https://gitlab.example.com/api/v4/projects/1/terraform/state/default/lock
  username: "{{ lookup('env','TF_STATE_USER') }}"
  password: "{{ lookup('env','TF_STATE_PASSWORD') }}"

Output from current version:

[WARNING]: Failed to parse inventory with 'auto' plugin: Error refreshing state: HTTP remote state endpoint requires auth

Failed to parse inventory with 'auto' plugin.

<<< caused by >>>

Error refreshing state: HTTP remote state endpoint requires auth
Origin: <inventory plugin 'auto' with source '/path/to/ansible/inventory/terraform_state.yml'>

[WARNING]: Failed to parse inventory with 'yaml' plugin: Plugin configuration YAML file, not YAML inventory

Failed to parse inventory with 'yaml' plugin.

<<< caused by >>>

Plugin configuration YAML file, not YAML inventory
Origin: <inventory plugin 'yaml' with source '/path/to/ansible/inventory/terraform_state.yml'>

[WARNING]: Failed to parse inventory with 'ansible_collections.cloud.terraform.plugins.inventory.terraform_state' plugin: Error refreshing state: HTTP remote state endpoint requires auth

Failed to parse inventory with 'ansible_collections.cloud.terraform.plugins.inventory.terraform_state' plugin.

<<< caused by >>>

Error refreshing state: HTTP remote state endpoint requires auth
Origin: <inventory plugin 'ansible_collections.cloud.terraform.plugins.inventory.terraform_state' with source '/path/to/ansible/inventory/terraform_state.yml'>

[WARNING]: Unable to parse /path/to/ansible/inventory/terraform_state.yml as an inventory source

@softwarefactory-project-zuul
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant