cat <<'EOF' > Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "rockylinux/9"
#config.vm.box = "almalinux/9"
config.vm.provider "virtualbox" do |vb|
#config.vm.provider "vmware_desktop" do |vb|
vb.memory = "768"
vb.cpus = 2
end
config.vm.define "machine"
config.vm.synced_folder '.', '/vagrant', disabled: true
end
EOF
config.vm.hostname = "hostname"
config.vm.define "machine" do |machine|
machine.vm.network "public_network" , bridge: "en0: Wi-Fi"
end
config.vm.define "machine" do |machine|
machine.vm.network :private_network, ip:"192.168.255.2"
end
machine.vm.network :forwarded_port, guest:22, host:1234, id:"ssh"
config.vm.provision "ansible" do |ansible|
ansible.playbook = "site.yml"
end
イメージによって、エラー有無がある。
config.vm.synced_folder '.', '/vagrant', disabled: true
# Vagrantfile作成
vagrant init
vagrant up
vagrant up --provision
vagrant up --no-provision
vagrant provision
vagrant status
vagrant ssh
vagrant suspend
vagrant halt
vagrant global-status
vagrant destroy -f [id]
vagrant global-status --prune
seq 2 | xargs -P2 -I@ vagrant up vm@
vagrant ssh-config > ssh.config
scp -P 2222 -F ssh.config vagrant@localhost:/etc/redhat-release .
# プラグインのインストール
vagrant plugin install vagrant-vbguest
# 実行
vagrant vbguest
vagrant global-status
vagrant global-status —-prune
for f in `vagrant global-status --prune | grep /Users/ | awk '{print $1}'`
do
vagrant destroy $f -f &
done
wait
# box
vagrant box list | awk '{print $1}' | xargs -I@ vagrant box remove @ --all
# VirtualBox
VBoxManage list vms | awk '{print $1}' | xargs -I@ VBoxManage unregistervm @
rm -rf "${HOME}/VirtualBox VMs"/*
brew install vagrant
# その他、VirtualBoxが必要