我的Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.define "vm1" do |vm1|
vm1.vm.box = "debian/buster64"
vm1.vm.box.hostname = "debian-vm"
vm1.vm.network "private_network", ip: "192.168.15.140"
end
vb1.vm.provider "virtualbox" do |vb1|
vb1.customize ["modifyvm", :id, "--gui", false] #changed
vb1.customize ["modifyvm", :id, "--memory", "4092"] #changed
vb1.customize ["modifyvm", :id, "--cpus", "4"] #changed
vb1.customize ["modifyvm", :id, "--name", "debian-vm"] #changed
end
vm1.vm.provision "shell" do |sh1|
sh1.inline = "sudo apt-get update"
sh1.inline = "sudo apt-get install wget ntpdate net-tools nano"
end
config.vm.define "vm2" do |vm2|
vm2.vm.box = "centos7"
vm2.vm.box.hostname = "centos7-vm"
vm2.vm.network "private_network", ip: "192.168.15.142"
end
vb2.vm.provider "virtualbox" do |vb2|
vb2.customize ["modifyvm", :id, "--gui", false] #changed
vb2.customize ["modifyvm", :id, "--memory", "4092"] #changed
vb2.customize ["modifyvm", :id, "--cpus", "4"] #changed
vb2.customize ["modifyvm", :id, "--name", "debian-vm"] #changed
end
vm2.vm.provision "shell" do |sh2|
sh2.inline = "sudo yum check-update"
sh2.inline = "sudo yum -y install wget ntpdate net-tools nano"
sh2.inline = "curl -fsSL https://get.docker.com/ | sh"
sh2.inline = "sudo systemctl start docker"
sh2.inline = "sudo systemctl status docker"
sh2.inline = "sudo systemctl enable docker"
sh2.inline = "sudo ps -ef | grep dockerd"
end
end
该 Vagranfile 的 cmder(终端)的输出是:
C:\Users\Marlon\OneDrive\pipeline (master -> origin)
λ vagrant up
Vagrant failed to initialize at a very early stage:
There is a syntax error in the following Vagrantfile. The syntax error
message is reproduced below for convenience:
C:/Users/Marlon/OneDrive/pipeline/Vagrantfile:15: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
C:/Users/Marlon/OneDrive/pipeline/Vagrantfile:34: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
答案1
语法错误,意外的 tSTRING_BEG,预期为 keyword_do 或 '{' 或 '('
这是一个后续错误,因为上一行有一个错误。
vb.cpus = 4
该论点4
应引用如下:
vb.cpus = "4"
答案2
经过一番研究,我发现我存储的地方没有同步(OneDrive),然后我放入一个静态文件夹并成功了!
做了一些修复和一些命令并将最终的作品放在这里。
附言:刚刚发现,因为 Onedrive 发出了警告,而且我的一些文件夹中有很多大文件。
Vagrant.configure("2") do |config|
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = "4096"
vb.cpus = "4"
end
config.vm.define "vm1" do |vm1|
vm1.vm.box = "centos/7"
vm1.vm.network "public_network", bridge: "en1: Realtek PCIe GBE Family Controller"
vm1.vm.network "public_network", ip: "192.168.15.140"
vm1.vm.hostname = "centos-vm"
vm1.vm.provision "shell", inline: <<-SHELL
sudo yum update
sudo yum -y install wget ntpdate net-tools nano
sudo curl -fsSL https://get.docker.com/ | sh
sudo systemctl start docker
sudo systemctl status docker
sudo systemctl enable docker
sudo ps -ef | grep dockerd
SHELL
end
config.vm.define "vm2" do |vm2|
vm2.vm.box = "debian/buster64"
vm2.vm.network "public_network", bridge: "en1: Realtek PCIe GBE Family Controller"
vm2.vm.network "public_network", ip: "192.168.15.142"
vm2.vm.hostname = "debian-vm"
vm2.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install wget ntpdate net-tools nano
SHELL
end
end