Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nbering/terraform-inventory
An Ansible dynamic inventory script to pair with nbering/terraform-provider-ansible.
https://github.com/nbering/terraform-inventory
ansible ansible-inventory terraform
Last synced: 7 days ago
JSON representation
An Ansible dynamic inventory script to pair with nbering/terraform-provider-ansible.
- Host: GitHub
- URL: https://github.com/nbering/terraform-inventory
- Owner: nbering
- License: mit
- Created: 2018-01-06T16:55:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-06-17T21:05:57.000Z (over 2 years ago)
- Last Synced: 2024-04-14T23:52:39.929Z (9 months ago)
- Topics: ansible, ansible-inventory, terraform
- Language: Python
- Homepage:
- Size: 134 KB
- Stars: 175
- Watchers: 11
- Forks: 51
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list-ansible - terraform-inventory - provider-ansible. (terraform)
README
# Terraform Inventory
An Ansible [dynamic inventory][2] script to process Terraform state and return
Ansible host data from [Terraform Provider for Ansible][1] host resources. See the
Terraform Provider for it's own installation and use.## Usage
Copy the [terraform.py](./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\_BINOverride 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.
### ANSIBLE\_TF\_WS\_NAME
Sets the workspace for the `terraform` command when the scripts shells out to it, defaults to `default` workspace - if you don't use workspaces this is the one you'll be using.
## License
Licensed for use under the [MIT License](./LICENSE).
[1]: https://github.com/nbering/terraform-provider-ansible/
[2]: http://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html