Take a look to the inline template feature
define myapp {
$myip = inline_template("<%= ipaddress_eth0_${name} %>")
exec {"$name":
command => "/bin/sed -i 's/IP_ADDRESS=\"127.0.0.1\"/IP_ADDRESS=\"$myip\"/' /opt/app.${name}/bin/setenv.sh"
}