diff options
-rw-r--r-- | scripts/Vagrantfile | 12 | ||||
-rwxr-xr-x | scripts/build-qemu-image | 2 | ||||
-rwxr-xr-x | scripts/build-vmware-image | 4 | ||||
-rw-r--r-- | scripts/packer.json | 27 |
4 files changed, 40 insertions, 5 deletions
diff --git a/scripts/Vagrantfile b/scripts/Vagrantfile new file mode 100644 index 00000000..7c89422d --- /dev/null +++ b/scripts/Vagrantfile @@ -0,0 +1,12 @@ +Vagrant.configure("2") do |config| + config.vm.synced_folder './', '/vagrant', + type: "rsync", + owner: 'vyos', + group: 'users', + mount_options: ['dmode=775,fmode=775'] + config.ssh.username = "vyos" + config.ssh.password = "vyos" + config.vm.provider :libvirt do |libvirt| + libvirt.driver = "kvm" + end +end diff --git a/scripts/build-qemu-image b/scripts/build-qemu-image index 59a42f07..29cb6cf1 100755 --- a/scripts/build-qemu-image +++ b/scripts/build-qemu-image @@ -20,7 +20,7 @@ BUILD_DIR=$(scripts/query-json build/build-config.json build_dir) BUILD_ARCH=$(scripts/query-json build/build-config.json architecture) -VERSION=$(cat $BUILD_DIR/version) +export VERSION=$(cat $BUILD_DIR/version) export ISO_IMAGE=./build/live-image-$BUILD_ARCH.hybrid.iso export ISO_MD5_SUM=$(md5sum ${ISO_IMAGE} | awk '{print $1}') diff --git a/scripts/build-vmware-image b/scripts/build-vmware-image index e665e0b5..1730d7a3 100755 --- a/scripts/build-vmware-image +++ b/scripts/build-vmware-image @@ -37,12 +37,12 @@ export PACKER_BUILD_DIR=packer_build DST_DIR=${PACKER_BUILD_DIR}/vmware mkdir -p ${DST_DIR} -# Convert raw image to VMDK +# Convert qcow2 image to VMDK source_image=${PACKER_BUILD_DIR}/qemu/vyos_qemu_image.img tmp_vmdk=${DST_DIR}/tmp.vmdk vmdk=${DST_DIR}/vyos_vmware_image.vmdk ovf=${DST_DIR}/vyos_vmware_image.ovf -qemu-img convert -f raw ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} +qemu-img convert -f qcow2 ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} vmdk-convert ${tmp_vmdk} ${vmdk} # Generate OVF diff --git a/scripts/packer.json b/scripts/packer.json index 83df10c5..39ab423b 100644 --- a/scripts/packer.json +++ b/scripts/packer.json @@ -2,7 +2,11 @@ "variables": { "iso_url": "{{env `ISO_IMAGE`}}", "iso_checksum": "{{env `ISO_MD5_SUM`}}", - "output_directory": "{{env `PACKER_BUILD_DIR`}}" + "output_directory": "{{env `PACKER_BUILD_DIR`}}", + "box_tag": "{{env `VAGRANT_BOX_NAME`}}", + "cloud_token": "{{env `VAGRANT_CLOUD_ACCESS_TOKEN`}}", + "version": "{{env `VERSION`}}", + "box_base_url": "{{env `BOX_BASE_URL`}}" }, "builders": [ @@ -15,7 +19,7 @@ "output_directory": "{{user `output_directory`}}/qemu", "shutdown_command": "sudo halt -p", "disk_size": 4096, - "format": "raw", + "format": "qcow2", "headless": true, "ssh_host_port_min": 2222, "ssh_host_port_max": 2229, @@ -90,5 +94,24 @@ "scripts/packer-scripts/vmware.sh" ] } + ], + "post-processors": [ + [ + { + "type": "vagrant", + "only": ["qemu-image"], + "vagrantfile_template": "scripts/Vagrantfile", + "output": "{{user `output_directory`}}/vagrant-libvirt/vyos_vagrant_libvirt.box", + "keep_input_artifact": "true" + }, + { + "type": "vagrant-cloud", + "only": ["qemu-image"], + "box_tag": "{{user `box_tag`}}", + "access_token": "{{user `cloud_token`}}", + "version": "{{user `version`}}", + "box_download_url": "{{user `box_base_url`}}/vyos-{{user `version`}}-vagrant-libvirt.box" + } + ] ] } |