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

Acceptance test simplification and related changes #1381

Merged
merged 6 commits into from
Apr 12, 2021
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ website/node_modules
*~
.*.swp
.idea
.vscode
*.iml
*.test
*.iml
Expand Down
65 changes: 65 additions & 0 deletions scripts/packet/devrc.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
export TF_VAR_VCSA_DEPLOY_PATH="/tmp/vcsa/vcsa-cli-installer/mac/vcsa-deploy"
export TF_VAR_PRIV_KEY='<your ssh key>'
export TF_VAR_VSPHERE_REST_SESSION_PATH=$HOME/.govmomi/rest_sessions
export TF_VAR_VSPHERE_VIM_SESSION_PATH=$HOME/.govmomi/sessions
export TF_VAR_VSPHERE_LICENSE=00000-00000-00000-00000-00000
export TF_VAR_PACKET_PROJECT=00000000-0000-0000-0000-000000000000
export TF_VAR_PACKET_AUTH=00000000000000000000000000000000
#export TF_VAR_ESXI_VERSION="vmware_esxi_7_0"
export TF_VAR_ESXI_VERSION="vmware_esxi_6_7"

export TF_VAR_VSPHERE_NAS_HOST=${nas_host}
export TF_VAR_VSPHERE_ESXI1=${esxi_host_1}
export TF_VAR_VSPHERE_ESXI2=${esxi_host_2}
export VSPHERE_SERVER=${vsphere_host}

export TF_VAR_VSPHERE_VMFS_REGEXP='naa.6000c29[2b]'
export TF_VAR_VSPHERE_DS_VMFS_ESXI1_DISK0="naa.6000c29b4b217432a854822b1bc40502"
export TF_VAR_VSPHERE_DS_VMFS_ESXI1_DISK1="naa.6000c29f3dbf773c6c25cb830dfc201b"

export VSPHERE_USER="administrator@vcenter.vspheretest.internal"
export VSPHERE_PASSWORD="Password123!"
export VSPHERE_ALLOW_UNVERIFIED_SSL=true

export TF_VAR_VSPHERE_SERVER=$VSPHERE_SERVER
export TF_VAR_VSPHERE_USER=$VSPHERE_USER
export TF_VAR_VSPHERE_PASSWORD=$VSPHERE_PASSWORD
export TF_VAR_VSPHERE_ALLOW_UNVERIFIED_SSL=$VSPHERE_ALLOW_UNVERIFIED_SSL
export TF_VAR_VSPHERE_ESXI_TRUNK_NIC=vmnic1
export TF_VAR_VSPHERE_DATACENTER=hashidc
export TF_VAR_VSPHERE_CLUSTER=c1
export TF_VAR_VSPHERE_NFS_DS_NAME=nfs
export TF_VAR_VSPHERE_NFS_DS_NAME1=nfs-vol1
export TF_VAR_VSPHERE_NFS_DS_NAME2=nfs-vol2
export TF_VAR_VSPHERE_DVS_NAME=terraform-test-dvs
export TF_VAR_VSPHERE_PG_NAME='vmnet'
export TF_VAR_VSPHERE_RESOURCE_POOL=hashi-resource-pool
export TF_VAR_VSPHERE_NFS_PATH=/nfs
export TF_VAR_VSPHERE_NFS_PATH1=/nfs/ds1
export TF_VAR_VSPHERE_NFS_PATH2=/nfs/ds2
export TF_VAR_VSPHERE_ISO_DATASTORE=nfs
export TF_VAR_VSPHERE_ISO_FILE=fake.iso
export TF_VAR_REMOTE_OVA_URL="https://storage.googleapis.com/acctest-images/tfvsphere_template.ova"
export TF_VAR_VSPHERE_TEMPLATE=tfvsphere_template
export TF_VAR_VSPHERE_INIT_TYPE=thin
export TF_VAR_VSPHERE_ADAPTER_TYPE=lsiLogic
export TF_VAR_VSPHERE_DC_FOLDER=dc-folder
export TF_VAR_VSPHERE_DS_FOLDER=ds
export TF_VAR_VSPHERE_USE_LINKED_CLONE=true
export TF_VAR_VSPHERE_PERSIST_SESSION=true
export TF_VAR_VSPHERE_CLONED_VM_DISK_SIZE=20
export TF_VAR_VSPHERE_TEST_OVA="https://storage.googleapis.com/acctest-images/yVM.ova"
export TF_VAR_VSPHERE_TEST_OVF="https://storage.googleapis.com/acctest-images/yVM.ovf"
export TF_VAR_VSPHERE_CONTENT_LIBRARY_FILES="https://storage.googleapis.com/acctest-images/yVM.ovf"
export TF_VAR_REMOTE_OVF_URL=https://acctest-images.storage.googleapis.com/tfvsphere_template.ovf

