diff --git a/get-vm-ips.sh b/get-vm-ips.sh index 7fc5178..cd319ff 100755 --- a/get-vm-ips.sh +++ b/get-vm-ips.sh @@ -84,13 +84,15 @@ for GROUP in $ANS_GROUPS; do # HOSTNAME1=0.0.0.0 # HOSTNAME2=0.0.0.0 VARS="$( - echo $DATA | \ + echo -n $DATA | \ jq '.[] | select(.group=="'"$GROUP"'") | .vms[] | "\(.hostname)=\(.ip)"' | \ sed 's/"//g' | \ sed "s/$VM_NAME_PREFIX-//g" | \ sed 's/-/_/g' )" - # Print the contents of $VARS converted to uppercase. - echo "${VARS^^}" + # Print the contents of $VARS converted to uppercase. If it's not expty. + if [ ! -z $VARS ]; then + echo "${VARS^^}" + fi done diff --git a/main.tf b/main.tf index d2127ae..3f0a9c5 100644 --- a/main.tf +++ b/main.tf @@ -4,18 +4,21 @@ locals { module.aws-network-existing.subnet-by-name["subnet_1"].id, module.aws-network-existing.subnet-by-name["subnet_3"].id, ] + nfs-subnets = [ + module.aws-network-existing.subnet-by-name["subnet_4"], + ] nodes-config = { "k8s-master" = { base-image = var.ubuntu-ami aws-ec2-type = var.t2-medium-4gib-2vcpu subnet-ids = local.k8s-subnets-ids - num = 1 + num = 0 }, "k8s-worker" = { base-image = var.ubuntu-ami aws-ec2-type = var.t2-medium-4gib-2vcpu subnet-ids = local.k8s-subnets-ids - num = 2 + num = 0 }, "ansible-test" = { base-image = var.ubuntu-ami @@ -97,8 +100,21 @@ resource "aws_key_pair" "key" { } } -# resource "aws_ebs_volume" "zfs" { -# availability_zone = +resource "aws_ebs_volume" "zfs" { + # TODO REM look at types. + availability_zone = local.nfs-subnets[0].availability_zone + size = 10 + encrypted = false + tags = { + Name = "zfs-disk" + } +} + +resource "aws_volume_attachment" "mount-nfs-volume" { + device_name = "/dev/sdf" + instance_id = module.nodes["nfs"].nodes[0].id + volume_id = aws_ebs_volume.zfs.id +} module "nodes" { for_each = local.nodes-config diff --git a/modules/aws-nodes/outputs.tf b/modules/aws-nodes/outputs.tf index ac1ae29..ba4a1cc 100644 --- a/modules/aws-nodes/outputs.tf +++ b/modules/aws-nodes/outputs.tf @@ -9,3 +9,7 @@ output "private_ips" { output "names" { value = aws_instance.nodes.*.tags.Name } + +output "nodes" { + value = aws_instance.nodes +}