34 Commits
Author SHA1 Message Date
shnee 786bbc4b4b Merge branch 'master' into ansible-test 2021-12-10 10:19:06 -05:00
shnee 6c2d3e3837 Updated get-vim-ips script to use hostnames.
- Made the qemu-agent content in the cloud-init config to be controlled
  by a 'install-qemu-agent' flag.
2021-12-10 10:01:06 -05:00
shnee fee62e0385 Updated get-vim-ips script to use hostnames.
- Made the qemu-agent content in the cloud-init config to be controlled
  by a 'install-qemu-agent' flag.
2021-12-09 23:13:00 -05:00
shnee 482e8d1027 Merged common changes from ansible-test to master. 2021-12-09 14:27:05 -05:00
shnee 5ea36d8626 libvirt bridged network interface
- Added support for libvirt VMs that use a bridged network interface.
2021-12-09 13:46:54 -05:00
shnee 10a88425ed Added Arch libvirt image. 2021-11-29 10:40:33 -05:00
shnee ce3a5b39f5 Rolled back main.tf to have master and worker. 2021-11-26 15:21:32 -05:00
shnee ad0212a29d Added a script to poll AWS node status. 2021-11-26 15:01:54 -05:00
shnee 1787590da2 Use config map and added RHEL 7 & 8. 2021-11-18 11:41:26 -05:00
shnee 17c60e41bb rebase with master 2021-11-18 11:28:38 -05:00
shnee ec6bb824d0 Moved node-config to be local, added AMI vars. 2021-11-18 11:19:59 -05:00
shnee 852d8cfcf2 Update get-vm-ips.sh to work with new map config. 2021-11-18 10:45:58 -05:00
shnee c9ea3d4489 Make libvirt module accept config map. 2021-11-18 09:45:16 -05:00
shnee 9aa0a68be8 AWS nodes and user-data created from config map. 2021-11-17 21:50:07 -05:00
shnee 3088e2295f Added a aws_ami module. 2021-11-17 14:18:31 -05:00
shnee 091b459046 Recomment user-data from master. 2021-11-16 21:02:41 -05:00
shnee b4ac04fbd8 Added aws-ami module. 2021-11-16 21:01:34 -05:00
shnee 8724cede19 Create ansible invetory with get-vm-ips.sh 2021-11-16 14:38:06 -05:00
shnee 31a70766ec Added CentOS 7 & 8 and Arch 2021-11-16 14:36:57 -05:00
shnee 25794c641a Added arch AWS image. 2021-11-15 09:14:33 -05:00
shnee b0b959f28b Creates 1 amazn, 1 ubuntu to test ansible. 2021-11-14 11:49:25 -05:00
shnee f357d3dd5b Forgot to add aws-nodes files.
- Moved network_config.cfg to libvirt-nodes.
2021-11-12 21:58:22 -05:00
shnee cb59a5b2f3 Made cloud-init configs an input to libvirt-nodes. 2021-11-12 20:54:05 -05:00
shnee f8b894739f Fixed cloud-init for aws.
- Organized main.tf
- Still need to add cloud-init as an input parameter for the libvirt
  module.
