Code Monkey home page Code Monkey logo

nomad_jobs's Introduction

nomad_jobs

A collection of Nomad Jobds to run as part of the meanstack-consul-connect demo

These are tightly coupled with the nomad created in the repo terraform-aws-demostack

These should NOT be used as examples of a production deployment.

List demos

PortgreSQL dynamic credentials

Declare the following in your runjobs.tf

resource "nomad_job" "postgresSQL" {
  jobspec = "${file("./postgresSQL.nomad")}"
}

resource "nomad_job" "pgadmin" {
  jobspec = "${file("./pgadmin.nomad")}"
}

This first script will deploy the PostgreSQL database, whilst the second one will deploy the PGAdmin tool.

Once you open the pgadmin tool, there's already a preconfigured connection named Server Group 1 with:

  • postgres.service.consul:5432
  • username="root"
  • password="rootpassword"
  • disable SSL
  • database = postgres

Setup your vault

vault secrets enable database
vault write database/config/postgresql  plugin_name=postgresql-database-plugin connection_url="postgresql://{{username}}:{{password}}@postgres.service.consul:5432/postgres?sslmode=disable" allowed_roles="*" username="root" password="rootpassword"
vault write database/roles/readonly db_name=postgresql [email protected] default_ttl=1h max_ttl=24h

You can find the readonly.sql file in this repo.

# read credentials
vault read database/creds/readonly

Vault SSH OTP

Declare the following in your runjobs.tf, where nomad_node is your nomad node name for ssh.

data "template_file" "vault-ssh-helper" {
  template = "${file("./vault-ssh-helper.nomad.tpl")}"
  vars = {
    nomad_node = "ric-lnd-stack-server-1"
  }
}

resource "nomad_job" "vault-ssh-helper" {
  jobspec = "${data.template_file.vault-ssh-helper.rendered}"
}

Afterwards, setup vault

vault secrets enable ssh
vault write ssh/roles/otp_key_role key_type=otp default_user=ubuntu cidr_list=0.0.0.0/0

And from your client machine you'll be able to accessthe node:

vault ssh -role otp_key_role -mode otp -strict-host-key-checking=no ubuntu@<nomad_node_ip/host>

Vault SSH CA

Declare the following in your runjobs.tf, where nomad_node is your nomad node name for ssh.

data "template_file" "vault-ssh-ca" {
  template = "${file("./vault-ssh-ca.nomad.tpl")}"
  vars = {
    nomad_node = "ric-lnd-stack-server-1"
  }
}

resource "nomad_job" "vault-ssh-ca" {
  jobspec = "${data.template_file.vault-ssh-ca.rendered}"
}

This demo will already setup your Vault with the right backend and role. To use it, make sure you have an existing ssh key pair (ssh-keygen -t rsa -C "[email protected]) Then sign your key and save it to disk

# to sign your key
vault write -field=signed_key ssh-client-signer/sign/my-role \
    public_key=@$HOME/.ssh/id_rsa.pub > signed-cert.pub

# (Optional) to verify your keygen
ssh-keygen -Lf  signed-cert.pub

# Then just sign in (replacing your server hostname)
ssh -i signed-cert.pub -i ~/.ssh/id_rsa ubuntu@<nomad_node_ip/hostname>

LDAP Auth

Declare the following in your runjobs.tf,

resource "nomad_job" "ldap-server" {
  jobspec = "${file("./ldap-server.nomad")}"
}
resource "nomad_job" "phpldapadmin" {
  jobspec = "${file("./phpldapadmin.nomad")}"
}

You can login via fabio on http://fabio.<demo stack namespace>.hashidemos.io:9999/phpldapadmin-server/ as cn=admin,dc=example,dc=org, to view the users that are pre-loaded.

To configure vault for the control groups demo, see LDAP-configure-Vault-Script

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.