8000 Add support for building libvirt Vagrant boxes by mattymo · Pull Request #1 · mattymo/magma · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add support for building libvirt Vagrant boxes #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions cwf/gateway/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
vb.customize ["modifyvm", :id, "--cpus", "4"]
vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
end

config.vm.provider :libvirt do |domain, override|
override.vm.synced_folder "../..", "/home/vagrant/magma", type: 'nfs', linux__nfs_options: ['rw','no_subtree_check', 'no_root_squash']
domain.uri = "qemu+unix:///system"
domain.memory = 4096
domain.cpus = 4
domain.driver = "kvm"
domain.host = "localhost"
domain.connect_via_ssh = false
domain.username = $user
domain.storage_pool_name = "default"
domain.nic_model_type = "virtio"
domain.management_network_name = "magma-mgmt-net"
domain.management_network_address = "172.17.2.0/24"
domain.nested = true
domain.cpu_mode = "host-passthrough"
domain.volume_cache = "unsafe"
domain.disk_bus = "virtio"
domain.graphics_ip = "0.0.0.0"
end

cwag.vm.provision "ansible" do |ansible|
ansible.host_key_checking = false
ansible.playbook = "deploy/cwag_dev.yml"
Expand Down
74 changes: 68 additions & 6 deletions lte/gateway/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# - debian/contrib-jessie64
# - linux kernel from debian jessie backports
# - updated vbguest-tool
magma.vm.box = "fbcmagma/magma_dev"
magma.vm.box = "magmacore/magma_dev"
magma.vm.hostname = "magma-dev"
magma.vm.box_version = "1.0.1604610159"
magma.vm.box_version = "1.1.20201124"
magma.vbguest.auto_update = false

# Create a private network, which allows host-only access to the machine
Expand All @@ -43,6 +43,27 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
vb.customize ["modifyvm", :id, "--cpus", "4"]
vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
end

config.vm.provider :libvirt do |domain, override|
override.vm.synced_folder "../..", "/home/vagrant/magma", type: 'nfs', linux__nfs_options: ['rw','no_subtree_check', 'no_root_squash']
domain.uri = "qemu+unix:///system"
domain.memory = 6144
domain.cpus = 4
domain.driver = "kvm"
domain.host = "localhost"
domain.connect_via_ssh = false
domain.username = $user
domain.storage_pool_name = "default"
domain.nic_model_type = "virtio"
domain.management_network_name = "magma-mgmt-net"
domain.management_network_address = "172.17.2.0/24"
domain.nested = true
domain.cpu_mode = "host-passthrough"
domain.volume_cache = "unsafe"
domain.disk_bus = "virtio"
domain.graphics_ip = "0.0.0.0"
end

magma.vm.provision "ansible" do |ansible|
ansible.host_key_checking = false
ansible.playbook = "deploy/magma_dev.yml"
Expand All @@ -54,9 +75,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end

config.vm.define :magma_trfserver, autostart: false do |magma_trfserver|
magma_trfserver.vm.box = "fbcmagma/magma_trfserver"
magma_trfserver.vm.box = "magmacore/magma_trfserver"
magma_trfserver.vm.hostname = "magma-trfserver"
magma_trfserver.vm.box_version = "1.0.1551294676"
magma_trfserver.vm.box_version = "1.1.20201124"
magma_trfserver.vbguest.auto_update = false

# Create a private network, which allows host-only access to the machine
Expand All @@ -73,6 +94,26 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
end

config.vm.provider :libvirt do |domain, override|
override.vm.synced_folder "../..", "/home/vagrant/magma", type: 'nfs', linux__nfs_options: ['rw','no_subtree_check', 'no_root_squash']
domain.uri = "qemu+unix:///system"
domain.memory = 6144
domain.cpus = 4
domain.driver = "kvm"
domain.host = "localhost"
domain.connect_via_ssh = false
domain.username = $user
domain.storage_pool_name = "default"
domain.nic_model_type = "virtio"
domain.management_network_name = "magma-mgmt-net"
domain.management_network_address = "172.17.2.0/24"
domain.nested = true
domain.cpu_mode = "host-passthrough"
domain.volume_cache = "unsafe"
domain.disk_bus = "virtio"
domain.graphics_ip = "0.0.0.0"
end

magma_trfserver.vm.provision "ansible" do |ansible|
ansible.host_key_checking = false
ansible.playbook = "deploy/magma_trfserver.yml"
Expand All @@ -85,9 +126,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

config.vm.define :magma_test, autostart: false do |magma_test|
# Get our prepackaged box from the atlas cloud
magma_test.vm.box = "fbcmagma/magma_test"
magma_test.vm.box = "magmacore/magma_test"
magma_test.vm.hostname = "magma-test"
magma_test.vm.box_version = "1.0.1581466527"
magma_test.vm.box_version = "1.1.20201124"
magma_test.vbguest.auto_update = false

# Create a private network, which allows host-only access to the machine
Expand All @@ -106,6 +147,26 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
end

config.vm.provider :libvirt do |domain, override|
override.vm.synced_folder "../..", "/home/vagrant/magma", type: 'nfs', linux__nfs_options: ['rw','no_subtree_check', 'no_root_squash']
domain.uri = "qemu+unix:///system"
domain.memory = 1024
domain.cpus = 1
domain.driver = "kvm"
domain.host = "localhost"
domain.connect_via_ssh = false
domain.username = $user
domain.storage_pool_name = "default"
domain.nic_model_type = "virtio"
domain.management_network_name = "magma-mgmt-net"
domain.management_network_address = "172.17.2.0/24"
domain.nested = true
domain.cpu_mode = "host-passthrough"
domain.volume_cache = "unsafe"
domain.disk_bus = "virtio"
domain.graphics_ip = "0.0.0.0"
end

magma_test.vm.provision "ansible" do |ansible|
ansible.host_key_checking = false
ansible.playbook = "deploy/magma_test.yml"
Expand Down Expand Up @@ -191,3 +252,4 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end

end

130 changes: 130 additions & 0 deletions orc8r/tools/packer/magma-dev-libvirt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"variables": {
"cloud_token": "{{ env `ATLAS_TOKEN` }}",
"version": "1.0.{{timestamp}}",
"cpus": "2",
"memory": "2048",
"disk_size": "10G",
"boot_wait": "10s"
},
"builders": [{
"type": "qemu",
"vm_name": "qemu-magma-dev",
"iso_checksum": "md5:5c583fd40360fd039b3ac98387b77dbb",
"iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/9.2.1/amd64/iso-cd/debian-9.2.1-amd64-netinst.iso",
"disk_size": "{{ user `disk_size` }}",
"headless": true,
"http_directory": ".",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
"ssh_wait_timeout": "64206s",
"format": "qcow2",
"skip_compaction": false,
"disk_compression": true,
"accelerator": "kvm",
"qemuargs": [
[ "-smp", "{{ user `cpus` }}" ],
[ "-m", "{{ user `memory` }}M" ]
],

"boot_wait": "{{ user `boot_wait` }}",
"boot_command":
[
"<esc><wait>",
"install ",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/magma-libvirt.seed <wait>",
"debian-installer=en_US ",
"auto=true ",
"locale=en_US ",
"kbd-chooser/method=us ",
"keyboard-configuration/xkb-keymap=us ",
"netcfg/get_hostname={{ .Name }} <wait>",
"netcfg/get_domain=magma.com <wait>",
"fb=false ",
"debconf/frontend=noninteractive ",
"console-setup/ask_detect=false ",
"console-keymaps-at/keymap=us ",
"<enter><wait>"
]
}],
"provisioners": [
{
"type": "shell",
"script": "scripts/provision-stretch.sh",
"execute_command": "echo 'vagrant' | sudo -S env {{.Vars}} {{.Path}}"
},{
"type": "shell",
"inline": ["sudo reboot"],
"expect_disconnect": true
},{
"type": "shell",
"script": "scripts/guest_additions.sh",
"execute_command": "echo 'vagrant' | sudo -S env {{.Vars}} {{.Path}}",
"pause_before": "10s"
}, {
"type": "shell",
"script": "scripts/vagrant_key.sh",
"execute_command": "echo 'vagrant' | sudo -S env {{.Vars}} {{.Path}}"
},
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"script": "scripts/setup.sh"
},
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"script": "scripts/ansible_debian.sh"
},
{
"type": "ansible-local",
"playbook_file": "../../../lte/gateway/deploy/magma_dev.yml",
"inventory_groups": "dev",
"role_paths": [
"../../../orc8r/tools/ansible/roles/apt_cache",
"../../../orc8r/tools/ansible/roles/distro_snapshot",
"../../../orc8r/tools/ansible/roles/docker",
"../../../orc8r/tools/ansible/roles/fluent_bit",
"../../../orc8r/tools/ansible/roles/gateway_dev",
"../../../orc8r/tools/ansible/roles/gateway_services",
"../../../orc8r/tools/ansible/roles/golang",
"../../../orc8r/tools/ansible/roles/pkgrepo",
"../../../orc8r/tools/ansible/roles/python_dev",
"../../../orc8r/tools/ansible/roles/resolv_conf",
"../../../orc8r/tools/ansible/roles/test_certs",
"../../../lte/gateway/deploy/roles/stretch_snapshot",
"../../../lte/gateway/deploy/roles/envoy",
"../../../lte/gateway/deploy/roles/magma",
"../../../lte/gateway/deploy/roles/dev_common",
"../../../lte/gateway/deploy/roles 9E7A /magma",
"../../../lte/gateway/deploy/roles/magma_test",
"../../../lte/gateway/deploy/roles/ovs_build",
"../../../lte/gateway/deploy/roles/ovs_deploy",
"../../../lte/gateway/deploy/roles/ovs_prepare",
"../../../lte/gateway/deploy/roles/pyvenv",
"../../../lte/gateway/deploy/roles/stretch_snapshot",
"../../../lte/gateway/deploy/roles/trfserver",
"../../../lte/gateway/deploy/roles/uselocalpkgrepo"
],
"extra_arguments": [
"--extra-vars '{\"ansible_user\": \"vagrant\", \"preburn\": true, \"full_provision\": false}'"
]
}
],
"post-processors": [
[
{
"output": "builds/magma_dev_{{.Provider}}.box",
"type": "vagrant"
},
{
"type": "vagrant-cloud",
"box_tag": "magmacore/magma_dev",
"access_token": "{{user `cloud_token`}}",
"version": "{{user `version`}}"
}

]
]
}
2 changes: 1 addition & 1 deletion orc8r/tools/packer/magma-dev-virtualbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
},
{
"type": "vagrant-cloud",
"box_tag": "fbcmagma/magma_dev",
"box_tag": "magmacore/magma_dev",
"access_token": "{{user `cloud_token`}}",
"version": "{{user `version`}}"
}
Expand Down
88 changes: 88 additions & 0 deletions orc8r/tools/packer/magma-libvirt.seed
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
################################################################################
# Copyright 2020 The Magma Authors.

# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

d-i debian-installer/language string en
d-i debian-installer/country string US
d-i debian-installer/locale string en_US.UTF-8
d-i keyboard-configuration/xkb-keymap select us
d-i keymap select us

d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string vagrant
d-i netcfg/get_domain string vagrant

# load non-free firmware
d-i hw-detect/load_firmware boolean true

# use the US debian mirror
d-i mirror/country string us
d-i mirror/http/hostname string http.us.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string

# disable Predictable Network Interface Names (not supported in Vagrant 1.8.1).
d-i debian-installer/add-kernel-opts string net.ifnames=0
d-i preseed/late_command string \
echo "vagrant ALL=(ALL) NOPASSWD:ALL" >> /target/etc/sudoers; \
echo "Defaults:vagrant !requiretty" >> /target/etc/sudoers; \
echo "auto eth0" >> /target/etc/network/interfaces; \
echo "iface eth0 inet dhcp" >> /target/etc/network/interfaces; \
for i in 1 2 3; do \
echo "auto eth$i" >> /target/etc/network/interfaces; \
echo "iface eth$i inet manual" >> /target/etc/network/interfaces; \
done

# no root user -- use sudo instead
d-i passwd/root-login boolean false

# create a user
d-i passwd/user-fullname string vagrant
d-i passwd/username string vagrant
d-i passwd/user-password password vagrant
d-i passwd/user-password-again password vagrant

# utc all day
d-i clock-setup/utc boolean true
d-i time/zone string UTC
d-i clock-setup/ntp boolean true

d-i partman-auto/disk string /dev/vda
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select atomic
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

# always install to the mbr
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i grub-installer/bootdev string /dev/vda

# install base system
tasksel tasksel/first multiselect standard, ssh-server

# Don't scan other dvd
apt-cdrom-setup apt-setup/cdrom/set-first boolean false
apt-mirror-setup apt-setup/use_mirror boolean true

# Don't send our data
popularity-contest popularity-contest/participate boolean false

# acknowledge complete message
d-i finish-install/reboot_in_progress note

# Prevent packaged version of VirtualBox Guest Additions being installed:
d-i preseed/early_command string sed -i \
'/in-target/idiscover(){/sbin/discover|grep -v VirtualBox;}' \
/usr/lib/pre-pkgsel.d/20install-hwpackages
Loading
0