diff --git a/CentOS-7-Minimal-Cloud-Init-virtualbox.json b/CentOS-7-Minimal-Cloud-Init-virtualbox.json index 59eff84..851caf1 100644 --- a/CentOS-7-Minimal-Cloud-Init-virtualbox.json +++ b/CentOS-7-Minimal-Cloud-Init-virtualbox.json @@ -32,7 +32,8 @@ "ssh_user_home": "/home/centos", "ssh_user_password": "centos", "ssh_user_shell": "/bin/bash", - "ssh_user_sudo": "ALL=(ALL) NOPASSWD:ALL" + "ssh_user_sudo": "ALL=(ALL) NOPASSWD:ALL", + "vagrantfile_template": "CentOS-7.Vagrantfile" }, "builders": [ { @@ -114,62 +115,46 @@ "compression_level": 9, "keep_input_artifact": true }, - [ - { - "type": "artifice", - "files": [ - "CentOS-7.Vagrantfile" - ] - }, - { - "type": "shell-local", - "execute_command": "chmod +x {{.Path}}; {{.Vars}} /bin/bash {{.Path}}", - "inline_shebang": "/bin/bash -e", - "inline": [ - "if [[ ! -d output-tmp ]]; then", - " mkdir output-tmp", - "fi", - "if [[ -n ${1} ]] && [[ -f ${1} ]]; then", - " echo '--> Generating Vagrantfile template.'", - " cp -pf ${1} output-tmp/${1}", - " sed -e 's~[{][{]user `ssh_user`[}][}]~{{user `ssh_user`}}~g' output-tmp/${1} > ${1}", - "fi" - ] - } - ], + { + "type": "shell-local", + "execute_command": "chmod +x \"{{.Script}}\"; {{.Vars}} /bin/bash \"{{.Script}}\" {{user `vagrantfile_template`}}", + "inline_shebang": "/bin/bash -e", + "inline": [ + "if [[ ! -d output-tmp ]]; then", + " mkdir output-tmp", + "fi", + "if [[ -n ${1} ]] && [[ -f ${1} ]]; then", + " echo '--> Generating Vagrantfile template.'", + " cp -pf ${1} output-tmp/${1}", + " sed -e 's~[{][{]user `ssh_user`[}][}]~{{user `ssh_user`}}~g' output-tmp/${1} > ${1}", + "fi" + ] + }, { "type": "vagrant", - "vagrantfile_template": "CentOS-7.Vagrantfile", + "vagrantfile_template": "{{user `vagrantfile_template`}}", "output": "{{user `build_output_directory`}}/{{.BuildName}}-{{.Provider}}.box", "compression_level": 9, "keep_input_artifact": true }, - [ - { - "type": "artifice", - "files": [ - "output-tmp/CentOS-7.Vagrantfile" - ] - }, - { - "type": "shell-local", - "execute_command": "chmod +x {{.Path}}; {{.Vars}} /bin/bash {{.Path}}", - "inline_shebang": "/bin/bash -e", - "inline": [ - "if [[ -n ${1} ]] && [[ -f ${1} ]]; then", - " echo '--> Restoring Vagrantfile template.'", - " mv -f ${1} .", - "fi", - "echo '--> Cleanup output directories.'", - "find . -mindepth 1 -maxdepth 1 -type d -name \"output-*\" -exec rm -rf '{}' +" - ] - } - ] + { + "type": "shell-local", + "execute_command": "chmod +x \"{{.Script}}\"; {{.Vars}} /bin/bash \"{{.Script}}\" {{user `vagrantfile_template`}}", + "inline_shebang": "/bin/bash -e", + "inline": [ + "if [[ -n ${1} ]] && [[ -f ${1} ]]; then", + " echo '--> Restoring Vagrantfile template.'", + " mv -f ${1} .", + "fi", + "echo '--> Cleanup output directories.'", + "find . -mindepth 1 -maxdepth 1 -type d -name \"output-*\" -exec rm -rf '{}' +" + ] + } ], "provisioners": [ { "type": "shell", - "execute_command": "chmod +x {{.Path}}; env {{.Vars}} /bin/bash {{.Path}}", + "execute_command": "chmod +x \"{{.Path}}\"; env {{.Vars}} /bin/bash \"{{.Path}}\"", "remote_folder": "/var/tmp", "skip_clean": false, "environment_vars": [ diff --git a/CentOS-7-Minimal-virtualbox.json b/CentOS-7-Minimal-virtualbox.json index df081c7..a3cb502 100644 --- a/CentOS-7-Minimal-virtualbox.json +++ b/CentOS-7-Minimal-virtualbox.json @@ -32,7 +32,8 @@ "ssh_user_home": "/home/vagrant", "ssh_user_password": "vagrant", "ssh_user_shell": "/bin/bash", - "ssh_user_sudo": "ALL=(ALL) NOPASSWD:ALL" + "ssh_user_sudo": "ALL=(ALL) NOPASSWD:ALL", + "vagrantfile_template": "CentOS-7.Vagrantfile" }, "builders": [ { @@ -114,62 +115,46 @@ "compression_level": 9, "keep_input_artifact": true }, - [ - { - "type": "artifice", - "files": [ - "CentOS-7.Vagrantfile" - ] - }, - { - "type": "shell-local", - "execute_command": "chmod +x {{.Path}}; {{.Vars}} /bin/bash {{.Path}}", - "inline_shebang": "/bin/bash -e", - "inline": [ - "if [[ ! -d output-tmp ]]; then", - " mkdir output-tmp", - "fi", - "if [[ -n ${1} ]] && [[ -f ${1} ]]; then", - " echo '--> Generating Vagrantfile template.'", - " cp -pf ${1} output-tmp/${1}", - " sed -e 's~[{][{]user `ssh_user`[}][}]~{{user `ssh_user`}}~g' output-tmp/${1} > ${1}", - "fi" - ] - } - ], + { + "type": "shell-local", + "execute_command": "chmod +x \"{{.Script}}\"; {{.Vars}} /bin/bash \"{{.Script}}\" {{user `vagrantfile_template`}}", + "inline_shebang": "/bin/bash -e", + "inline": [ + "if [[ ! -d output-tmp ]]; then", + " mkdir output-tmp", + "fi", + "if [[ -n ${1} ]] && [[ -f ${1} ]]; then", + " echo '--> Generating Vagrantfile template.'", + " cp -pf ${1} output-tmp/${1}", + " sed -e 's~[{][{]user `ssh_user`[}][}]~{{user `ssh_user`}}~g' output-tmp/${1} > ${1}", + "fi" + ] + }, { "type": "vagrant", - "vagrantfile_template": "CentOS-7.Vagrantfile", + "vagrantfile_template": "{{user `vagrantfile_template`}}", "output": "{{user `build_output_directory`}}/{{.BuildName}}-{{.Provider}}.box", "compression_level": 9, "keep_input_artifact": true }, - [ - { - "type": "artifice", - "files": [ - "output-tmp/CentOS-7.Vagrantfile" - ] - }, - { - "type": "shell-local", - "execute_command": "chmod +x {{.Path}}; {{.Vars}} /bin/bash {{.Path}}", - "inline_shebang": "/bin/bash -e", - "inline": [ - "if [[ -n ${1} ]] && [[ -f ${1} ]]; then", - " echo '--> Restoring Vagrantfile template.'", - " mv -f ${1} .", - "fi", - "echo '--> Cleanup output directories.'", - "find . -mindepth 1 -maxdepth 1 -type d -name \"output-*\" -exec rm -rf '{}' +" - ] - } - ] + { + "type": "shell-local", + "execute_command": "chmod +x \"{{.Script}}\"; {{.Vars}} /bin/bash \"{{.Script}}\" {{user `vagrantfile_template`}}", + "inline_shebang": "/bin/bash -e", + "inline": [ + "if [[ -n ${1} ]] && [[ -f ${1} ]]; then", + " echo '--> Restoring Vagrantfile template.'", + " mv -f ${1} .", + "fi", + "echo '--> Cleanup output directories.'", + "find . -mindepth 1 -maxdepth 1 -type d -name \"output-*\" -exec rm -rf '{}' +" + ] + } ], "provisioners": [ { "type": "shell", - "execute_command": "chmod +x {{.Path}}; env {{.Vars}} /bin/bash {{.Path}}", + "execute_command": "chmod +x \"{{.Path}}\"; env {{.Vars}} /bin/bash \"{{.Path}}\"", "remote_folder": "/var/tmp", "skip_clean": false, "environment_vars": [ diff --git a/README.md b/README.md index eb73a45..19293cf 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ The build environment required is Mac OSX or GNU Linux. To build the box file you will need the following installed: -- [VirtualBox](https://www.virtualbox.org) (5.0.26) -- [Vagrant](https://www.vagrantup.com) (1.8.4) -- [Packer](https://www.packer.io) (0.10.1) +- [VirtualBox](https://www.virtualbox.org) (5.1.22) +- [Vagrant](https://www.vagrantup.com) (1.9.5) +- [Packer](https://www.packer.io) (1.0.0) ### Build