Giter Site home page Giter Site logo

dangernil / terraform-nomad-postgres Goto Github PK

View Code? Open in Web Editor NEW

This project forked from skatteetaten/terraform-nomad-postgres

0.0 0.0 0.0 114 KB

License: Apache License 2.0

Python 2.50% Makefile 21.42% HCL 60.11% Shell 1.49% Dockerfile 14.49%

terraform-nomad-postgres's Introduction

Terraform-nomad-postgres

This module is IaC - infrastructure as code which contains a nomad job of postgres.

Content

  1. Usage
  2. Requirements
    1. Required software
    2. Providers
  3. Inputs
  4. Outputs
  5. Example usage
    1. Verifying setup
  6. Volumes
  7. Vault secrets
  8. License

Usage

make test

The command will run a standalone instance of postgres found in the example folder.

Requirements

Required software

Providers

Inputs

Name Description Type Default Required
nomad_datacenters Nomad data centers list(string) ["dc1"] no
nomad_namespace [Enterprise] Nomad namespace string "default" no
nomad_host_volume Nomad host volume name string "persistence" no
service_name Postgres service name string "postgres" no
container_port Postgres port number 5432 no
container_image Postgres docker image string "postgres:12-alpine" no
admin_user Postgres admin username string or data obj "postgres" yes
admin_password Postgres admin password string or data obj "postgres" yes
admin_password Postgres database name string "metastore" yes
container_environment_variables Postgres container environement variables list(string) ["PGDATA=/var/lib/postgresql/data"] no
volume_destination Postgres volume destination string "/var/lib/postgresql/data" no
use_host_volume Use nomad host volume bool false no

Outputs

Name Description Type
service_name Postgres service name string
username Postgres username string
password Postgres password string
database_name Postgres database name string
port Postgres port number

Example usage

The example-code shows the minimum of what you need to use this module.

module "postgres" {
  source = "github.com/fredrikhgrelland/terraform-nomad-postgres.git?ref=0.0.2"

  # nomad
  nomad_datacenters = ["dc1"]
  nomad_namespace   = "default"
  nomad_host_volume = "persistence"

  # postgres
  service_name                    = "postgres"
  container_image                 = "postgres:12-alpine"
  container_port                  = 5432
  admin_user                      = "postgres"
  admin_password                  = "postgres"
  database                        = "metastore"
  volume_destination              = "/var/lib/postgresql/data"
  use_host_volume                 = true
  container_environment_variables = ["PGDATA=/var/lib/postgresql/data"]
}

Verifying setup

You can verify that postgres is running by checking the connection. This can be done using the consul docker image to set up a proxy. Check out the required software section.

make proxy-to-postgres

Volumes

We are using host volume to store postgres data. If the use_host_volume is set to true, Postgres data will be available in root /persistence/postgres folder inside the Vagrant box.

Vault secrets

The postgres username and password is generated and put in /secret/postgres inside Vault.

To get the username and password from Vault you can login to the Vault-UI with token master and reveal the username and password in /secret/postgres. Alternatively, you can ssh into the vagrant box with vagrant ssh, and use the vault binary to get the username and password. See the following commands:

# get username
vault kv get -field='username' secret/postgres

# get password
vault kv get -field='password' secret/postgres

License

This work is licensed under Apache 2 License. See LICENSE for full details.

terraform-nomad-postgres's People

Contributors

claesgill avatar dangernil avatar fredrikhgrelland avatar zhenik avatar pdmthorsrud avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.