2021-11-12 20:28:12 -05:00
shnee e3b15f952c Created aws-node module. 2021-11-12 18:31:01 -05:00
shnee 833352fda8 Moved AWS network resources into a aws-network module. 2021-11-12 15:55:25 -05:00
shnee a232bbfd71 Single AWS node is working. 2021-11-12 14:03:45 -05:00
shnee b2ae84be72 Tested with centos 7 image. 2021-11-11 18:37:17 -05:00
shnee 4a62875b8e Added outputs for IPs.
- Made sure node-memory ad node-vcpus is passed down to module.
- Fixed get-vm-ips.sh after move to module.
2021-11-11 14:50:45 -05:00
shnee 3d7bd95f78 node module is working. 2021-11-10 22:22:17 -05:00
shnee 474f6c746a Setting passwords and keys working via variables.
- Setting hostnames is working also.
2021-11-10 15:29:22 -05:00
shnee af17823d68 Setting keys and password with cloud-init working. 2021-11-10 13:59:07 -05:00
shnee b126da8acf Initial attempt is working. 2021-11-10 11:24:50 -05:00
shnee 483c44b695 Add example configs from libvirt provider. 2021-11-09 17:06:17 -05:00
12 changed files with 20 additions and 147 deletions
View File
+20 -20
View File
@@ -1,3 +1,12 @@
terraform {
required_version = ">= 1.0.8"
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.6.11"
}
}
}
locals { locals {
nodes-config = { nodes-config = {
@@ -34,6 +43,10 @@ module "cloud-init-config" {
# libvirt modules/resources. # libvirt modules/resources.
################################################################################ ################################################################################
provider "aws" {
region = "us-east-2"
}
# This module will grab the latest ami for a variety of distros. Uncomment to # This module will grab the latest ami for a variety of distros. Uncomment to
# get a list of the latest AMIs for our supported distros. # get a list of the latest AMIs for our supported distros.
# module "aws-amis" { # module "aws-amis" {
@@ -43,27 +56,14 @@ module "cloud-init-config" {
# value = module.aws-amis.amis # value = module.aws-amis.amis
# } # }
################################################################################ module "aws-network" {
# AWS Networking source = "./modules/aws-network"
# Use of the 2 modules below to create resources for the AWS network. name-prefix = var.vm-name-prefix
# aws-network-from-scratch will build the AWS network from scratch. vpc-cidr-block = var.aws-vpc-cidr-block
# aws-network-existing will query AWS for an existing VPC. subnet-cidr-block = var.aws-subnet-cidr-block
################################################################################ admin-ips = var.admin-ips
# module "aws-network-from-scratch" {
# source = "./modules/aws-network-from-scratch"
# name-prefix = var.vm-name-prefix
# vpc-cidr-block = var.aws-vpc-cidr-block
# subnet-cidr-block = var.aws-subnet-cidr-block
# admin-ips = var.admin-ips
# }
module "aws-network-existing" {
source = "./modules/aws-network-existing"
} }
################################################################################
# This key pair is not actually used. Keys are added to the nodes via cloud-init # This key pair is not actually used. Keys are added to the nodes via cloud-init
# instead. We just add this here that this key will show up in the AWS console." # instead. We just add this here that this key will show up in the AWS console."
resource "aws_key_pair" "key" { resource "aws_key_pair" "key" {
@@ -127,7 +127,7 @@ module "nodes" {
# end libvirt # end libvirt
################################################################################ ################################################################################
# This will output a map of group => [{hostname, ip}]. # This will outpus a map of group => [{hostname, ip}].
# TODO A 'names' output needs to be added to libvirt. # TODO A 'names' output needs to be added to libvirt.
output "groups_hostnames_ips" { output "groups_hostnames_ips" {
value = { for type, node in module.nodes : type => zipmap(node.names, node.ips) } value = { for type, node in module.nodes : type => zipmap(node.names, node.ips) }
-23
View File
@@ -1,23 +0,0 @@
locals {
az-to-subnets = {
for s in data.aws_subnet.subnets : s.availability_zone => s.id...
}
}
data "aws_vpc" "default" {
tags = {
Name = var.default-vpc-name
}
}
data "aws_subnets" "subnet-ids" {
filter {
name = "vpc-id"
values = [data.aws_vpc.default.id]
}
}
data "aws_subnet" "subnets" {
for_each = toset(data.aws_subnets.subnet-ids.ids)
id = each.key
}
-18
View File
@@ -1,18 +0,0 @@
output "default-vpc" {
value = data.aws_vpc.default
}
output "subnets" {
description = "An array of all subnets in default-vpc."
value = data.aws_subnet.subnets
}
output "k8s-subnets" {
description = "An array of subnets to be used for k8s VMs. These subnets were chosen by selecting a single subnet from each availability_zone."
value = [for k,v in local.az-to-subnets : v[0]]
}
output "az-to-subnets" {
description = "A map of availability zone to array of subnets that are in thet availability zone."
value = local.az-to-subnets
}
@@ -1,4 +0,0 @@
variable "default-vpc-name" {
description = "The name of the existing default VPC. This module will query AWS for a VPC with this name,"
default = "Managed VPC"
}
-1
View File
@@ -1,7 +1,6 @@
resource "aws_instance" "nodes" { resource "aws_instance" "nodes" {
ami = var.ami ami = var.ami
instance_type = var.ec2-instance-type instance_type = var.ec2-instance-type
# TODO REM double check this key.
# key_name = aws_key_pair.debug1.key_name # key_name = aws_key_pair.debug1.key_name
associate_public_ip_address = true associate_public_ip_address = true
subnet_id = var.subnet-id subnet_id = var.subnet-id
-76
View File
@@ -1,76 +0,0 @@
provider "aws" {
region = "us-gov-west-1"
}
terraform {
required_version = ">= 1.0.8"
backend "s3" {
bucket = "mss-terraform-state"
key = "global/s3/terraform.tfstate"
region = "us-gov-west-1"
dynamodb_table = "mss-terraform-state-lock"
encrypt = true
}
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.6.11"
}
}
}
##
#S3 bucket create to hold our TFState file so we can all share env settings
resource "aws_s3_bucket" "terraform_state" {
bucket = "mss-terraform-state"
# enable versioning for the state files
versioning {
enabled = true
}
#enable server-side encryption
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
##
# no sql database used so that we can lock the TFstate file in the S3 bucket to ensure two people
# are not running a terraform command at the same time
resource "aws_dynamodb_table" "terraform_locks" {
name = "mss-terraform-state-lock"
billing_mode = "PAY_PER_REQUEST"
hash_key = "LockID"
attribute {
name = "LockID"
type = "S"
}
}
##
# output variable to give details on the s3 bucket created
#TODO: move to output.tf
output "s3_bucket_arn" {
value = aws_s3_bucket.terraform_state.arn
description = "The ARN of the S3 bucket"
}
-5
View File
@@ -8,11 +8,6 @@ variable "aws-ec2-instance-type" {
description = "The AWS instance type to use for all nodes." description = "The AWS instance type to use for all nodes."
} }
variable "aws-region" {
default = "us-east-1"
description = "The AWS region to use."
}
variable "aws-subnet-cidr-block" { variable "aws-subnet-cidr-block" {
default = "10.0.1.0/24" default = "10.0.1.0/24"
description = "The address space to be used for this subnet." description = "The address space to be used for this subnet."