Skip to content

Commit

Permalink
Improve post porocessing, add retry, timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
xorel committed Nov 6, 2023
1 parent d2d2eaa commit 6b1f7f9
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 78 deletions.
12 changes: 6 additions & 6 deletions packer/alma/alma.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ build {
expect_disconnect = true
}

post-processors {
post-processor "shell-local" {
inline = [
"virt-sysprep --add ${var.output_dir}/${var.appliance_name} --selinux-relabel --root-password disabled --hostname localhost.localdomain --run-command 'truncate -s0 -c /etc/machine-id' --delete /etc/resolv.conf",
"virt-sparsify --in-place ${var.output_dir}/${var.appliance_name}"
post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
"OUTPUT_DIR=${var.output_dir}",
"APPLIANCE_NAME=${var.appliance_name}",
]
}
scripts = [ "packer/postprocess.sh" ]
}
}
12 changes: 6 additions & 6 deletions packer/alpine/alpine.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ build {
expect_disconnect = true
}

post-processors {
post-processor "shell-local" {
inline = [
"virt-sysprep --add ${var.output_dir}/${var.appliance_name} --selinux-relabel --root-password disabled --hostname localhost.localdomain --run-command 'truncate -s0 -c /etc/machine-id' --delete /etc/resolv.conf",
"virt-sparsify --in-place ${var.output_dir}/${var.appliance_name}"
post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
"OUTPUT_DIR=${var.output_dir}",
"APPLIANCE_NAME=${var.appliance_name}",
]
}
scripts = [ "packer/postprocess.sh" ]
}
}
12 changes: 6 additions & 6 deletions packer/alt/alt.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ build {
expect_disconnect = true
}

post-processors {
post-processor "shell-local" {
inline = [
"virt-sysprep --add ${var.output_dir}/${var.appliance_name} --selinux-relabel --root-password disabled --hostname localhost.localdomain --run-command 'truncate -s0 -c /etc/machine-id' --delete /etc/resolv.conf",
"virt-sparsify --in-place ${var.output_dir}/${var.appliance_name}"
post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
"OUTPUT_DIR=${var.output_dir}",
"APPLIANCE_NAME=${var.appliance_name}",
]
}
scripts = [ "packer/postprocess.sh" ]
}
}
12 changes: 6 additions & 6 deletions packer/amazon/amazon.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ build {
expect_disconnect = true
}

post-processors {
post-processor "shell-local" {
inline = [
"virt-sysprep --add ${var.output_dir}/${var.appliance_name} --selinux-relabel --root-password disabled --hostname localhost.localdomain --run-command 'truncate -s0 -c /etc/machine-id' --delete /etc/resolv.conf",
"virt-sparsify --in-place ${var.output_dir}/${var.appliance_name}"
post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
"OUTPUT_DIR=${var.output_dir}",
"APPLIANCE_NAME=${var.appliance_name}",
]
}
scripts = [ "packer/postprocess.sh" ]
}
}
12 changes: 6 additions & 6 deletions packer/centos/centos.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ build {
expect_disconnect = true
}

post-processors {
post-processor "shell-local" {
inline = [
"virt-sysprep --add ${var.output_dir}/${var.appliance_name} --selinux-relabel --root-password disabled --hostname localhost.localdomain --run-command 'truncate -s0 -c /etc/machine-id' --delete /etc/resolv.conf",
"virt-sparsify --in-place ${var.output_dir}/${var.appliance_name}"
post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
"OUTPUT_DIR=${var.output_dir}",
"APPLIANCE_NAME=${var.appliance_name}",
]
}
scripts = [ "packer/postprocess.sh" ]
}
}
12 changes: 6 additions & 6 deletions packer/debian/debian.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ build {
expect_disconnect = true
}

post-processors {
post-processor "shell-local" {
inline = [
"virt-sysprep --add ${var.output_dir}/${var.appliance_name} --selinux-relabel --root-password disabled --hostname localhost.localdomain --run-command 'truncate -s0 -c /etc/machine-id' --delete /etc/resolv.conf",
"virt-sparsify --in-place ${var.output_dir}/${var.appliance_name}"
post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
"OUTPUT_DIR=${var.output_dir}",
"APPLIANCE_NAME=${var.appliance_name}",
]
}
scripts = [ "packer/postprocess.sh" ]
}
}
12 changes: 6 additions & 6 deletions packer/devuan/devuan.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ build {
expect_disconnect = true
}

post-processors {
post-processor "shell-local" {
inline = [
"virt-sysprep --add ${var.output_dir}/${var.appliance_name} --selinux-relabel --root-password disabled --hostname localhost.localdomain --run-command 'truncate -s0 -c /etc/machine-id' --delete /etc/resolv.conf",
"virt-sparsify --in-place ${var.output_dir}/${var.appliance_name}"
post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
"OUTPUT_DIR=${var.output_dir}",
"APPLIANCE_NAME=${var.appliance_name}",
]
}
scripts = [ "packer/postprocess.sh" ]
}
}
12 changes: 6 additions & 6 deletions packer/fedora/fedora.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ build {
expect_disconnect = true
}