export TF_VAR_VSPHERE_HOST_NIC0=vmnic0
export TF_VAR_VSPHERE_HOST_NIC1=vmnic1


export TF_VAR_VSPHERE_VSWITCH_UPPER_VERSION="7.0.0"
export TF_VAR_VSPHERE_VSWITCH_LOWER_VERSION="6.5.0"
export TF_VAR_VSPHERE_DS_VMFS_NAME='ds-001'
export TF_VAR_VSPHERE_VM_V1_PATH='pxe-server'
export TF_VAR_VSPHERE_FOLDER_V0_PATH='Discovered virtual machine'
export TF_VAR_VSPHERE_ENTITY_PERMISSION_USER_GROUP="root"
85 changes: 69 additions & 16 deletions scripts/packet/main.tf.phase1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ variable "PACKET_PROJECT" {}

variable "PRIV_KEY" {}

variable "VCSA_DEPLOY_PATH" {}

variable "ESXI_VERSION" {
default = "vmware_esxi_6_7"
}

variable "PACKET_FACILITY" {
default = "sjc1"
}

variable ESXI_PLAN {
default = "c3.medium.x86"
}

variable STORAGE_PLAN {
default = "c1.small.x86"
}

variable LAB_PREFIX {
default = ""
}

provider "packet" {
auth_token = var.PACKET_AUTH
}
Expand All @@ -46,10 +68,10 @@ provider "vsphere" {
}

resource "packet_device" "esxi1" {
hostname = "esxi1.vspheretest.internal"
plan = "c3.medium.x86"
facilities = ["sjc1"]
operating_system = "vmware_esxi_6_7"
hostname = "${var.LAB_PREFIX}esxi1.vspheretest.internal"
plan = var.ESXI_PLAN
facilities = [var.PACKET_FACILITY]
operating_system = var.ESXI_VERSION
billing_cycle = "hourly"
project_id = local.project_id
}
Expand All @@ -60,10 +82,10 @@ resource "packet_device_network_type" "esxi1" {
}

resource "packet_device" "esxi2" {
hostname = "esxi2.vspheretest.internal"
plan = "c3.medium.x86"
facilities = ["sjc1"]
operating_system = "vmware_esxi_6_7"
hostname = "${var.LAB_PREFIX}esxi2.vspheretest.internal"
plan = var.ESXI_PLAN
facilities = [var.PACKET_FACILITY]
operating_system = var.ESXI_VERSION
billing_cycle = "hourly"
project_id = local.project_id
}
Expand All @@ -74,36 +96,56 @@ resource "packet_device_network_type" "esxi2" {
}

resource "packet_device" "storage1" {
hostname = "storage1.vspheretest.internal"
plan = "c1.small.x86"
facilities = ["sjc1"]
hostname = "${var.LAB_PREFIX}storage1.vspheretest.internal"
plan = var.STORAGE_PLAN
facilities = [var.PACKET_FACILITY]
operating_system = "ubuntu_20_04"
billing_cycle = "hourly"
project_id = local.project_id
provisioner "remote-exec" {
inline = [
"mkdir /nfs",
"mkdir -p /nfs/ds1 /nfs/ds2 /nfs/ds2 /nfs/ds3",
"apt-get update",
"apt-get install nfs-common nfs-kernel-server -y",
"echo \"/nfs *(rw,no_root_squash)\" > /etc/exports",
"echo \"/nfs/ds1 *(rw,no_root_squash)\" >> /etc/exports",
"echo \"/nfs/ds2 *(rw,no_root_squash)\" >> /etc/exports",
"echo \"/nfs/ds3 *(rw,no_root_squash)\" >> /etc/exports",
"exportfs -a",
]
connection {
host = packet_device.storage1.network.0.address
private_key = var.PRIV_KEY
private_key = file(var.PRIV_KEY)
}
}
}

