Skip to content

Latest commit

 

History

History
118 lines (93 loc) · 2.8 KB

README.md

File metadata and controls

118 lines (93 loc) · 2.8 KB

Demo Terraform

A demo Terraform usage and templates.

1. Installation

TERRAFORM_VER=`curl -sS https://releases.hashicorp.com/terraform/ | grep href | head -2 | tail -1 | awk -F/ '{print $3}'`
curl -o terraform.zip https://releases.hashicorp.com/terraform/${TERRAFORM_VER}/terraform_${TERRAFORM_VER}_linux_amd64.zip
unzip terraform.zip
sudo mv terraform /usr/local/bin/terraform
rm -f terraform.zip
terraform version

2. Getting Started

Check out source code:

git clone https://github.com/minhluantran017/demo-terraform.git
cd demo-terraform

Code structure:

.
|____<provider>             // Each provider is a directory
|    |____provider.tf       // Contains general configurations for this provider
|    |____<...>.tf          // Contains TF plans for components
|    |____<...>.tfvars      // Contains variables for plans 
|____scripts                // Contains shell/python/powershell scripts
|    |____*.sh
|    |____*.py
|____files                  // Contains other files 
|    |____*.txt
|    |____*.cfg
|____LICENSE               // Contains licenses
|____README.md

Create a simple AWS environment

TODO

Create a simple vSphere environment

Go to vsphere folder:

cd vsphere

Replace value in templates/terraform.tfvars.tpl with proper values.

envsubst <templates/terraform.tfvars.tpl >terraform.tfvars

Then proceed with Terraform commands:

terraform init
terraform plan
terraform apply -auto-approve

Create a simple KVM environment

Go to kvm folder:

cd kvm

Simple CentOS VM creation can be found here. Just proceed with Terraform commands:

terraform init
terraform plan
terraform apply -auto-approve

For using module, please use example format as follow:

module "ubuntu-vm" {
    source          = "git::https://github.com/minhluantran017/demo-terraform.git//kvm/module-vm?ref=v0.1.4"
    base_image_url  = "https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img"
    libvirt_pool    = "devops"
    create_pool     = true
    vm_name         = "ubuntu-vm"
    vm_count        = 1
    vm_vcpu         = 4
    vm_memory       = 8096
    vm_disk         = 100000000000
    ip_addresses    = [
        "10.250.200.191"
    ]
    gw_address      = "10.250.200.1"
    dns_address     = "10.250.200.2"
    ssh_public_key  = "ssh-rsa AAAA..."
}

Create aa simple OpenStack environment

TODO

3. Code of Conduct

  • Create branch for each component from master with convention: dev_<provider>. For example: dev_aws.

  • Please always create Pull Request to merge it to master. Only merge if all the tests pass.

4. Licenses

Terraform is under MPL2 licence. See LICENSE

5. TODO

  • N/A