Added CentOS 7 & 8 and Arch
This commit is contained in:
@@ -45,4 +45,5 @@ terraform.rc
|
|||||||
|
|
||||||
k8s-key*
|
k8s-key*
|
||||||
STARTHERE
|
STARTHERE
|
||||||
|
inventory
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,12 @@ aws-ec2-instance-type = "t2.micro"
|
|||||||
# AWS Amazon Linux 2 AMI (HVM), SSD Volume Type - us-east-2 - 2021.11.12 - free
|
# AWS Amazon Linux 2 AMI (HVM), SSD Volume Type - us-east-2 - 2021.11.12 - free
|
||||||
base-image = "ami-0dd0ccab7e2801812"
|
base-image = "ami-0dd0ccab7e2801812"
|
||||||
|
|
||||||
|
## CentOS
|
||||||
|
# CentOS 7.9.2009 x86_64 - us-east-2 - 2021-11-15
|
||||||
|
# base-image = "ami-00f8e2c955f7ffa9b"
|
||||||
|
# CentOS 8.4.2105 x86_64 - us-east-2 - 2021-11015
|
||||||
|
# base-image = "ami-057cacbfbbb471bb3"
|
||||||
|
|
||||||
## Ubuntu
|
## Ubuntu
|
||||||
# Ubuntu Server 20.04 LTS (HVM), SSD Volume Type
|
# Ubuntu Server 20.04 LTS (HVM), SSD Volume Type
|
||||||
# us-east-2 - (64-bit x86) - 2021.11.12 - free
|
# us-east-2 - (64-bit x86) - 2021.11.12 - free
|
||||||
|
|||||||
+51
-10
@@ -1,19 +1,60 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This script will create environment variables for all of the output IPs. It
|
||||||
|
# will also create a `ANSIBLE_INV` variable that will be a comma separated
|
||||||
|
# string of all the IPs. A anisble inventory file called "inventory is created
|
||||||
|
# as well.
|
||||||
|
#
|
||||||
# Use eval $(./get-vm-ips.sh) to set env vars for ips.
|
# Use eval $(./get-vm-ips.sh) to set env vars for ips.
|
||||||
|
|
||||||
terraform refresh > /dev/null
|
terraform refresh > /dev/null
|
||||||
|
|
||||||
IPS_JSON="$(terraform show -json | jq '.values.outputs')"
|
# All terraform outputs in json format.
|
||||||
|
OUTPUTS_JSON="$(
|
||||||
|
terraform show -json | \
|
||||||
|
jq '.values.outputs' | \
|
||||||
|
sed 's/-/_/g')"
|
||||||
|
# Just the IP address outputs in json format. Also all '-' characters are
|
||||||
|
# replaced by '_' becuase '-' causes jq some problems.
|
||||||
|
IPS_JSON="$(
|
||||||
|
echo $OUTPUTS_JSON | \
|
||||||
|
jq 'to_entries | .[] | select(.key | contains("ips"))')"
|
||||||
|
# An array of all node "types"
|
||||||
|
NODE_TYPE_ARRAY="$(
|
||||||
echo $IPS_JSON | \
|
echo $IPS_JSON | \
|
||||||
jq '."master-ips".value[]' | \
|
jq '.key' | \
|
||||||
nl -v 0 | \
|
sed 's/"//g' | \
|
||||||
awk '{print "export MASTER" $1 "=" $2}' | \
|
sed -z 's/\n/ /g;s/ $/\n/g')"
|
||||||
sed 's/"//g'
|
|
||||||
|
|
||||||
echo $IPS_JSON | \
|
# Loop over all the node types and create an export line for each IP.
|
||||||
jq '."worker-ips".value[]' | \
|
VM_IP_EXPORTS="$(
|
||||||
|
for TYPE in $NODE_TYPE_ARRAY; do
|
||||||
|
|
||||||
|
# Convert type, converts "master-ips" to "MASTER"
|
||||||
|
TYPE_UPPER="$(echo ${TYPE^^} | sed s/_.*$//g)"
|
||||||
|
echo "$OUTPUTS_JSON" | \
|
||||||
|
jq '.'"$TYPE"'.value[]' | \
|
||||||
|
# Add line numbers starting with 0.
|
||||||
nl -v 0 | \
|
nl -v 0 | \
|
||||||
awk '{print "export WORKER" $1 "=" $2}' | \
|
# Print an export string with a type placeholder "__TYPE__".
|
||||||
sed 's/"//g'
|
awk '{print "export __TYPE__" $1 "=" $2}' | \
|
||||||
|
sed s/__TYPE__/$TYPE_UPPER/g
|
||||||
|
done)"
|
||||||
|
|
||||||
|
ANSIBLE_INV="$(
|
||||||
|
echo "$VM_IP_EXPORTS" | \
|
||||||
|
sed 's/"//g' | \
|
||||||
|
sed 's/^.*=//g' | \
|
||||||
|
sed -z 's/\n/,/g;s/,$/\n/g')"
|
||||||
|
|
||||||
|
# Create an inventory file for ansible.
|
||||||
|
echo "[k8s_nodes]" > inventory
|
||||||
|
echo $VM_IP_EXPORTS | \
|
||||||
|
sed 's/"//g' | \
|
||||||
|
sed 's/export //g' | \
|
||||||
|
sed 's/ /\n/g' | \
|
||||||
|
sed 's/^\(.*\)\(=.*\)$/\1 ansible_host\2/g' \
|
||||||
|
>> inventory
|
||||||
|
|
||||||
|
echo $VM_IP_EXPORTS | sed 's/" /"\n/g'
|
||||||
|
echo export ANSIBLE_INV=$ANSIBLE_INV
|
||||||
|
|||||||
@@ -52,6 +52,36 @@ data "template_file" "ubuntu-node-user-datas" {
|
|||||||
count = 1
|
count = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data "template_file" "arch-node-user-datas" {
|
||||||
|
template = file("${path.module}/cloud_init.cfg")
|
||||||
|
vars = {
|
||||||
|
admin-passwd = "${var.root-admin-passwd}"
|
||||||
|
admin-pub-key = "${var.root-admin-pub-key}"
|
||||||
|
hostname = "${var.vm-name-prefix}-arch-${count.index}"
|
||||||
|
}
|
||||||
|
count = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
data "template_file" "centos7-node-user-datas" {
|
||||||
|
template = file("${path.module}/cloud_init.cfg")
|
||||||
|
vars = {
|
||||||
|
admin-passwd = "${var.root-admin-passwd}"
|
||||||
|
admin-pub-key = "${var.root-admin-pub-key}"
|
||||||
|
hostname = "${var.vm-name-prefix}-centos7-${count.index}"
|
||||||
|
}
|
||||||
|
count = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
data "template_file" "centos8-node-user-datas" {
|
||||||
|
template = file("${path.module}/cloud_init.cfg")
|
||||||
|
vars = {
|
||||||
|
admin-passwd = "${var.root-admin-passwd}"
|
||||||
|
admin-pub-key = "${var.root-admin-pub-key}"
|
||||||
|
hostname = "${var.vm-name-prefix}-centos8-${count.index}"
|
||||||
|
}
|
||||||
|
count = 1
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# aws
|
# aws
|
||||||
# To use the aws module, uncomment the aws modules/resources and comment out the
|
# To use the aws module, uncomment the aws modules/resources and comment out the
|
||||||
@@ -93,7 +123,7 @@ module "amzn2-nodes" {
|
|||||||
|
|
||||||
module "ubuntu-nodes" {
|
module "ubuntu-nodes" {
|
||||||
source = "./modules/aws-nodes"
|
source = "./modules/aws-nodes"
|
||||||
ami = var.base-image
|
ami = "ami-0629230e074c580f2"
|
||||||
ec2-instance-type = var.aws-ec2-instance-type
|
ec2-instance-type = var.aws-ec2-instance-type
|
||||||
subnet-id = module.aws-network.subnet.id
|
subnet-id = module.aws-network.subnet.id
|
||||||
security-group-ids = [module.aws-network.default-security-group.id]
|
security-group-ids = [module.aws-network.default-security-group.id]
|
||||||
@@ -102,6 +132,39 @@ module "ubuntu-nodes" {
|
|||||||
name-prefix = "${var.vm-name-prefix}-ubuntu"
|
name-prefix = "${var.vm-name-prefix}-ubuntu"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module "arch-nodes" {
|
||||||
|
source = "./modules/aws-nodes"
|
||||||
|
ami = "ami-02653f06de985e3ba"
|
||||||
|
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.ubuntu-node-user-datas
|
||||||
|
num-nodes = 1
|
||||||
|
name-prefix = "${var.vm-name-prefix}-arch"
|
||||||
|
}
|
||||||
|
|
||||||
|
module "centos7-nodes" {
|
||||||
|
source = "./modules/aws-nodes"
|
||||||
|
ami = "ami-00f8e2c955f7ffa9b"
|
||||||
|
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.ubuntu-node-user-datas
|
||||||
|
num-nodes = 1
|
||||||
|
name-prefix = "${var.vm-name-prefix}-centos7"
|
||||||
|
}
|
||||||
|
|
||||||
|
module "centos8-nodes" {
|
||||||
|
source = "./modules/aws-nodes"
|
||||||
|
ami = "ami-057cacbfbbb471bb3"
|
||||||
|
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.ubuntu-node-user-datas
|
||||||
|
num-nodes = 1
|
||||||
|
name-prefix = "${var.vm-name-prefix}-centos8"
|
||||||
|
}
|
||||||
|
|
||||||
# module "master-nodes" {
|
# module "master-nodes" {
|
||||||
# source = "./modules/aws-nodes"
|
# source = "./modules/aws-nodes"
|
||||||
# ami = var.base-image
|
# ami = var.base-image
|
||||||
@@ -184,6 +247,18 @@ output "ubuntu-ips" {
|
|||||||
value = module.ubuntu-nodes.ips
|
value = module.ubuntu-nodes.ips
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output "arch-ips" {
|
||||||
|
value = module.arch-nodes.ips
|
||||||
|
}
|
||||||
|
|
||||||
|
output "centos7-ips" {
|
||||||
|
value = module.centos7-nodes.ips
|
||||||
|
}
|
||||||
|
|
||||||
|
output "centos8-ips" {
|
||||||
|
value = module.centos8-nodes.ips
|
||||||
|
}
|
||||||
|
|
||||||
# TODO REM move to other file?
|
# TODO REM move to other file?
|
||||||
# output "master-ips" {
|
# output "master-ips" {
|
||||||
# value = module.master-nodes.ips
|
# value = module.master-nodes.ips
|
||||||
|
|||||||
Reference in New Issue
Block a user