Skip to main content

Orchestrate OpenTofu (or Terraform) initialization and interactions with Ansible and Incus (including Incus S3 bucket as state backend).

Project description

tf-glue

Orchestrate OpenTofu (or Terraform) initialization and interactions with Ansible and Incus (including Incus S3 bucket as state backend).

Features

This tool provides some frequently needed glue for projects that combine part of, or all of, the following infrastructure automation stack:

Supported interactions between OpenTofu/Terraform and Incus:

Supported interactions with Ansible:

  • Read Incus client configuration from Ansible inventory's variables defined for the Incus connection plugin.
  • Identify unused IP addresses on Incus networks, reserve them, so that they can be passed as variables to a dynamic Ansible inventory.
  • Generate a dynamic Ansible inventory by compiling a YAML Jinja2 template with variables coming from Incus client and/or OpenTofu.

Installation

This tool can be installed from PyPI:

pip install tf-glue

Add the template extra (i.e. pyyaml and jinja2) to generate dynamic Ansible inventories from templates:

pip install tf-glue[template]

Usage

This tool can be used as a command-line application. The following example initializes OpenTofu (or Terraform) with an Incus-managed S3 bucket named myproject-state as its state backend (the bucket is automatically created if it does not exist yet) and variable definitions related to Incus client configuration:

tf-glue init --bucket myproject-state

See command-line help for available commands and options:

tf-glue --help

This tool can also be used as a Python library. Example:

#!/usr/bin/env python3
from tf_glue.ansible import generate_inventory
from tf_glue.incus import Incus

incus = Incus()  # will use the environment detected by the Incus command-line client
generate_inventory("mytemplate.yml", incus=incus)

Contributing

Pull requests are welcome. See:

Legal

This tool is licensed under the MIT license.

It is not affiliated in any way with OpenTofu, Terraform, Ansible, Incus or any associated organization.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tf_glue-1.0.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file tf_glue-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tf_glue-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tf_glue-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa8a2022c2a4f9d8911508ca8e689f497e68bdc6e0b6f2385fb9f921bab3db64
MD5 8d6982a34769c6a9951c89f4d60195a2
BLAKE2b-256 ccb5c9ddf613b238de488d3cbbe8795536948ac414fda55497e8d7acbb7b7ee3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page