module-tinc/manifests/vpn_net.pp

110 lines
2.9 KiB
ObjectPascal
Raw Normal View History

2010-10-22 23:15:28 +02:00
define tinc::vpn_net(
$ensure = present,
$connect_to_hosts = [],
$connect_on_boot = true,
$hosts_source = 'absent',
$hosts_source_is_prefix = false,
$key_source_prefix = 'absent',
$tinc_ip = 'absent',
$tinc_interface = 'absent',
$tinc_bridge_interface = 'absent'
){
include ::tinc
2010-10-23 01:29:49 +02:00
2010-10-22 23:15:28 +02:00
file{"/etc/tinc/${name}":
require => Package['tinc'],
notify => Service['tinc'],
owner => root, group => 0, mode => 0644;
}
line{"tinc_boot_net_${name}":
ensure => $ensure ? {
'present' => $connect_on_boot ? {
true => 'present',
default => 'absent'
},
default => 'absent'
},
line => $name,
file => '/etc/tinc/nets.boot',
require => File['/etc/tinc/nets.boot'],
notify => Service['tinc'],
}
if $ensure == 'present' {
File["/etc/tinc/${name}"]{
ensure => directory,
}
file{"/etc/tinc/${name}/hosts":
source => 'puppet:///modules/common/empty',
ensure => directory,
recurse => true,
purge => true,
force => true,
require => Package['tinc'],
notify => Service['tinc'],
owner => root, group => 0, mode => 0644;
}
file { "/etc/tinc/${name}/tinc.conf":
content => template('tinc/tinc.conf.erb'),
notify => Service[tinc],
owner => root, group => 0, mode => 0600;
}
file{"/etc/tinc/${name}/rsa_key.priv":
source => $key_source_prefix ? {
'absent' => "puppet:///modules/site-tinc/keys/${name}/${fqdn}/rsa_key.priv",
2010-10-22 23:53:15 +02:00
default => "${key_source_prefix}/${name}/${fqdn}/rsa_key.priv",
2010-10-22 23:15:28 +02:00
},
notify => Service[tinc],
owner => root, group => 0, mode => 0644;
}
file{"/etc/tinc/${name}/rsa_key.pub":
source => $key_source_prefix ? {
'absent' => "puppet:///modules/site-tinc/keys/${name}/${fqdn}/rsa_key.pub",
2010-10-22 23:53:15 +02:00
default => "${key_source_prefix}/${name}/${fqdn}/rsa_key.pub",
2010-10-22 23:15:28 +02:00
},
notify => Service[tinc],
owner => root, group => 0, mode => 0644;
}
# always include myself in the hosts dir
tinc::vpn_net::host{$fqdn:
source => $hosts_source,
source_is_prefix => $hosts_source_is_prefix,
vpn_net => $name
}
# include all the hosts we should connect to
tinc::vpn_net::host{$connect_to_hosts:
source => $hosts_source,
source_is_prefix => $hosts_source_is_prefix,
vpn_net => $name
}
$real_tinc_bridge_interface = $tinc_bridge_interface ? {
'absent' => "br${name}",
default => $tinc_bridge_interface
}
$real_tinc_ip = $tinc_ip ? {
'absent' => $ip,
default => $tinc_ip
}
file { "/etc/tinc/${name}/tinc-up":
content => template('tinc/tinc-up.erb'),
require => Package['bridge-utils'],
notify => Service['tinc'],
owner => root, group => 0, mode => 0600;
}
} else {
File["/etc/tinc/${name}"]{
ensure => absent,
recurse => true,
purge => true,
force => true
}
}
}