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

more params for lc #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
17 changes: 12 additions & 5 deletions stack/generic-asg-ec2/ec2-asg.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ resource "aws_autoscaling_group" "generic-asg" {
min_size = "${var.min_size}"
desired_capacity = "${var.desired_capacity}"
health_check_type = "${var.hc_type}"
launch_template = {
id = "${aws_launch_template.generic_lc_template.id}"
version = "$$Latest"
launch_template = {
id = "${aws_launch_template.generic_lc_template.id}"
version = "$$Latest"
}
vpc_zone_identifier = ["${var.subnets}"]

Expand All @@ -15,6 +15,13 @@ resource "aws_autoscaling_group" "generic-asg" {
resource "aws_launch_template" "generic_lc_template" {
name = "lc-${var.name}"
key_name = "${var.key_name}"
image_id = "${var.image_id}"

image_id = "${var.ami_id}"
instance_type = "${var.instance_type}"
vpc_security_group_ids = "${var.vpc_security_group_ids}"
tag_specifications {
resource_type = "instance"
tags {
Name = "${var.name}"
}
}
}
17 changes: 13 additions & 4 deletions stack/generic-asg-ec2/vars_app.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ variable "name" {
}

variable "max_size"{
default = 1
}
default = 1
}

variable "min_size"{
default = 1
Expand All @@ -26,6 +26,15 @@ variable "key_name" {
default = "test"
}

variable "image_id"{
default = "ami-0e4c9b46b89ddd90c"
variable "ami_id"{
default = "ami-0e4c9b46b89ddd90c"
}

variable "instance_type" {
default = "t2.medium"
}

variable "vpc_security_group_ids" {
default = [""]
}

45 changes: 45 additions & 0 deletions stack/kubernetes-kubeadm/server.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
provider "aws" {
profile = "vrdev"
region = "us-east-2"
}

data "template_file" "init" {
template = "${file("user-data.sh")}"
}
resource "aws_instance" "master" {
#ami = "ami-03c6239555bb12112"
#ami = "ami-0f65671a86f061fcd"
ami = "${var.ami-id}"
instance_type = "${var.instance-type}"
subnet_id = "${var.subnet-id}"
key_name = "${var.key-name}"
security_groups = "${var.security-groups}"

user_data = "${data.template_file.init.rendered}"
tags {
Name = "{$var.name-master}"
}

#provisioner "local-exec" {
# command = "echo ${aws_instance.master.private_ip} >> private_ips.txt"
# }
# provisioner "local-exec" {
# command = "sleep 60; ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -e 'ansible_python_interpreter=/usr/bin/python3' -u ubuntu --private-key /home/lazevedo/Documents/KEYS/VR-CLOUD-TEAM.ppk -i '${aws_instance.master.private_ip}', /home/lazevedo/Documents/repo/terraform-geek182/stack/kubernetes-kubeadm/playbook.yml"
# }
}




resource "aws_instance" "worker1" {
ami = "${var.ami-id}"
instance_type = "${var.instance-type}"
subnet_id = "${var.subnet-id}"
key_name = "${var.key-name}"
security_groups = "${var.security-groups}"
user_data = "${data.template_file.init.rendered}"
tags {
Name = "${var.name-worker}"
}

}
14 changes: 14 additions & 0 deletions stack/kubernetes-kubeadm/user-data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

sysctl -p
apt-get update
apt-get install -y docker.io

apt-get update && apt-get install -y apt-transport-https curl
curl -4 -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
apt-get update
apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl

echo $(kubectl version)
27 changes: 27 additions & 0 deletions stack/kubernetes-kubeadm/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
variable "ami-id" {
default = "ami-0f65671a86f061fcd"
}

variable "instance-type" {
default = "t2.micro"
}

variable "subnet-id" {
default = ""
}

variable "key-name" {
default = ""
}

variable "security-groups" {
default = ["sg,sg"]
}

variable "name-worker" {
default = "WORKER"
}

variable "name-master"{
default = "MASTER"
}