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

Loading…
Cancel
Save