1、VirtualBox依赖安装
# 安装依赖并重启服务器 dnf --enablerepo=epel -y install kernel-devel-$(uname -r) kernel-headers-$(uname -r) gcc gcc-c++ glibc make bzip2 dkms perl elfutils-libelf-devel libX11-devel libXt libXmu
2、VirtualBox安装
# 安装源配置 curl http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo -o /etc/yum.repos.d/virtualbox.repo # 查看当前可用版本 dnf search virtualbox # 安装VirtualBox dnf -y install VirtualBox-7.0
3、Vagrant安装
dnf install -y yum-utils yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo dnf -y install vagrant
4、命令补全
vagrant autocomplete install --bash
5、Vagrant参数
# vagrant --help Usage: vagrant [options] <command> [<args>] -h, --help Print this help. Common commands: autocomplete manages autocomplete installation on host box manages boxes: installation, removal, etc. cloud manages everything related to Vagrant Cloud destroy stops and deletes all traces of the vagrant machine global-status outputs status Vagrant environments for this user halt stops the vagrant machine help shows the help for a subcommand init initializes a new Vagrant environment by creating a Vagrantfile login package packages a running vagrant environment into a box plugin manages plugins: install, uninstall, update, etc. port displays information about guest port mappings powershell connects to machine via powershell remoting provision provisions the vagrant machine push deploys code in this environment to a configured destination rdp connects to machine via RDP reload restarts vagrant machine, loads new Vagrantfile configuration resume resume a suspended vagrant machine serve start Vagrant server snapshot manages snapshots: saving, restoring, etc. ssh connects to machine via SSH ssh-config outputs OpenSSH valid configuration to connect to the machine status outputs status of the vagrant machine suspend suspends the machine up starts and provisions the vagrant environment upload upload to machine via communicator validate validates the Vagrantfile version prints current and latest Vagrant version winrm executes commands on a machine via WinRM winrm-config outputs WinRM configuration to connect to the machine For help on any individual command run `vagrant COMMAND -h` Additional subcommands are available, but are either more advanced or not commonly used. To see all subcommands, run the command `vagrant list-commands`. --[no-]color Enable or disable color output --machine-readable Enable machine readable output -v, --version Display Vagrant version --debug Enable debug output --timestamp Enable timestamps on log output --debug-timestamp Enable debug output with timestamps --no-tty Enable non-interactive output
6、Vagrant日常操作
# 查看Vagrant版本 vagrant --version # 查看Vagrant当前所有已安装系统 vagrant global-status # 查看所有已添加box vagrant box list # 启动系统 vagrant init generic/centos7 vagrant up # 离线下载并启动box vagrant box add --name=centos7 /data/centos7/centos7.box vagrant init centos7 vagrant up --provider=virtualbox
7、Vagrant插件安装
# 安装rubygems dnf install rubygems -y # 配置国内源 gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/ # 列出已有源 gem sources -l # 插件安装并查看 vagrant plugin install vagrant-reload vagrant plugin install vagrant-share vagrant plugin install vagrant-mutate vagrant plugin list
8、Packer安装
dnf install -y yum-utils yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo dnf -y install packer
参考:https://developer.hashicorp.com/vagrant/downloads
https://www.virtualbox.org/wiki/Linux_Downloads
https://www.modb.pro/db/88457
https://developer.hashicorp.com/packer/downloads
https://github.com/chef/bento