diff --git a/Vagrantfile b/Vagrantfile index 61aebcf..8f7fa80 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -73,7 +73,7 @@ Vagrant.configure(2) do |config| "--audio-driver", "none", "--cpus", guest['cpus'], "--memory", guest['memory'], - "--natnet1", "192.168.33.0/24", + "--natnet1", "192.168.33.0/24", "--graphicscontroller", "VMSVGA", "--vram", "64" ] diff --git a/files/cleanup.sh b/files/cleanup.sh new file mode 100755 index 0000000..5400392 --- /dev/null +++ b/files/cleanup.sh @@ -0,0 +1,7 @@ +#!/bin/bash -x + +# minimize disk usage +echo 'Clean up yum cache' +yum clean all +echo "Remove temporary files used to build box" +rm -rf /tmp/packer-provisioner-ansible-local /var/tmp/dnf-packer-* diff --git a/vagrant.sh b/files/vagrant.sh old mode 100644 new mode 100755 similarity index 100% rename from vagrant.sh rename to files/vagrant.sh diff --git a/vmtools.sh b/files/vmtools.sh old mode 100644 new mode 100755 similarity index 100% rename from vmtools.sh rename to files/vmtools.sh diff --git a/packer.pkr.hcl b/packer.pkr.hcl index 2cc5b87..89c9cc0 100644 --- a/packer.pkr.hcl +++ b/packer.pkr.hcl @@ -224,12 +224,12 @@ build { provisioner "shell" { except = ["azure-arm.controller"] execute_command = "bash '{{ .Path }}'" - script = "vagrant.sh" + script = "files/vagrant.sh" } provisioner "shell" { except = ["azure-arm.controller"] execute_command = "bash '{{ .Path }}'" - script = "vmtools.sh" + script = "files/vmtools.sh" } provisioner "shell" { execute_command = "echo 'vagrant' | {{ .Vars }} sudo -S -E bash '{{ .Path }}'" @@ -243,6 +243,15 @@ build { only = ["azure-arm"] } + provisioner "shell" { + execute_command = "bash '{{ .Path }}'" + script = "files/cleanup.sh" + } + + provisioner "shell" { + execute_command = "echo 'vagrant' | {{ .Vars }} sudo -S -E bash '{{ .Path }}'" + scripts = ["controller.sh"] + } post-processors { post-processor "vagrant" { except = ["azure-arm.controller"]