post-processors {
post-processor "shell-local" {
inline = [
"virt-sysprep --add ${var.output_dir}/${var.appliance_name} --selinux-relabel --root-password disabled --hostname localhost.localdomain --run-command 'truncate -s0 -c /etc/machine-id' --delete /etc/resolv.conf",
"virt-sparsify --in-place ${var.output_dir}/${var.appliance_name}"
post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
"OUTPUT_DIR=${var.output_dir}",
"APPLIANCE_NAME=${var.appliance_name}",
]
}
scripts = [ "packer/postprocess.sh" ]
}
}
12 changes: 6 additions & 6 deletions packer/ol/ol.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ build {
expect_disconnect = true
}

post-processors {
post-processor "shell-local" {
inline = [
"virt-sysprep --add ${var.output_dir}/${var.appliance_name} --selinux-relabel --root-password disabled --hostname localhost.localdomain --run-command 'truncate -s0 -c /etc/machine-id' --delete /etc/resolv.conf",
"virt-sparsify --in-place ${var.output_dir}/${var.appliance_name}"
post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
"OUTPUT_DIR=${var.output_dir}",
"APPLIANCE_NAME=${var.appliance_name}",
]
}
scripts = [ "packer/postprocess.sh" ]
}
}
12 changes: 6 additions & 6 deletions packer/opensuse/opensuse.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ build {
expect_disconnect = true
}

post-processors {
post-processor "shell-local" {
inline = [
"virt-sysprep --add ${var.output_dir}/${var.appliance_name} --selinux-relabel --root-password disabled --hostname localhost.localdomain --run-command 'truncate -s0 -c /etc/machine-id' --delete /etc/resolv.conf",
"virt-sparsify --in-place ${var.output_dir}/${var.appliance_name}"
post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
"OUTPUT_DIR=${var.output_dir}",
"APPLIANCE_NAME=${var.appliance_name}",
]
}
scripts = [ "packer/postprocess.sh" ]
}
}
15 changes: 15 additions & 0 deletions packer/postprocess.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

timeout 5m virt-sysprep \
--add ${OUTPUT_DIR}/${APPLIANCE_NAME} \
--selinux-relabel \
--root-password disabled \
--hostname localhost.localdomain \
--run-command 'truncate -s0 -c /etc/machine-id' \
--delete /etc/resolv.conf

# virt-sparsify was haning sometimes
for I in 1 2 3; do
timeout 5m virt-sparsify \
--in-place ${OUTPUT_DIR}/${APPLIANCE_NAME} && break
done
12 changes: 6 additions & 6 deletions packer/rhel/rhel.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ build {
expect_disconnect = true
}

post-processors {
post-processor "shell-local" {
inline = [
"virt-sysprep --add ${var.output_dir}/${var.appliance_name} --selinux-relabel --root-password disabled --hostname localhost.localdomain --run-command 'truncate -s0 -c /etc/machine-id' --delete /etc/resolv.conf",
"virt-sparsify --in-place ${var.output_dir}/${var.appliance_name}"
post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
"OUTPUT_DIR=${var.output_dir}",
"APPLIANCE_NAME=${var.appliance_name}",
]
}
scripts = [ "packer/postprocess.sh" ]
}
}
12 changes: 6 additions & 6 deletions packer/rocky/rocky.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ build {
expect_disconnect = true
}

post-processors {
post-processor "shell-local" {
inline = [
"virt-sysprep --add ${var.output_dir}/${var.appliance_name} --selinux-relabel --root-password disabled --hostname localhost.localdomain --run-command 'truncate -s0 -c /etc/machine-id' --delete /etc/resolv.conf",
"virt-sparsify --in-place ${var.output_dir}/${var.appliance_name}"
post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
"OUTPUT_DIR=${var.output_dir}",
"APPLIANCE_NAME=${var.appliance_name}",
]
}
scripts = [ "packer/postprocess.sh" ]
}
}
12 changes: 6 additions & 6 deletions packer/ubuntu/ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ build {
expect_disconnect = true
}

post-processors {
post-processor "shell-local" {
inline = [
"virt-sysprep --add ${var.output_dir}/${var.appliance_name} --selinux-relabel --root-password disabled --hostname localhost.localdomain --run-command 'truncate -s0 -c /etc/machine-id' --delete /etc/resolv.conf",
"virt-sparsify --in-place ${var.output_dir}/${var.appliance_name}"
post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
"OUTPUT_DIR=${var.output_dir}",
"APPLIANCE_NAME=${var.appliance_name}",
]
}
scripts = [ "packer/postprocess.sh" ]
}
}

0 comments on commit 6b1f7f9

Please sign in to comment.