terraform-provider-external icon indicating copy to clipboard operation
terraform-provider-external copied to clipboard

ansible-vault command not found

Open johnreytanquinco opened this issue 3 years ago • 0 comments

Terraform CLI and Provider Versions

$ terraform --version Terraform v0.14.3 Your version of Terraform is out of date! The latest version is 1.2.5. You can update by downloading from https://www.terraform.io/downloads.html $ terraform init Initializing the backend... Successfully configured the backend "azurerm"! Terraform will automatically use this backend unless the backend configuration changes. Initializing provider plugins...

  • Finding latest version of hashicorp/azurerm...
  • Finding latest version of hashicorp/external...
  • Installing hashicorp/azurerm v3.14.0...
  • Installed hashicorp/azurerm v3.14.0 (self-signed, key ID XXXXXXXXX)
  • Installing hashicorp/external v2.2.2...
  • Installed hashicorp/external v2.2.2 (self-signed, key ID XXXXXXXX)

Terraform Configuration

# variables.tf

data "external" "ansible" {
  program  = [
    "./vault.sh",
    "group_vars/dev/vars.yml"
  ]
}

# vault.sh
#!/usr/bin/env bash

set -e

vault_file_path=$1
if [ -z $vault_file_path ]; then
    echo You need to provide vault file path as the first argument. None received.
    exit 2
fi

ansible-vault decrypt --output - $vault_file_path --vault-password-file pass

Expected Behavior

data source should be able to run the script.

Actual Behavior

$ terraform plan -out=$PLAN -input=false Acquiring state lock. This may take a few moments... Error: External Program Execution Failed on variables.tf line 26, in data "external" "ansible": 26: program = [ 27: "./vault.sh", 28: "group_vars/dev/vars.yml" 29: ] The data source received an unexpected error while attempting to execute the program. Program: ./vault.sh Error Message: ./vault.sh: line 11: ansible-vault: command not found State: exit status 127

Steps to Reproduce

  1. terraform plan -out=$PLAN -input=false Im running it from gitlab ci.

How much impact is this issue causing?

High

Logs

No response

Additional Information

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

johnreytanquinco avatar Jul 15 '22 21:07 johnreytanquinco