Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Not exactly what you're looking for, but it cuts down on having to keep multiple variables in sync:

site.pp:

class { 'ip::addr': name => "as2s67v", cidrs => [ "192.168.30.0/24", "172.45.35.0/16", "145.88.88.0/24" ] } 

modules/ip/addr.pp:

class ip::addr ($cidrs) { file { "/tmp/$name": content => template("ip/template.pp") } } 

template.pp:

server: <%= name %> <% for idx in (0..(cidrs.length-1)) -%> ipaddress<%= idx %> = "<%= cidrs[idx].split("/")[0] %>" prefix<%= idx %> = "<%= cidrs[idx].split("/")[1] %> <% end -%> 

References:

Not exactly what you're looking for, but it cuts down on having to keep multiple variables in sync:

site.pp:

class { 'ip::addr': name => "as2s67v", cidrs => [ "192.168.30.0/24", "172.45.35.0/16", "145.88.88.0/24" ] } 

modules/ip/addr.pp:

class ip::addr ($cidrs) { file { "/tmp/$name": content => template("ip/template.pp") } } 

template.pp:

server: <%= name %> <% for idx in (0..(cidrs.length-1)) -%> ipaddress<%= idx %> = "<%= cidrs[idx].split("/")[0] %>" prefix<%= idx %> = "<%= cidrs[idx].split("/")[1] %> <% end -%> 

References:

Not exactly what you're looking for, but it cuts down on having to keep multiple variables in sync:

site.pp:

class { 'ip::addr': name => "as2s67v", cidrs => [ "192.168.30.0/24", "172.45.35.0/16", "145.88.88.0/24" ] } 

modules/ip/addr.pp:

class ip::addr ($cidrs) { file { "/tmp/$name": content => template("ip/template.pp") } } 

template.pp:

server: <%= name %> <% for idx in (0..(cidrs.length-1)) -%> ipaddress<%= idx %> = "<%= cidrs[idx].split("/")[0] %>" prefix<%= idx %> = "<%= cidrs[idx].split("/")[1] %> <% end -%> 

References:

Source Link
Mike Renfro
  • 1.3k
  • 1
  • 8
  • 11

Not exactly what you're looking for, but it cuts down on having to keep multiple variables in sync:

site.pp:

class { 'ip::addr': name => "as2s67v", cidrs => [ "192.168.30.0/24", "172.45.35.0/16", "145.88.88.0/24" ] } 

modules/ip/addr.pp:

class ip::addr ($cidrs) { file { "/tmp/$name": content => template("ip/template.pp") } } 

template.pp:

server: <%= name %> <% for idx in (0..(cidrs.length-1)) -%> ipaddress<%= idx %> = "<%= cidrs[idx].split("/")[0] %>" prefix<%= idx %> = "<%= cidrs[idx].split("/")[1] %> <% end -%> 

References: