Skip to content

Instantly share code, notes, and snippets.

@shalomb
Created October 14, 2020 10:44
Show Gist options
  • Save shalomb/38829f926173f2ed6b1b3a2403fb731b to your computer and use it in GitHub Desktop.
Save shalomb/38829f926173f2ed6b1b3a2403fb731b to your computer and use it in GitHub Desktop.
terraform initialization
#!/bin/bash
# Initialize terraform so that the ansible-terraform-openstack dynamic
# inventory script can succeed.
bin_dir=${bin_dir:-$( cd "${BASH_SOURCE[0]%/*}" && pwd )}
source "$bin_dir/init.sh" # shared config with ansible, cidb, etc
export TF_VAR_OS_USERNAME="$OS_USERNAME"
export TF_VAR_OS_PASSWORD="$OS_PASSWORD"
export TF_VAR_OS_TENANT_NAME="$OS_TENANT_NAME"
..
# Fail early test to check OS credentials
openstack project show "$OS_TENANT_NAME" -f yaml c
# Assert TF environment
pushd "$tf_dir"
terraform version
terraform init -reconfigure -backend-config="container=$OS_TENANT_NAME"
terraform validate -check-variables=true
terraform providers
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment