mirror of
https://github.com/vyos/vyos-build.git
synced 2025-10-01 20:28:40 +02:00
Add vagrant-libvirt make target
This commit is contained in:
parent
795546f923
commit
822747f4de
7
Makefile
7
Makefile
@ -46,6 +46,13 @@ qemu:
|
||||
@scripts/check-vm-build-env
|
||||
@scripts/build-qemu-image
|
||||
|
||||
.PHONY: vagrant-libvirt
|
||||
.ONESHELL:
|
||||
vagrant-libvirt:
|
||||
@set -e
|
||||
@scripts/check-vm-build-env
|
||||
@scripts/build-vagrant-libvirt-box
|
||||
|
||||
.PHONY: vmware
|
||||
.ONESHELL:
|
||||
vmware:
|
||||
|
||||
69
scripts/build-vagrant-libvirt-box
Executable file
69
scripts/build-vagrant-libvirt-box
Executable file
@ -0,0 +1,69 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2016 VyOS maintainers and contributors
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 or later as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# File: build-vagrant-libvirt-box
|
||||
# Purpose:
|
||||
# Build VyOS Vagrant libvirt box.
|
||||
|
||||
export PACKER_BUILD_DIR=packer_build
|
||||
|
||||
DST_DIR=${PACKER_BUILD_DIR}/vagrant-libvirt
|
||||
BOX_DIR=${DST_DIR}/box
|
||||
mkdir -p ${BOX_DIR}
|
||||
|
||||
# Copy qcow2 image
|
||||
cp -p packer_build/qemu/vyos_qemu_image.img ${BOX_DIR}/box.img
|
||||
|
||||
# Put metadata.json and Vagrantfile
|
||||
echo '{"format":"qcow2","provider":"libvirt","virtual_size":4}' > ${BOX_DIR}/metadata.json
|
||||
cat <<EOF > ${BOX_DIR}/Vagrantfile
|
||||
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
|
||||
EOF
|
||||
|
||||
# Create box
|
||||
box=${DST_DIR}/vyos_vagrant_libvirt.box
|
||||
tar -C ${BOX_DIR} -czvf ${box} metadata.json Vagrantfile box.img
|
||||
if [ "$?" = "0" ]; then
|
||||
echo "Vagrant libvirt box successfully created to ./${box}"
|
||||
fi
|
||||
|
||||
PROVIDER=libvirt
|
||||
|
||||
# Create version
|
||||
curl -XPOST -d "version[version]=${VERSION}" \
|
||||
https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/versions?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN}
|
||||
echo
|
||||
|
||||
# Create provider
|
||||
curl -XPOST -d "provider[name]=${PROVIDER}" -d "provider[url]=${VAGRANT_BOX_BASE_URL}" \
|
||||
https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/version/${VERSION}/providers?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN}
|
||||
echo
|
||||
|
||||
# Release version
|
||||
curl -XPUT \
|
||||
https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/version/${VERSION}/release?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN}
|
||||
echo
|
||||
@ -2,11 +2,7 @@
|
||||
"variables": {
|
||||
"iso_url": "{{env `ISO_IMAGE`}}",
|
||||
"iso_checksum": "{{env `ISO_MD5_SUM`}}",
|
||||
"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`}}"
|
||||
"output_directory": "{{env `PACKER_BUILD_DIR`}}"
|
||||
},
|
||||
"builders":
|
||||
[
|
||||
@ -61,57 +57,6 @@
|
||||
"save<enter><wait5>",
|
||||
"exit<enter><wait5>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "vmware-image",
|
||||
"type": "qemu",
|
||||
"iso_url": "{{user `output_directory`}}/qemu/vyos_qemu_image.img",
|
||||
"iso_checksum_type": "none",
|
||||
"output_directory": "{{user `output_directory`}}/vmware",
|
||||
"shutdown_command": "sudo halt -p",
|
||||
"disk_image": true,
|
||||
"disk_size": 4096,
|
||||
"format": "raw",
|
||||
"headless": true,
|
||||
"accelerator": "tcg",
|
||||
"ssh_host_port_min": 2222,
|
||||
"ssh_host_port_max": 2229,
|
||||
"ssh_username": "vyos",
|
||||
"ssh_password": "vyos",
|
||||
"ssh_port": 22,
|
||||
"ssh_wait_timeout": "300s",
|
||||
"vm_name": "vyos_vmware_image.img",
|
||||
"net_device": "virtio-net",
|
||||
"disk_interface": "virtio",
|
||||
"boot_wait": "5s"
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "shell",
|
||||
"only": ["vmware-image"],
|
||||
"scripts": [
|
||||
"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"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user