Terraform Module Collection

For Easy Provide Infrastructure, here some Terraform modules. The Modules wrappped the hcloud terraform provider, with some preconfiguration elements. This modules build the basic Infrastructure, from nolte/personal-storage-infrastructure and nolte/minecraft-infrastructure.

Terraform Modules

Github Project Stars Travis CI build status Documentation Status Github Issue Tracking Github LatestRelease

Repository for Shared, reuseable Terraform Modules. At the Moment the modules only useable for the hetzner.de/cloud, with the terraform Provider.

Usage

module "private_access_key" {
    source = "git::https://github.com/nolte/terraform-infrastructure-modules.git//[module_name]?ref=v0.0.5.dev"
    ...
}

Modules

module

description

project_access_elements

Handle the Accees Keys from a Project (wrapper for the hcloud_ssh_key).

storage_elements

Handle Storage Volumes (wrapper for hcloud_volume).

computing_elements

Handle Computing Instances (wrapper for hcloud_server), execute a preconfiguration with CloudInit.

Development

virtualenv -p python3 ~/venvs/development
source ~/venvs/development/bin/activate
pip install -r requirements.txt
pre-commit install

Add Required asdf Plugin Repositories for install additional tools.

asdf plugin-add terraform-docs https://github.com/looztra/asdf-terraform-docs
asdf plugin-add task https://github.com/nolte/asdf-task.git
asdf install

List Existing tasks

$ task -l

task: Available tasks for this project:
* default:                              Generate All Module Readme Files
* tfdocs_computing_elements:            Readme for Computing Elements
* tfdocs_project_access_elements:       Readme for Project Access Elements
* tfdocs_storage_elements:              Readme for Storage Elements

Testing

export PASSWORD_STORE_DIR=~/.password-store
export HCLOUD_TOKEN=$(pass internet/hetzner.com/projects/minecraft/terraform-token)
export TF_machine_access_pass_path=private/keyfiles/ssh/online/onlineSecond_rsa.pub

go test -v -timeout 30m

Docs

tox -e docs

Example

Handle a Storage Volume
module "minio_storage_runtime" {
  source       = "git::https://github.com/nolte/terraform-infrastructure-modules.git//storage_elements?ref=v0.0.5.dev"

  storage_name = "minio_storage_runtime"
  storage_size = 30
  storage_labels = {
    service = "storagebox"
    type    = "runtime_storage"
  }
}

For more Information take a look to the source at storage_elements/main.tf and storage_elements/variables.tf

Example

Crate a Ready For Configure VM, with mounted Volues and preconfigured Ansible User (ready for, nolte/ansible_playbook-baseline-online-server).

handle a reconfigured computing instance
module "minio_computing_elements" {
  source                                           = "git::https://github.com/nolte/terraform-infrastructure-modules.git//computing_elements?ref=v0.0.5.dev"

  computing_instance_name                          = "${var.minio_computing_instance_name}"
  computing_instance_usage_root_key                = "${data.hcloud_ssh_key.machine_key.id}"
  computing_instance_labels                        = "${local.merged_minio_computing_instance_labels}"
  computing_instance_ssh_machine_key_id_var        = "${data.hcloud_ssh_key.machine_key.public_key}"
  computing_instance_ssh_private_key_id_var        = "${data.hcloud_ssh_key.private_key.public_key}"
  computing_instance_additional_volumes_cloud_init = "${data.template_file.cloudinit_mounts.rendered}"
}

you will find some example used in nolte/personal-storage-infrastructure or nolte/minecraft-infrastructure.

Ansible User

SSHD Config

Example

Required: camptocamp/terraform-provider-pass

Create a SSH Key from given pass path
module "management_access_key" {
  source = "git::https://github.com/nolte/terraform-infrastructure-modules.git//project_access_elements?ref=v0.0.5.dev"

  name      = "management_key"
  pass_path = "${var.machine_access_pass_path}"
  labels = {
    usage = "machine"
  }
}

For more Information take a look to the source at project_access_elements/main.tf and project_access_elements/variables.tf