Compare commits

...

3 commits

3 changed files with 26 additions and 11 deletions

View file

@ -4,9 +4,12 @@ define tinc::instance(
$connect_on_boot = true,
$tinc_interface = 'eth0',
$tinc_address = undef,
$tinc_address_to_export = undef,
$port = '655',
$port_to_export = '655',
$compression = '10',
$mode = 'switch',
$options = {},
$tinc_up_content = undef,
$tinc_down_content = undef,
){
@ -94,6 +97,11 @@ define tinc::instance(
$int_name_escaped = regsubst($tinc_interface,'\.','_','G')
$host_address = getvar("::ipaddress_${int_name_escaped}")
}
if $tinc_address_to_export {
$export_addr = $tinc_address_to_export
} else {
$export_addr = $host_address
}
# get the keys
# [ priv, pub ]
@ -114,9 +122,9 @@ define tinc::instance(
}
# export this host and collect all the other hosts
@@tinc::host{"${fqdn_tinc}@${name}":
port => $port,
port => $port_to_export,
compression => $compression,
address => $host_address,
address => $export_addr,
public_key => $tinc_keys[1],
tag => "tinc::host_for_${name}",
}

View file

@ -5,22 +5,28 @@ define tinc::switch(
$tinc_interface = 'eth0',
$tinc_address = undef,
$port = '655',
$tinc_address_to_export = undef,
$port_to_export = '655',
$tinc_internal_interface = 'eth1',
$tinc_internal_ip = 'absent',
$tinc_internal_netmask = 'absent',
$tinc_bridge_interface = 'absent',
$compression = '10',
$options = {},
$shorewall_zone = 'absent'
){
tinc::instance{$name:
ensure => $ensure,
connect_on_boot => $connect_on_boot,
tinc_interface => $tinc_interface,
tinc_address => $tinc_address,
port => $port,
compression => $compression,
mode => 'switch',
ensure => $ensure,
connect_on_boot => $connect_on_boot,
tinc_interface => $tinc_interface,
tinc_address => $tinc_address,
tinc_address_to_export => $tinc_address_to_export,
port => $port,
port_to_export => $port_to_export,
compression => $compression,
mode => 'switch',
options => $options,
}
if $ensure == 'present' {

View file

@ -1,9 +1,10 @@
Name = <%= @fqdn_tinc %>
AddressFamily = ipv4
Device = /dev/net/tun
#PMTU = 1440
Mode = <%= @mode %>
BindToAddress = <%= @host_address %> <%= @port %>
BindToInterface = <%= @tinc_interface.to_s %>
<% @options.keys.sort.each do |key| -%>
<%= key %> = <%= @options[key] %>
<% end -%>