fix: [deploy] There was an issue with parallel build, fixed

fix: [json] The Packer variable is now set correctly
pull/23/head
Steve Clement 2019-05-10 07:14:15 +02:00
parent 0385720105
commit e2730fd9fb
2 changed files with 11 additions and 6 deletions

View File

@ -155,6 +155,7 @@ removeAll () {
rm packer_virtualbox-iso_virtualbox-iso_sha*.checksum.asc rm packer_virtualbox-iso_virtualbox-iso_sha*.checksum.asc
rm ${PACKER_VM}_${VER}@${LATEST_COMMIT}-vmware.zip.asc rm ${PACKER_VM}_${VER}@${LATEST_COMMIT}-vmware.zip.asc
rm /tmp/LICENSE-${PACKER_NAME} rm /tmp/LICENSE-${PACKER_NAME}
rm /tmp/vbox.done /tmp/vmware.done
} }
# TODO: Make it more graceful if files do not exist # TODO: Make it more graceful if files do not exist
@ -181,16 +182,15 @@ if [[ "${LATEST_COMMIT}" != "$(cat /tmp/${PACKER_NAME}-latest.sha)" ]]; then
# Build virtualbox VM set # Build virtualbox VM set
PACKER_LOG_PATH="${PWD}/packerlog-vbox.txt" PACKER_LOG_PATH="${PWD}/packerlog-vbox.txt"
($PACKER_RUN build --on-error=ask -only=virtualbox-iso misp-deploy.json ; VIRTUALBOX_BUILD=$? ; touch /tmp/vbox.done) & ($PACKER_RUN build --on-error=cleanup -only=virtualbox-iso misp-deploy.json ; VIRTUALBOX_BUILD=$? ; touch /tmp/vbox.done) &
# Build vmware VM set # Build vmware VM set
PACKER_LOG_PATH="${PWD}/packerlog-vmware.txt" PACKER_LOG_PATH="${PWD}/packerlog-vmware.txt"
($PACKER_RUN build --on-error=ask -only=vmware-iso misp-deploy.json ; VMWARE_BUILD=$? ; touch /tmp/vmware.done) & ($PACKER_RUN build --on-error=cleanup -only=vmware-iso misp-deploy.json ; VMWARE_BUILD=$? ; touch /tmp/vmware.done) &
# The below waits for the above 2 parallel packer builds to finish # The below waits for the above 2 parallel packer builds to finish
while [[ ! -f /tmp/vbox.done ]] && [[ ! -f /tmp/vmware.done ]]; do while [[ ! -f /tmp/vmware.done ]]; do :; done
: while [[ ! -f /tmp/vbox.done ]]; do :; done
done
# Prevent uploading only half a build # Prevent uploading only half a build
if [[ "$VMWARE_BUILD" == "0" ]] && [[ "$VIRTUALBOX_BUILD" == "0" ]]; then if [[ "$VMWARE_BUILD" == "0" ]] && [[ "$VIRTUALBOX_BUILD" == "0" ]]; then
@ -241,6 +241,7 @@ if [[ "${LATEST_COMMIT}" != "$(cat /tmp/${PACKER_NAME}-latest.sha)" ]]; then
else else
echo "The packer exit code of VMware was: ${VMWARE_BUILD}" echo "The packer exit code of VMware was: ${VMWARE_BUILD}"
echo "The packer exit code of VBox was: ${VIRTUALBOX_BUILD}" echo "The packer exit code of VBox was: ${VIRTUALBOX_BUILD}"
echo "--------------------------------------------------------------------------------"
echo "#fail" > /tmp/${PACKER_NAME}-latest.sha echo "#fail" > /tmp/${PACKER_NAME}-latest.sha
removeAll 2> /dev/null removeAll 2> /dev/null
TIME_END=$(date +%s) TIME_END=$(date +%s)

View File

@ -91,6 +91,7 @@
"passwd/user-password={{ user `ssh_password` }} ", "passwd/user-password={{ user `ssh_password` }} ",
"passwd/user-password-again={{ user `ssh_password` }} ", "passwd/user-password-again={{ user `ssh_password` }} ",
"passwd/username={{ user `ssh_username` }} ", "passwd/username={{ user `ssh_username` }} ",
"debconf/frontend=noninteractive ",
"-- <enter>" "-- <enter>"
] ]
}, },
@ -137,7 +138,6 @@
"environment_vars": [ "environment_vars": [
"DESKTOP={{user `desktop`}}", "DESKTOP={{user `desktop`}}",
"UPDATE={{user `update`}}", "UPDATE={{user `update`}}",
"PACKER=1",
"http_proxy={{user `http_proxy`}}", "http_proxy={{user `http_proxy`}}",
"https_proxy={{user `https_proxy`}}", "https_proxy={{user `https_proxy`}}",
"no_proxy={{user `no_proxy`}}" "no_proxy={{user `no_proxy`}}"
@ -165,6 +165,10 @@
}, },
{ {
"type": "shell", "type": "shell",
"environment_vars": [
"PACKER=1",
"DEBIAN_FRONTEND=noninteractive"
],
"execute_command": "echo '{{user `ssh_pass`}}' | {{ .Vars }} sudo -u {{user `ssh_name`}} -E -S bash '{{ .Path }}'", "execute_command": "echo '{{user `ssh_pass`}}' | {{ .Vars }} sudo -u {{user `ssh_name`}} -E -S bash '{{ .Path }}'",
"inline": [ "inline": [
"chmod u+x /tmp/INSTALL.sh", "chmod u+x /tmp/INSTALL.sh",