I am trying to retrieve the hostonly ip address specified in the Vagrantfile:
config.vm.network :hostonly, "33.33.33.33"
in a recipe file :
mycookbook/files/default/xdebug.ini
[xdebug]
zend_extension = "/usr/lib/php/modules/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "***HERE***"
xdebug.trace_output_dir = "/tmp"
xdebug.max_nesting_level = 200
node[:network][:interfaces][:eth1][:addresses].detect{|k,v| v[:family] == "inet" }.first
Actually you can find out all the node attributes by logging into the VM (with vagrant ssh) and running shef. And inspect there the node object.
If you want to retrieve the IP of the Host machine, you can use this:
in your recipe:
your/cookbook/path/recipes/default.rb
ip = node[:network][:interfaces][:eth1][:addresses].detect{|k,v| v[:family] == "inet" }.first
remote_ip = ip.gsub /\.\d+$/, '.1'
template "/etc/php.d/xdebug.ini" do
source "xdebug.ini.erb"
owner "root"
group "root"
mode 0644
variables({
"remote_host" => remote_ip
})
end
and in the template: your/cookbook/path/templates/default/xdebug.ini.erb
[xdebug]
zend_extension = "/usr/lib/php/modules/xdebug.so"
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "/tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = <%= @remote_host %>
xdebug.trace_output_dir = "/tmp"
xdebug.max_nesting_level = 200
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With