gpt4 book ai didi

continuous-integration - 在云 CI 服务上使用 Vagrant

转载 作者:行者123 更新时间:2023-12-03 23:56:44 25 4
gpt4 key购买 nike

是否有任何云 CI 服务允许 Vagrant VM 使用 VirtualBox 作为提供者运行?

早期的调查表明,这对于 Travis CI 或 Circle CI 似乎是不可能的,尽管 vagrant-aws 插件允许使用 AWS 服务器作为 Vagrant 提供者。这样对吗?

最佳答案

2021 年 1 月更新 :GitHub Actions还支持 Vagrant - 和 Vagrant/VirtualBox are both installed out-of-the-box in the MacOS environment ( not on Linux 或当前 Windows!)。见 possible environments here .因此,我在以下位置创建了一个完全可理解的示例项目:https://github.com/jonashackt/vagrant-github-actions
1.:创建一个Vagrantfile (并且您不仅限于使用 Travis 的 libvirt,您拥有一个完整的 VirtualBox 环境,其中包含在 GitHub Actions 上工作的嵌套虚拟化!)像这样:

Vagrant.configure("2") do |config|
config.vm.box = "generic/ubuntu1804"

config.vm.define 'ubuntu'

# Prevent SharedFoldersEnableSymlinksCreate errors
config.vm.synced_folder ".", "/vagrant", disabled: true
end
2.:创建 GitHub 操作工作流 像这样 vagrant-up.yml.github/workflows存储库中的目录:
name: vagrant-up

on: [push]

jobs:
vagrant-up:
runs-on: macos-10.15

steps:
- uses: actions/checkout@v2

- name: Run vagrant up
run: vagrant up

- name: ssh into box after boot
run: vagrant ssh -c "echo 'hello world!'"
你甚至可以 add caching for the Vagran boxes ,这会让你安全几秒钟:)

2020 年初:
TravisCI 现在终于可以运行 Vagrant 了! 感谢 this GitHub issue我了解到 libvirt和 KVM,可与 vagrant-libvirt Plugin 一起使用在 TravisCI 上运行 Vagrant 盒子。
一个例子 TravisCI .travis.yml应该看起来像这样:
---
dist: bionic
language: python

install:
# Install libvrt & KVM
- sudo apt-get update && sudo apt-get install -y bridge-utils dnsmasq-base ebtables libvirt-bin libvirt-dev qemu-kvm qemu-utils ruby-dev

# Download Vagrant & Install Vagrant package
- sudo wget -nv https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_x86_64.deb
- sudo dpkg -i vagrant_2.2.7_x86_64.deb

# Vagrant correctly installed?
- vagrant --version

# Install vagrant-libvirt Vagrant plugin
- sudo vagrant plugin install vagrant-libvirt

script:
- sudo vagrant up --provider=libvirt
- sudo vagrant ssh -c "echo 'hello world!'"
generic Vagrant Box images from Vagrant Cloud的帮助下如果您愿意,您还可以建立在 Travis 上使用 Vagrant + libvirt + KVM 和在本地机器上使用 Vagrant + VirtualBox 的工作流程:
enter image description here
我在这里创建了一个完全有效且 100% 可理解的示例项目: https://github.com/jonashackt/vagrant-travisci-libvrt

关于continuous-integration - 在云 CI 服务上使用 Vagrant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31828555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com