This will output the IP-Address of interface eth1 from each host
desc "Print local ip address"You can extend it like this to replace a given template text inside a file with the IP from one interface
task :show_local_ip, :roles => [:app] do
run "ifconfig eth1 | grep 'inet addr:'| cut -d: -f2 | awk '{ print $1}'"
end
desc "replace local ip address"This will replace %%IPADDRESS%% inside the myconfig file with the IP-Address of your Interface eth1
task :replace_local_ip, :roles => [:app] do
run "ifconfig eth1 | grep 'inet addr:'| cut -d: -f2 | awk '{ printf $1}' | xargs -0 -INEWIP perl -pi.bak -e 's/%%IPADDRESS%%/NEWIP/' #{current_releasse}/myconfig"
end
Keine Kommentare:
Kommentar veröffentlichen