Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用CoreOS的Vagrant多VM配置_Vagrant_Vagrantfile_Coreos - Fatal编程技术网

使用CoreOS的Vagrant多VM配置

使用CoreOS的Vagrant多VM配置,vagrant,vagrantfile,coreos,Vagrant,Vagrantfile,Coreos,我想做的是,将标准的CoreOS Vagrantfile和我自己的Vagrantfile集成在一起,这两个文件启动了一个Ubuntu盒子 这是我的档案: # Vagrantfile API/syntax version. VAGRANTFILE_API_VERSION = "2" ### Check if required plugins are installed unless Vagrant.has_plugin?("vagrant-bindfs") raise 'vagrant-bi

我想做的是,将标准的CoreOS Vagrantfile和我自己的Vagrantfile集成在一起,这两个文件启动了一个Ubuntu盒子

这是我的档案:

# Vagrantfile API/syntax version.
VAGRANTFILE_API_VERSION = "2"

### Check if required plugins are installed
unless Vagrant.has_plugin?("vagrant-bindfs")
  raise 'vagrant-bindfs plugin is missing!'
end

unless Vagrant.has_plugin?("vagrant-hostsupdater")
  raise 'vagrant-hostsupdater plugin is missing!'
end


# Setup CoreOS config files
CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data")
CONFIG = File.join(File.dirname(__FILE__), "config.rb")

# Defaults for config options defined in CONFIG
$num_instances = 1
$instance_name_prefix = "core"
$update_channel = "stable"


# Attempt to apply the deprecated environment variable NUM_INSTANCES to
# $num_instances while allowing config.rb to override it
if ENV["NUM_INSTANCES"].to_i > 0 && ENV["NUM_INSTANCES"]
  $num_instances = ENV["NUM_INSTANCES"].to_i
end

# Include Config file
if File.exist?(CONFIG)
  require CONFIG
end


Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

# COREOS
  config.vm.define :coreos do |node|
    node.ssh.insert_key = false
    node.vm.box = "coreos-%s" % $update_channel
    node.vm.box_version = ">= 308.0.1"
    node.vm.box_url = "http://%s.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json" % $update_channel

    node.vm.provider :virtualbox do |v|
      v.check_guest_additions = false
      v.functional_vboxsf     = false
    end

    if Vagrant.has_plugin?("vagrant-vbguest") then
      node.vbguest.auto_update = false
    end

    (1..$num_instances).each do |i|
      node.vm.define vm_name = "%s-%02d" % [$instance_name_prefix, i] do |node|
        node.vm.hostname = vm_name
        ip = "172.17.8.#{i+100}"
        node.vm.network :private_network, ip: ip

        if File.exist?(CLOUD_CONFIG_PATH)
          node.vm.provision :file, :source => "#{CLOUD_CONFIG_PATH}", :destination => "/tmp/vagrantfile-user-data"
          node.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true
        end
      end
    end
  end


# UBUNTU

  config.vm.define :ubuntu do |node|
    node.vm.box = "ubuntu1404-64"
    node.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
    node.vm.network "private_network", ip: "192.168.100.100"
    node.vm.hostname = "wpthor"
    node.bindfs.debug = true

  ### Set a right amount of memory
    node.vm.provider :virtualbox do |vb|
      vb.customize ["modifyvm", :id, "--memory", "1024"]
    end


  ### Fix for Ansible bug resulting in an encoding error
    ENV['PYTHONIOENCODING'] = "utf-8"

  ### Run Ansible provision
    node.vm.provision "ansible" do |ansible|
      ansible.limit = 'all'
      ansible.verbose = "" ### If you notice errors, add "vvv" here to activate verbose mode
      ansible.playbook = "ansible/development.yml"
      ansible.inventory_path = "ansible/hosts"
    end
  end
end

它可以正常工作,但只引导一个CoreOS节点(而不是3个)。也许这是一个愚蠢的语法错误,但我想不出解决办法。你能帮我吗?

只需更新你想要启动的机器数量


$num_实例=3