我需要使用 vagrant 从本地开发机器测试一些表单。但问题是我找不到使用 vagrant box 连接到远程 SMTP 的方法。在我的“实时”网站上,一切都运行良好,但我不想每次进行更改时都进行部署。
我尝试了很多方法,使用 DHCP 的 public_network、“--nicpromisc2”、“allow-all”……
我无法让它工作,有没有 Vagrant Guru 可以帮助我?
谢谢 !
这是我的 Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
current_dir = File.dirname(File.expand_path(__FILE__))
configs = YAML.load_file("#{current_dir}/deploy/group_vars/all")
vagrant_config = configs
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
if Vagrant.has_plugin?("vagrant-cachier")
# Configure cached packages to be shared between instances of the same base box.
config.cache.scope = :box
config.cache.synced_folder_opts = {
type: :nfs
}
end
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "ubuntu/trusty64"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.33.10"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "./public_html/", "/var/www/html"
config.vm.synced_folder "./tools", "/var/www/html/tools"
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.vm.define 'default' do |node|
node.vm.hostname = vagrant_config['hostname']
node.vm.network :private_network, ip: '192.168.33.10'
node.hostmanager.aliases = [ 'www.' + vagrant_config['hostname'] ]
end
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "ansible" do |ansible|
ansible.playbook = "deploy/site.yml"
# ansible.inventory_path = "deploy/inventory/development"
ansible.limit = "default"
ansible.groups = {
"webservers" => ["default"],
"dbservers" => ["default"]
}
ansible.sudo = true
#ansible.verbose = "vvvvv"
end
end