首页 > 解决方案 > 为什么我在这个 Vagrantfile 中出现语法错误

问题描述

我刚开始学习如何使用 Vagrant!因此,当我尝试在 Vagrant 中迈出第一步时,我正在尝试使用“vagrant up”创建一个 vagrant 环境,但我的 Vagrantfile 出现语法错误。这是流浪文件:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

# Always use Vagrant's default insecure key
  config.ssh.insert_key = false
# Always use X11 Forwarding with r+this machine
  config.ssh.forward_x11 = true
# To avoid/allow install and uninstall of VBoxGuessAdditions.
  config.vbguest.auto_update = false
# Disable/enable automatic box update checking.
  config.vm.box_check_update = false



# Assign a friendly name for vagrant STATUS
  config.vm.define "mininet" do |mininet_config|
  # Every Vagrant development environment requires a box.
  mininet_config.vm.box = "ktr/mininet"
  # Assign a friendly name to this host VM
  mininet_config.vm.hostname = "mininet"
  # Create a private network, which allows host-only access to the machine
  mininet_config.vm.network "private_network", ip: "192.168.56.11"
  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant.
  # Example for VirtualBox:
    mininet_config.vm.provider "virtualbox" do |vb|
    # Change the VM name/ID in the Hypervisor
      vb.name = "mininet"
      opts = ["modifyvm", :id, "--natdnshostresolver1", "on"]
      vb.customize opts
    end
  end

# Some shell provisioning when machine is launched
 config.vm.provision "shell", :inline "apt-get update --fix-missing"

end

这是来自终端的警告:

 syntax error, unexpected tSTRING_BEG, expecting keyword_end
m.provision "shell", :inline "apt-get update --fix-missing"
                              ^
/home/alexandre/Desktop/3ano/RC/lab1/RC/mininet-updated/Vagrantfile:38: syntax error, unexpected keyword_end, expecting end-of-input

如果有人可以帮助我解决这个问题,我将不胜感激。谢谢你的时间

标签: ubuntuvagrantsyntax-errorvagrantfile

解决方案


推荐阅读