0
I need to test a few forms from my local dev machine using vagrant. But the problem is that I can't find a way to connect to distant SMTP using my vagrant box. When on my "live" site, everything work well, but I don't want to deploy every time I make a change.
I tried many things, public_network with DHCP, "--nicpromisc2", "allow-all"....
I can't get it to work, is there any Vagrant Guru out there to help me with that ?
Thank you !
Here is my 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
Did you edit the hosts file of the vagrant box? – random – 2016-11-24T03:30:55.020
No, should I ?? – Jonathan Lafleur – 2016-11-24T04:08:35.570
Can the box ping any sites? – random – 2016-11-24T04:26:53.133
Yes, that's when I try telnet that it don't work and PHPMailer fail to connect – Jonathan Lafleur – 2016-11-24T11:26:37.040