Created aws-node module.

ansible-test
shnee 4 years ago
parent 833352fda8
commit e3b15f952c

@ -40,25 +40,34 @@ data "template_file" "node-user-datas" {
count = var.master-nodes count = var.master-nodes
} }
resource "aws_instance" "test-node" { module "master-nodes" {
source = "./modules/aws-nodes"
ami = var.base-image ami = var.base-image
instance_type = var.aws-ec2-instance-type ec2-instance-type = var.aws-ec2-instance-type
# key_name = aws_key_pair.debug1.key_name subnet-id = module.aws-network.subnet.id
associate_public_ip_address = true security-group-ids = [module.aws-network.default-security-group.id]
subnet_id = module.aws-network.subnet.id user-datas = data.template_file.node-user-datas
vpc_security_group_ids = [module.aws-network.default-security-group.id] num-nodes = var.master-nodes
user_data = element(data.template_file.node-user-datas.*.rendered, count.index) name-prefix = "${var.vm-name-prefix}-master"
count = var.master-nodes
tags = {
Name = "${var.vm-name-prefix}-test"
}
} }
output "master-ips" { module "worker-nodes" {
value = aws_instance.test-node.*.public_ip source = "./modules/aws-nodes"
ami = var.base-image
ec2-instance-type = var.aws-ec2-instance-type
subnet-id = module.aws-network.subnet.id
security-group-ids = [module.aws-network.default-security-group.id]
user-datas = data.template_file.node-user-datas
num-nodes = var.worker-nodes
name-prefix = "${var.vm-name-prefix}-worker"
} }
################################################################################
# libvirt
# To use the libvirt module, uncomment the libvirt modules/resources and comment
# out the aws modules/resources.
################################################################################
# provider "libvirt" { # provider "libvirt" {
# uri = var.libvirt-connection-url # uri = var.libvirt-connection-url
# } # }
@ -94,12 +103,16 @@ output "master-ips" {
# type = "dir" # type = "dir"
# path = var.disk-image-dir # path = var.disk-image-dir
# } # }
#
# # TODO REM move to other file? ################################################################################
# output "master-ips" { # end libvirt
# value = module.master-nodes.ips ################################################################################
# }
# # TODO REM move to other file?
# output "worker-ips" { output "master-ips" {
# value = module.worker-nodes.ips value = module.master-nodes.ips
# } }
output "worker-ips" {
value = module.worker-nodes.ips
}

@ -15,7 +15,7 @@ variable "aws-subnet-cidr-block" {
variable "aws-vpc-cidr-block" { variable "aws-vpc-cidr-block" {
default = "10.0.0.0/16" default = "10.0.0.0/16"
description = "The address space to be used for this VPC." description = "The address space to be used for the VPC that all the AWS nodes will be in."
} }
variable "disk-image-dir" { variable "disk-image-dir" {

Loading…
Cancel
Save