Before writing your own code take a look at https://forge.puppetlabs.com. Because usually there is a module which totally covers all your needs.
In your case if I understand your task correctly it's https://forge.puppetlabs.com/example42/network
If you still want to do that manually you should either use simple template substitution as was mentioned already or augeas
which I think a better idea.
For example to configure vmbr0
interface you need to add something like this for Debian:
augeas{ "vmbr0_interface" :
context => "/files/etc/network/interfaces",
changes => [
"set auto[child::1 = 'vmbr0']/1 vmbr0",
"set iface[. = 'vmbr0'] vmbr0",
"set iface[. = 'vmbr0']/family inet",
"set iface[. = 'vmbr0']/method static",
"set iface[. = 'vmbr0']/address 192.168.11.1",
"set iface[. = 'vmbr0']/netmask 255.255.255.0",
"set iface[. = 'vmbr0']/bridge_ports none",
"set iface[. = 'vmbr0']/bridge_stp off",
"set iface[. = 'vmbr0']/bridge_fd 0"
]
}
And for CentOS:
augeas { "eth1":
context => "/files/etc/sysconfig/network-scripts/ifcfg-eth1",
changes => [
"set DEVICE eth1",
"set BOOTPROTO none",
"set ONBOOT yes",
"set NETMASK 255.255.255.0",
"set IPADDR 10.12.0.10",
],
}
Also follow this link http://projects.puppetlabs.com/projects/1/wiki/Network_Interface_Templates_Patterns. It has some nice thoughts about network configuration.