packer: Use jq to compose templates

This commit is contained in:
Michael Aldridge 2020-07-29 21:59:28 -07:00
parent dd6cd7951a
commit e9dea2d32c
7 changed files with 70 additions and 51 deletions

1
packer/.gitignore vendored
View File

@ -2,3 +2,4 @@ output_*
packer_cache
crash.log
*.box
templates/

12
packer/Makefile Normal file
View File

@ -0,0 +1,12 @@
TEMPLATES=templates/digitalocean-glibc64.json templates/vagrant-glibc64.json
all: $(TEMPLATES)
templates:
mkdir -p templates
templates/digitalocean-glibc64.json: templates fragments/base-qemu-glibc64.json fragments/provisioner-cloud.json fragments/platform-digitalocean.json
jq -s 'add' fragments/base-qemu-glibc64.json fragments/provisioner-cloud.json fragments/platform-digitalocean.json > templates/digitalocean-glibc64.json
templates/vagrant-glibc64.json: templates fragments/base-vbox-glibc64.json fragments/platform-vagrant.json
jq -s 'add' fragments/base-vbox-glibc64.json fragments/platform-vagrant.json > templates/vagrant-glibc64.json

View File

@ -22,32 +22,5 @@
"type": "qemu",
"vm_name": "DO-glibc64"
}
],
"post-processors": [
{
"image_description": "Packer import {{timestamp}}",
"image_name": "void-linux-{{user `release`}}",
"image_regions": "{{user `image_regions`}}",
"image_tags": [
"custom",
"packer"
],
"space_name": "{{user `spaces_bucket`}}",
"spaces_region": "{{user `spaces_region`}}",
"type": "digitalocean-import"
}
],
"provisioners": [
{
"execute_command": "echo 'void' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"script": "scripts/cloud.sh",
"type": "shell"
}
],
"variables": {
"image_regions": "{{env `IMAGE_REGIONS`}}",
"spaces_bucket": "{{env `SPACES_BUCKET`}}",
"spaces_region": "{{env `SPACES_REGION`}}",
"release": "{{env `RELEASE`}}"
}
]
}

View File

@ -27,27 +27,5 @@
],
"virtualbox_version_file": ".vbox_version"
}
],
"post-processors": [
[
{
"type": "vagrant"
},
{
"box_tag": "voidlinux/glibc64",
"type": "vagrant-cloud",
"version": "{{user `version`}}"
}
]
],
"provisioners": [
{
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"script": "scripts/vagrant.sh",
"type": "shell"
}
],
"variables": {
"version": "{{env `RELEASE`}}"
}
]
}

View File

@ -0,0 +1,22 @@
{
"post-processors": [
{
"image_description": "Packer import {{timestamp}}",
"image_name": "void-linux-{{user `release`}}",
"image_regions": "{{user `image_regions`}}",
"image_tags": [
"custom",
"packer"
],
"space_name": "{{user `spaces_bucket`}}",
"spaces_region": "{{user `spaces_region`}}",
"type": "digitalocean-import"
}
],
"variables": {
"image_regions": "{{env `IMAGE_REGIONS`}}",
"spaces_bucket": "{{env `SPACES_BUCKET`}}",
"spaces_region": "{{env `SPACES_REGION`}}",
"release": "{{env `RELEASE`}}"
}
}

View File

@ -0,0 +1,24 @@
{
"post-processors": [
[
{
"type": "vagrant"
},
{
"box_tag": "voidlinux/glibc64",
"type": "vagrant-cloud",
"version": "{{user `version`}}"
}
]
],
"provisioners": [
{
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"script": "scripts/vagrant.sh",
"type": "shell"
}
],
"variables": {
"version": "{{env `RELEASE`}}"
}
}

View File

@ -0,0 +1,9 @@
{
"provisioners": [
{
"execute_command": "echo 'void' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"script": "scripts/cloud.sh",
"type": "shell"
}
]
}