Skip to content

jaysiyani/terraform-inventory

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Inventory

An Ansible dynamic inventory script to process Terraform state and return Ansible host data from Terraform Provider for Ansible host resources. See the Terraform Provider for it's own installation and use.

Usage

Copy the terraform.py script file to a location on your system. Ansible's own documentation suggests the location /etc/ansible/terraform.py, but the particular location does not matter to the script. Ensure it has executable permissions (chmod +x /etc/ansible/terraform.py).

With your Ansible playbook and Terraform configuration in the same directory, run Ansible with the -i flag to set the inventory source.

$ ansible-playbook -i /etc/ansible/terraform.py playbook.yml

Environment Variables

ANSIBLE_TF_PATH

Override the path to the Terraform command executable. This is useful if you have multiple copies or versions installed and need to specify a specific binary. The inventory script runs the terraform state pull command to fetch the Terraform state, so that remote state will be fetched seemlessly regardless of the backend configuration.

ANSIBLE_TF_DIR

Set the working directory for the terraform command when the scripts shells out to it. This is useful if you keep your terraform and ansible configuration in separate directories. Defaults to using the current working directory.

License

Licensed for use under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 86.0%
  • HCL 14.0%