Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions plugins/inventory/terraform_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,24 @@ def parse(self, inventory, loader, path, cache=False): # type: ignore # mypy i
cfg = self._read_config_data(path)

project_path = cfg.get("project_path", os.getcwd())
try:
project_path = self.templar.template(project_path, fail_on_undefined=False)
except Exception as exc:
self.warn(f"Failed to template 'project_path': {exc}")

state_file = cfg.get("state_file", "")
try:
state_file = self.templar.template(state_file, fail_on_undefined=False)
except Exception as exc:
self.warn(f"Failed to template 'state_file': {exc}")

search_child_modules = cfg.get("search_child_modules", True)
terraform_binary = cfg.get("binary_path", None)
if terraform_binary is not None:
try:
terraform_binary = self.templar.template(terraform_binary, fail_on_undefined=False)
except Exception as exc:
self.warn(f"Failed to template 'binary_path': {exc}")
if terraform_binary is not None:
validate_bin_path(terraform_binary)
else:
Expand Down
29 changes: 29 additions & 0 deletions plugins/inventory/terraform_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,39 @@ def parse(self, inventory, loader, path, cache=False): # type: ignore # mypy i
cfg = self._read_config_data(path)

backend_config = cfg.get("backend_config")
if backend_config is not None:
try:
backend_config = self.templar.template(backend_config, fail_on_undefined=False)
except Exception as exc:
self.warn(f"Failed to template 'backend_config': {exc}")

backend_config_files = cfg.get("backend_config_files")
if backend_config_files is not None:
try:
backend_config_files = self.templar.template(backend_config_files, fail_on_undefined=False)
except Exception as exc:
self.warn(f"Failed to template 'backend_config_files': {exc}")

backend_type = cfg.get("backend_type")
if backend_type is not None:
try:
backend_type = self.templar.template(backend_type, fail_on_undefined=False)
except Exception as exc:
self.warn(f"Failed to template 'backend_type': {exc}")

provider_mapping = cfg.get("provider_mapping", [])
if provider_mapping:
try:
provider_mapping = self.templar.template(provider_mapping, fail_on_undefined=False)
except Exception as exc:
self.warn(f"Failed to template 'provider_mapping': {exc}")

terraform_binary = cfg.get("binary_path")
if terraform_binary is not None:
try:
terraform_binary = self.templar.template(terraform_binary, fail_on_undefined=False)
except Exception as exc:
self.warn(f"Failed to template 'binary_path': {exc}")
search_child_modules = cfg.get("search_child_modules", False)

if not backend_type:
Expand Down
Loading