resource "packet_vlan" "vmvlan" {
facility = var.PACKET_FACILITY
project_id = local.project_id
}

resource "packet_port_vlan_attachment" "vmvlan_esxi1" {
device_id = packet_device.esxi1.id
port_name = "eth1"
vlan_vnid = packet_vlan.vmvlan.vxlan
}

resource "packet_port_vlan_attachment" "vmvlan_esxi2" {
device_id = packet_device.esxi2.id
port_name = "eth1"
vlan_vnid = packet_vlan.vmvlan.vxlan
}

data "packet_precreated_ip_block" "private" {
facility = "sjc1"
facility = var.PACKET_FACILITY
project_id = local.project_id
address_family = 4
public = false
}

data "packet_precreated_ip_block" "public" {
facility = "sjc1"
facility = var.PACKET_FACILITY
project_id = local.project_id
address_family = 4
public = true
Expand Down Expand Up @@ -137,10 +179,21 @@ resource "local_file" "vcsa_template" {
})
filename = "./tmp/vcsa.json"
provisioner "local-exec" {
command = "sleep 290; echo five more; sleep 290; TERM=xterm-256color ./tmp/mnt/vcsa-cli-installer/lin64/vcsa-deploy install --accept-eula --acknowledge-ceip --no-ssl-certificate-verification --verbose --skip-ovftool-verification ./tmp/vcsa.json"
command = "sleep 290; echo five more; sleep 290; TERM=xterm-256color ${var.VCSA_DEPLOY_PATH} install --accept-eula --acknowledge-ceip --no-ssl-certificate-verification --verbose --skip-ovftool-verification $(pwd)/tmp/vcsa.json"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall the sleep 290; echo five more as unnecessary when i set things up... but my memory is hazy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sometimes the server is not immediately available, which is why this long sleep was added.

}
}

output "ip" {
value = cidrhost("${packet_device.esxi1.network.0.address}/${packet_device.esxi1.network.0.cidr}",3)
}

resource "local_file" "devrc" {
sensitive_content = templatefile("${path.cwd}/devrc.tpl", {
nas_host = packet_device.storage1.network.0.address
esxi_host_1 = packet_device.esxi1.network.0.address
esxi_host_2 = packet_device.esxi2.network.0.address
vsphere_host = cidrhost("${packet_device.esxi1.network.0.address}/${packet_device.esxi1.network.0.cidr}",3)

})
filename = "./devrc"
}
83 changes: 71 additions & 12 deletions scripts/packet/main.tf.phase2
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ variable "PACKET_PROJECT" {}

variable "PRIV_KEY" {}

variable "ESXI_VERSION" {
default = "vmware_esxi_6_7"
}
variable "PACKET_FACILITY" {
default = "sjc1"
}

variable ESXI_PLAN {
default = "c3.medium.x86"
}

variable STORAGE_PLAN {
default = "c1.small.x86"
}

