Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commenting out code for creating 2nd interface on VMs. Not needed. Ch… #361

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 60 additions & 59 deletions aws.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ variable "aws_ami" {
}

variable "aws_instance_type" {
default = "t2.large"
default = "t2.micro"
}

# how many VMs to spin up.
Expand All @@ -102,67 +102,68 @@ variable "num_nodes" {
default = "3"
}

# ============================================
# networks

### commenting out - 2nd interface not needed for vxlan testing on aws - doug.
## ============================================
## networks
##
## vars
## for convenience, we are using a pre-defined security group, its
## associated vpc and subnet.
##
## for the second interface, define a new subnet inside the vpc.
#
# vars
# for convenience, we are using a pre-defined security group, its
# associated vpc and subnet.
## eth1 - vxlan network
#resource "aws_network_interface" "netplugin_vxlan_interface" {
# subnet_id = "${aws_subnet.netplugin_vxlan_subnet.id}"
# security_groups = ["${var.our_security_group_id}"]
# count = "${var.num_nodes}"
#
# for the second interface, define a new subnet inside the vpc.


# eth1 - vxlan network
resource "aws_network_interface" "netplugin_vxlan_interface" {
subnet_id = "${aws_subnet.netplugin_vxlan_subnet.id}"
security_groups = ["${var.our_security_group_id}"]
count = "${var.num_nodes}"

# tell which instance(s) this interface belongs to
attachment {
instance = "${element(aws_instance.jenkins_netplugin.*.id, count.index)}"
device_index = 1
}
}

resource "aws_subnet" "netplugin_vxlan_subnet" {
vpc_id = "${var.our_vpc_id}"
# creates a different subnet using buildnum to generate a number
# between 100 and 200
cidr_block = "172.31.${var.buildnum%100 + 100}.0/24"
availability_zone = "${var.aws_availability_zone}"
}


# ============================================
# post-launch commands
# # tell which instance(s) this interface belongs to
# attachment {
# instance = "${element(aws_instance.jenkins_netplugin.*.id, count.index)}"
# device_index = 1
# }
#}
#
# these will be run on each instance after it is launched

variable "ssh_user" {
default = "centos"
}

# setup eth1 with IP# for all instances
resource "null_resource" "configure-interfaces" {
count = "${var.num_nodes}"
triggers {
jenkins_netplugin_instance_ids = "${join(",", aws_instance.jenkins_netplugin.*.id)}"
}

provisioner "remote-exec" {
inline = ["sudo /sbin/ip addr add '172.31.${var.buildnum%100}.1${count.index}/24' dev eth1 && sudo /sbin/ip link set dev eth1 up"]
}

connection {
type = "ssh"
user = "${var.ssh_user}"
private_key = "${file(var.key_path)}"
agent = false
host = "${element(aws_instance.jenkins_netplugin.*.public_ip, count.index)}"
}

}
#resource "aws_subnet" "netplugin_vxlan_subnet" {
# vpc_id = "${var.our_vpc_id}"
# # creates a different subnet using buildnum to generate a number
# # between 100 and 200
# cidr_block = "172.31.${var.buildnum%100 + 100}.0/24"
# availability_zone = "${var.aws_availability_zone}"
#}
#
#
## ============================================
## post-launch commands
##
## these will be run on each instance after it is launched
#
#variable "ssh_user" {
# default = "centos"
#}
#
## setup eth1 with IP# for all instances
#resource "null_resource" "configure-interfaces" {
# count = "${var.num_nodes}"
# triggers {
# jenkins_netplugin_instance_ids = "${join(",", aws_instance.jenkins_netplugin.*.id)}"
# }
#
# provisioner "remote-exec" {
# inline = ["sudo /sbin/ip addr add '172.31.${var.buildnum%100}.1${count.index}/24' dev eth1 && sudo /sbin/ip link set dev eth1 up"]
# }
#
# connection {
# type = "ssh"
# user = "${var.ssh_user}"
# private_key = "${file(var.key_path)}"
# agent = false
# host = "${element(aws_instance.jenkins_netplugin.*.public_ip, count.index)}"
# }
#
#}

# WIP - have not tried the ansible command yet.
# need to strip out the hardcoded IP#'s and use something like:
Expand Down