Skip to content

Commit e9dea2d

Browse files
committed
packer: Use jq to compose templates
1 parent dd6cd79 commit e9dea2d

File tree

7 files changed

+70
-51
lines changed

7 files changed

+70
-51
lines changed

packer/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ output_*
22
packer_cache
33
crash.log
44
*.box
5+
templates/

packer/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
TEMPLATES=templates/digitalocean-glibc64.json templates/vagrant-glibc64.json
2+
3+
all: $(TEMPLATES)
4+
5+
templates:
6+
mkdir -p templates
7+
8+
templates/digitalocean-glibc64.json: templates fragments/base-qemu-glibc64.json fragments/provisioner-cloud.json fragments/platform-digitalocean.json
9+
jq -s 'add' fragments/base-qemu-glibc64.json fragments/provisioner-cloud.json fragments/platform-digitalocean.json > templates/digitalocean-glibc64.json
10+
11+
templates/vagrant-glibc64.json: templates fragments/base-vbox-glibc64.json fragments/platform-vagrant.json
12+
jq -s 'add' fragments/base-vbox-glibc64.json fragments/platform-vagrant.json > templates/vagrant-glibc64.json

packer/templates/digitalocean-glibc64.json renamed to packer/fragments/base-qemu-glibc64.json

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,5 @@
2222
"type": "qemu",
2323
"vm_name": "DO-glibc64"
2424
}
25-
],
26-
"post-processors": [
27-
{
28-
"image_description": "Packer import {{timestamp}}",
29-
"image_name": "void-linux-{{user `release`}}",
30-
"image_regions": "{{user `image_regions`}}",
31-
"image_tags": [
32-
"custom",
33-
"packer"
34-
],
35-
"space_name": "{{user `spaces_bucket`}}",
36-
"spaces_region": "{{user `spaces_region`}}",
37-
"type": "digitalocean-import"
38-
}
39-
],
40-
"provisioners": [
41-
{
42-
"execute_command": "echo 'void' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
43-
"script": "scripts/cloud.sh",
44-
"type": "shell"
45-
}
46-
],
47-
"variables": {
48-
"image_regions": "{{env `IMAGE_REGIONS`}}",
49-
"spaces_bucket": "{{env `SPACES_BUCKET`}}",
50-
"spaces_region": "{{env `SPACES_REGION`}}",
51-
"release": "{{env `RELEASE`}}"
52-
}
25+
]
5326
}
Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,5 @@
2727
],
2828
"virtualbox_version_file": ".vbox_version"
2929
}
30-
],
31-
"post-processors": [
32-
[
33-
{
34-
"type": "vagrant"
35-
},
36-
{
37-
"box_tag": "voidlinux/glibc64",
38-
"type": "vagrant-cloud",
39-
"version": "{{user `version`}}"
40-
}
41-
]
42-
],
43-
"provisioners": [
44-
{
45-
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
46-
"script": "scripts/vagrant.sh",
47-
"type": "shell"
48-
}
49-
],
50-
"variables": {
51-
"version": "{{env `RELEASE`}}"
52-
}
30+
]
5331
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"post-processors": [
3+
{
4+
"image_description": "Packer import {{timestamp}}",
5+
"image_name": "void-linux-{{user `release`}}",
6+
"image_regions": "{{user `image_regions`}}",
7+
"image_tags": [
8+
"custom",
9+
"packer"
10+
],
11+
"space_name": "{{user `spaces_bucket`}}",
12+
"spaces_region": "{{user `spaces_region`}}",
13+
"type": "digitalocean-import"
14+
}
15+
],
16+
"variables": {
17+
"image_regions": "{{env `IMAGE_REGIONS`}}",
18+
"spaces_bucket": "{{env `SPACES_BUCKET`}}",
19+
"spaces_region": "{{env `SPACES_REGION`}}",
20+
"release": "{{env `RELEASE`}}"
21+
}
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"post-processors": [
3+
[
4+
{
5+
"type": "vagrant"
6+
},
7+
{
8+
"box_tag": "voidlinux/glibc64",
9+
"type": "vagrant-cloud",
10+
"version": "{{user `version`}}"
11+
}
12+
]
13+
],
14+
"provisioners": [
15+
{
16+
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
17+
"script": "scripts/vagrant.sh",
18+
"type": "shell"
19+
}
20+
],
21+
"variables": {
22+
"version": "{{env `RELEASE`}}"
23+
}
24+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"provisioners": [
3+
{
4+
"execute_command": "echo 'void' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
5+
"script": "scripts/cloud.sh",
6+
"type": "shell"
7+
}
8+
]
9+
}

0 commit comments

Comments
 (0)