provider "packet" {
auth_token = var.PACKET_AUTH
}
Expand All @@ -53,9 +68,9 @@ data "packet_device" "esxi1" {

resource "packet_device" "esxi1" {
hostname = "esxi1.vspheretest.internal"
plan = "c3.medium.x86"
facilities = ["sjc1"]
operating_system = "vmware_esxi_6_7"
plan = var.ESXI_PLAN
facilities = [var.PACKET_FACILITY]
operating_system = var.ESXI_VERSION
billing_cycle = "hourly"
project_id = local.project_id
}
Expand All @@ -67,9 +82,9 @@ resource "packet_device_network_type" "esxi1" {

resource "packet_device" "esxi2" {
hostname = "esxi2.vspheretest.internal"
plan = "c3.medium.x86"
facilities = ["sjc1"]
operating_system = "vmware_esxi_6_7"
plan = var.ESXI_PLAN
facilities = [var.PACKET_FACILITY]
operating_system = var.ESXI_VERSION
billing_cycle = "hourly"
project_id = local.project_id
}
Expand All @@ -81,35 +96,55 @@ resource "packet_device_network_type" "esxi2" {

resource "packet_device" "storage1" {
hostname = "storage1.vspheretest.internal"
plan = "c1.small.x86"
facilities = ["sjc1"]
plan = var.STORAGE_PLAN
facilities = [var.PACKET_FACILITY]
operating_system = "ubuntu_20_04"
billing_cycle = "hourly"
project_id = local.project_id
provisioner "remote-exec" {
inline = [
"mkdir /nfs",
"mkdir -p /nfs/ds1 /nfs/ds2 /nfs/ds2 /nfs/ds3",
"apt-get update",
"apt-get install nfs-common nfs-kernel-server -y",
"echo \"/nfs *(rw,no_root_squash)\" > /etc/exports",
"echo \"/nfs/ds1 *(rw,no_root_squash)\" >> /etc/exports",
"echo \"/nfs/ds2 *(rw,no_root_squash)\" >> /etc/exports",
"echo \"/nfs/ds3 *(rw,no_root_squash)\" >> /etc/exports",
"exportfs -a",
]
connection {
host = packet_device.storage1.network.0.address
private_key = var.PRIV_KEY
private_key = file(var.PRIV_KEY)
}
}
}

resource "packet_vlan" "vmvlan" {
facility = var.PACKET_FACILITY
project_id = local.project_id
}

resource "packet_port_vlan_attachment" "vmvlan_esxi1" {
device_id = packet_device.esxi1.id
port_name = "eth1"
vlan_vnid = packet_vlan.vmvlan.vxlan
}

resource "packet_port_vlan_attachment" "vmvlan_esxi2" {
device_id = packet_device.esxi2.id
port_name = "eth1"
vlan_vnid = packet_vlan.vmvlan.vxlan
}

data "packet_precreated_ip_block" "private" {
facility = "sjc1"
facility = var.PACKET_FACILITY
project_id = local.project_id
address_family = 4
public = false
}

data "packet_precreated_ip_block" "public" {
facility = "sjc1"
facility = var.PACKET_FACILITY
project_id = local.project_id
address_family = 4
public = true
Expand Down Expand Up @@ -201,3 +236,27 @@ resource "vsphere_host" "host2" {
cluster = vsphere_compute_cluster.compute_cluster.id
thumbprint = data.vsphere_host_thumbprint.esxi2.id
}

resource "local_file" "devrc" {
sensitive_content = templatefile("${path.cwd}/devrc.tpl", {
nas_host = packet_device.storage1.network.0.address
esxi_host_1 = packet_device.esxi1.network.0.address
esxi_host_2 = packet_device.esxi2.network.0.address
vsphere_host = cidrhost("${packet_device.esxi1.network.0.address}/${packet_device.esxi1.network.0.cidr}",3)

})
filename = "./devrc"
}

resource "vsphere_content_library" "nested-library" {
name = "nested esxi content library"
storage_backing = [vsphere_nas_datastore.ds.id]
description = "https://www.virtuallyghetto.com/2015/04/subscribe-to-vghetto-nested-esxi-template-content-library-in-vsphere-6-0.html"
}

resource "vsphere_content_library_item" "n-esxi" {
name = "nested esxi vm"
description = "nested esxi template"
library_id = vsphere_content_library.nested-library.id
file_url = "https://s3-us-west-1.amazonaws.com/vghetto-content-library/Nested-ESXi-VM-Template/Nested-ESXi-VM-Template.ovf"
}
Loading