Skip to main content

terrible

https://img.shields.io/pypi/v/terrible.svg https://img.shields.io/travis/palmertime/terrible.svg Documentation Status Updates

Terrible (TERRaform to ansIBLE) creates dynamic Ansible inventory from Terraform state.

Installation

To install terrible, run this command in your terminal.:

$ pip install terrible

Once installed a symbolic link or shell script can be added to the Ansible inventory directory.

Symbolic link.:

$ ln -s /path/to/terrible inventory/terrible

Simple shell script wrapper.:

#!/usr/bin/env bash
terrible "$@"

Usage

Usage: terrible [OPTIONS] <root_dir>

  Terrible extracts Ansible inventory data from Terraform state. The
  <root_dir> is relative to the directory where Ansible is executed but
  defaults to ./terraform in the current directory.

Options:
  --host TEXT  Show varibles for single host
  --list       List all variables
  --nometa     Remove _meta from output
  --pretty     Make json look pretty
  --help       Show this message and exit.

Features

Terraform Resources:

Common Parameters

These can be specified by all resources. Uniq configuration details are documented in specific sections below.

ansible_user (Optional)

The user that Ansible will connect to the host. Defaults to root if not specified.

ansible_group (Optional)

The inventory group associated with the resource. (Add default All group?)

ansible_host (Optional)

The host that Ansible will connect to. VMware defaults to IP of 1st interface, network_interface:0 but if can be overwriten to an specific IP. AWS defaults to public_ip and configuralbe to private_ip. (TODO: Add test and error condition for values)

VMware

When defining Terraform vsphere_virtual_machine resource use the custom_configuration_parameters block to set Ansible parameters.

Configuration example:

custom_configuration_parameters {
  ansible_group = "api-gateway"
  ansible_user = "ansible"
  ansible_host = "192.168.52.101"
}

AWS

When defining a Terraform aws-instance resource use tags to set Ansible parameters.

ansible_ssh_private_key_file

The key used to connect to AWS instance. The value is the path to the private key that matches the defined AWS instance key_name. Defaults to the value of key_name + .pem. EXAMPLE: If your AWS instance key_name is terraform then Ansible would look in the current working directory for terraform.pem

Configuration example:

tags {
  Name = "app1-aws"
  ansible_groups = "webapp"
  ansible_user = "ansible"
  ansible_host = "private_ip"
  ansible_ssh_private_key_file = "aws-keys/webapp-terraform.pem"
}

Directory Layout

By default, Terrible looks for the terraform inside the Ansible playbook root directory.:

.
├── ansible.cfg
├── inventory
│   ├── group_vars
│   └── terrible
├── playbooks
│   └── site.yml
├── requirements.yml
├── roles
│   └── example_role
└── terraform
    ├── terraform.tf
    ├── terraform.tfstate
    ├── terraform.tfvars
    └── variables.tf

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

This package was greatly influenced by the sean-abbott/terraform.py project.

History

0.1.2 (2017-08-21)

  • bump version testing

0.1.1 (2017-08-21)

  • Support for aws_instance and vsphere_virtual_machine Terraform resources.

  • Ansible parameters available: ansible_user, ansible_host, ansible_ssh_private_key_file

  • Define Terraform resource to ansible group.

0.1.0 (2017-08-10)

  • First release on PyPI.

Metadata

Release files for terrible 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for terrible 0.1.2
File Size Uploaded Provenance
terrible-0.1.2.tar.gz 16.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for terrible 0.1.2
File Interpreter ABI Platform
terrible-0.1.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 25.5 kB

Release files / terrible-0.1.2.tar.gz

Download URL terrible-0.1.2.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
626ec1d5101d19adabf0b4d4cee39ba4b4e3722caf3d32a60f774ec41f0509c9
BLAKE2b-256 checksum
How to use checksums
5318461420560cb759b22e318f74f8853989555d22103c59b2f9a23bc38cc5e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / terrible-0.1.2-py2.py3-none-any.whl

Download URL terrible-0.1.2-py2.py3-none-any.whl
Size 8.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6d8fa5192a164cdc6f6bda2b53998c46262d5544b8191201f4a305e3eb08f777
BLAKE2b-256 checksum
How to use checksums
379464cf9a4a17e1a591999e0b346874ddec8800dec9cebe67d274fa9edc291f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for terrible 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page