E2E: switch packer build files to HCL2 (#9219)
Build configuration files need comments, and JSON is also just the worst, isn't it? Upgrade our E2E packer configs to use the new HCL2 syntax.
This commit is contained in:
parent
06c75460f3
commit
dc8e20206d
|
@ -14,13 +14,13 @@ These builds are run as-needed to update the AMIs used by the end-to-end test in
|
|||
|
||||
```sh
|
||||
$ packer --version
|
||||
1.4.4
|
||||
1.6.4
|
||||
|
||||
# build Ubuntu Bionic AMI
|
||||
$ packer build packer-ubuntu-bionic-amd64.json
|
||||
$ packer build ubuntu-bionic-amd64.pkr.hcl
|
||||
|
||||
# build Windows AMI
|
||||
$ packer build packer-windows-2016-amd64.json
|
||||
$ packer build windows-2016-amd64.pkr.hcl
|
||||
```
|
||||
|
||||
## Debugging Packer Builds
|
||||
|
@ -28,7 +28,7 @@ $ packer build packer-windows-2016-amd64.json
|
|||
You'll need the Windows administrator password in order to access Windows machines via `winrm` as Packer does. You can get this by enabling `-debug` on your Packer build.
|
||||
|
||||
```sh
|
||||
packer build -debug -on-error=abort packer-windows-2016.json
|
||||
packer build -debug -on-error=abort windows-2016-amd64.json
|
||||
...
|
||||
==> amazon-ebs: Pausing after run of step 'StepRunSourceInstance'. Press enter to continue.
|
||||
==> amazon-ebs: Waiting for auto-generated password for instance...
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "amazon-ebs",
|
||||
"region": "us-east-1",
|
||||
"source_ami_filter": {
|
||||
"filters": {
|
||||
"virtualization-type": "hvm",
|
||||
"architecture": "x86_64",
|
||||
"name": "ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*",
|
||||
"block-device-mapping.volume-type": "gp2",
|
||||
"root-device-type": "ebs"
|
||||
},
|
||||
"owners": [
|
||||
"099720109477"
|
||||
],
|
||||
"most_recent": true
|
||||
},
|
||||
"instance_type": "t2.medium",
|
||||
"ssh_username": "ubuntu",
|
||||
"iam_instance_profile": "packer_build",
|
||||
"ami_name": "nomad-e2e-ubuntu-bionic-amd64-{{timestamp}}",
|
||||
"tags": {
|
||||
"OS": "Ubuntu",
|
||||
"Version": "Bionic"
|
||||
}
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "file",
|
||||
"source": "./ubuntu-bionic-amd64",
|
||||
"destination": "/tmp/linux"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"source": "../config",
|
||||
"destination": "/tmp/config"
|
||||
},
|
||||
{
|
||||
"type": "shell-local",
|
||||
"inline": ["sleep 30"]
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"script": "./ubuntu-bionic-amd64/setup.sh"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "amazon-ebs",
|
||||
"region": "us-east-1",
|
||||
"source_ami_filter": {
|
||||
"filters": {
|
||||
"virtualization-type": "hvm",
|
||||
"name": "Windows_Server-2016-English-Full-Base-*",
|
||||
"root-device-type": "ebs"
|
||||
},
|
||||
"owners": [
|
||||
"amazon"
|
||||
],
|
||||
"most_recent": true
|
||||
},
|
||||
"instance_type": "t2.medium",
|
||||
"ami_name": "nomad-e2e-windows-2016-amd64-{{timestamp}}",
|
||||
"communicator": "winrm",
|
||||
"user_data_file": "windows-2016-amd64/setupwinrm.ps1",
|
||||
"winrm_username": "Administrator",
|
||||
"winrm_insecure": true,
|
||||
"winrm_use_ssl": true,
|
||||
"tags": {
|
||||
"OS": "Windows2016"
|
||||
}
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "powershell",
|
||||
"elevated_user": "Administrator",
|
||||
"elevated_password": "{{.WinRMPassword}}",
|
||||
"scripts": [
|
||||
"windows-2016-amd64/disable-windows-updates.ps1",
|
||||
"windows-2016-amd64/fix-tls.ps1",
|
||||
"windows-2016-amd64/install-nuget.ps1",
|
||||
"windows-2016-amd64/install-tools.ps1",
|
||||
"windows-2016-amd64/install-docker.ps1",
|
||||
"windows-2016-amd64/setup-directories.ps1",
|
||||
"windows-2016-amd64/install-openssh.ps1",
|
||||
"windows-2016-amd64/install-consul.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "windows-restart"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"source": "../config",
|
||||
"destination": "/opt"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"source": "./windows-2016-amd64/provision.ps1",
|
||||
"destination": "/opt/provision.ps1"
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"elevated_user": "Administrator",
|
||||
"elevated_password": "{{.WinRMPassword}}",
|
||||
"inline": ["/opt/provision.ps1 -nomad_version 0.12.7 -nostart"]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"inline": [
|
||||
"C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SendWindowsIsReady.ps1 -Schedule",
|
||||
"C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\InitializeInstance.ps1 -Schedule",
|
||||
"C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SysprepInstance.ps1 -NoShutdown"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
locals {
|
||||
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
|
||||
distro = "ubuntu-bionic-18.04-amd64-server-*"
|
||||
}
|
||||
|
||||
source "amazon-ebs" "latest_ubuntu_bionic" {
|
||||
ami_name = "nomad-e2e-ubuntu-bionic-amd64-${local.timestamp}"
|
||||
iam_instance_profile = "packer_build" // defined in nomad-e2e repo
|
||||
instance_type = "t2.medium"
|
||||
region = "us-east-1"
|
||||
ssh_username = "ubuntu"
|
||||
|
||||
source_ami_filter {
|
||||
filters = {
|
||||
architecture = "x86_64"
|
||||
"block-device-mapping.volume-type" = "gp2"
|
||||
name = "ubuntu/images/hvm-ssd/${local.distro}"
|
||||
root-device-type = "ebs"
|
||||
virtualization-type = "hvm"
|
||||
}
|
||||
most_recent = true
|
||||
owners = ["099720109477"] // Canonical
|
||||
}
|
||||
|
||||
tags = {
|
||||
OS = "Ubuntu"
|
||||
Version = "Bionic"
|
||||
}
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["source.amazon-ebs.latest_ubuntu_bionic"]
|
||||
|
||||
provisioner "file" {
|
||||
destination = "/tmp/linux"
|
||||
source = "./ubuntu-bionic-amd64"
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
destination = "/tmp/config"
|
||||
source = "../config"
|
||||
}
|
||||
|
||||
// cloud-init modifies the apt sources, so we need to wait
|
||||
// before running our setup
|
||||
provisioner "shell-local" {
|
||||
inline = ["sleep 30"]
|
||||
}
|
||||
|
||||
provisioner "shell" {
|
||||
script = "./ubuntu-bionic-amd64/setup.sh"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
|
||||
|
||||
source "amazon-ebs" "latest_windows_2016" {
|
||||
ami_name = "nomad-e2e-windows-2016-amd64-${local.timestamp}"
|
||||
communicator = "winrm"
|
||||
instance_type = "t2.medium"
|
||||
region = "us-east-1"
|
||||
user_data_file = "windows-2016-amd64/setupwinrm.ps1"
|
||||
winrm_insecure = true
|
||||
winrm_use_ssl = true
|
||||
winrm_username = "Administrator"
|
||||
|
||||
source_ami_filter {
|
||||
filters = {
|
||||
name = "Windows_Server-2016-English-Full-Base-*"
|
||||
root-device-type = "ebs"
|
||||
virtualization-type = "hvm"
|
||||
}
|
||||
most_recent = true
|
||||
owners = ["amazon"]
|
||||
}
|
||||
|
||||
tags = {
|
||||
OS = "Windows2016"
|
||||
}
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["source.amazon-ebs.latest_windows_2016"]
|
||||
|
||||
provisioner "powershell" {
|
||||
elevated_user = "Administrator"
|
||||
elevated_password = build.Password
|
||||
|
||||
scripts = [
|
||||
"windows-2016-amd64/disable-windows-updates.ps1",
|
||||
"windows-2016-amd64/fix-tls.ps1",
|
||||
"windows-2016-amd64/install-nuget.ps1",
|
||||
"windows-2016-amd64/install-tools.ps1",
|
||||
"windows-2016-amd64/install-docker.ps1",
|
||||
"windows-2016-amd64/setup-directories.ps1",
|
||||
"windows-2016-amd64/install-openssh.ps1",
|
||||
"windows-2016-amd64/install-consul.ps1"
|
||||
]
|
||||
}
|
||||
|
||||
provisioner "windows-restart" {}
|
||||
|
||||
provisioner "file" {
|
||||
destination = "/opt"
|
||||
source = "../config"
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
destination = "/opt/provision.ps1"
|
||||
source = "./windows-2016-amd64/provision.ps1"
|
||||
}
|
||||
|
||||
provisioner "powershell" {
|
||||
elevated_user = "Administrator"
|
||||
elevated_password = build.Password
|
||||
inline = ["/opt/provision.ps1 -nomad_version 0.12.7 -nostart"]
|
||||
}
|
||||
|
||||
provisioner "powershell" {
|
||||
inline = [
|
||||
"C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SendWindowsIsReady.ps1 -Schedule",
|
||||
"C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\InitializeInstance.ps1 -Schedule",
|
||||
"C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SysprepInstance.ps1 -NoShutdown"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue