Coder Social home page Coder Social logo

kyxap1 / do-stack-template Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cmndrsp0ck/do-stack-template

0.0 3.0 0.0 13 KB

Terraform files which can be used in addition to Ansible roles to deploy on DigitalOcean

License: MIT License

HCL 36.71% Shell 63.29%

do-stack-template's Introduction

Purpose

This repo can be used to stand up various parts of your deployment on DigitalOcean using Terraform modules. The current modules include:

  • HAProxy load balancers (active-passive) with a floating IP
  • Backend nodes
  • Galera cluster

Prerequisites

  • You'll need to install Terraform which will be used to handle Droplet provisioning.
  • In order to apply configuration changes to the newly provisioned Droplets, Ansible needs to be installed.
  • Ansible's inventory will be handled by Terraform, so you'll need terraform-inventory.
  • We're going to need a DigitalOcean API key. The steps to generate a DigitalOcean API key can be found here.
  • Use the included gen_auth_key script to generate an auth key for your load balancing cluster.

Configuring

Use terraform.tfvars to store values required such as API key, project name, and SSH data. The sample file terraform.tfvars.sample has been supplied, just remember to remove the appended .sample. Once you have your all of the variables set, Terraform should be able to authenticate in order to deploy your Droplets.

Uncomment any blocks in main.tf for each module you want to use. You'll also be able to edit the module arguments for things like Droplet size and number of Droplets.

module "galera-cluster" {
  source           = "./modules/galera-cluster"
  project          = "${var.project}"
  region           = "${var.region}"
  keys             = "${var.keys}"
  private_key_path = "${var.private_key_path}"
  ssh_fingerprint  = "${var.ssh_fingerprint}"
  public_key       = "${var.public_key}"
}

This should allow you to spin up your Droplets and you'll be able to use terraform-inventory in order to to create your dynamic inventory listing to be used by Ansible. You'll be able to create roles/, then cd into it, and git clone a role you want to use such as galera-cluster.

Deploying

We'll start by using Terraform. Make sure you head back to the repository home. You can run a quick check and create an execution plan by running terraform plan.

Once you're ready, use terraform apply to build the Droplets and floating IP. This should take about a minute or two depending on how many nodes you're spinning up. Once it finishes up, wait about 30 seconds for the cloud-config commands that were passed in to complete.

When you're ready to begin configuring your Droplets, refer to the documentation for each Ansible role.

Follow-up steps

Keep in mind that this is a very basic setup, but the template files and tasks can easily be altered to suit your needs. If you already have Droplets provisioned, you can import them into Terraform, as well as create an image from it and use the image ID to spin up additional nodes. Any additional configuration can simple by done by creating a simple Ansible role, or modifying the existing one.

do-stack-template's People

Contributors

cmndrsp0ck avatar

Watchers

 avatar  avatar  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.