abstract the tinc host part into its own define
This commit is contained in:
parent
ebf3a00ed1
commit
4e22ae9781
3 changed files with 46 additions and 11 deletions
36
manifests/host.pp
Normal file
36
manifests/host.pp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# a host for a certain network
|
||||||
|
# title must be:
|
||||||
|
# hostname@network
|
||||||
|
#
|
||||||
|
define tinc::host(
|
||||||
|
$public_key,
|
||||||
|
$ensure = present,
|
||||||
|
$port = 655,
|
||||||
|
$compression = 10,
|
||||||
|
) {
|
||||||
|
# if absent the net should
|
||||||
|
# clean it up by itself
|
||||||
|
if $ensure == 'present' {
|
||||||
|
validate_re($name,'.+@.+')
|
||||||
|
$sp_name = split($name,'@')
|
||||||
|
$fqdn_tinc = $sp_name[0]
|
||||||
|
$net = $sp_name[1]
|
||||||
|
|
||||||
|
include tinc
|
||||||
|
if $tinc::uses_systemd {
|
||||||
|
$service_name = "tincd@${net}"
|
||||||
|
} else {
|
||||||
|
$service_name = 'tinc'
|
||||||
|
}
|
||||||
|
|
||||||
|
file{"/etc/tinc/${net}/hosts/${fqdn_tinc}":
|
||||||
|
content => template('tinc/host.erb'),
|
||||||
|
# to be sure that we manage that net
|
||||||
|
require => File["/etc/tinc/${net}/hosts"],
|
||||||
|
notify => Service[$service_name],
|
||||||
|
owner => root,
|
||||||
|
group => 0,
|
||||||
|
mode => '0600';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -112,15 +112,15 @@ define tinc::instance(
|
||||||
group => 0,
|
group => 0,
|
||||||
mode => '0600';
|
mode => '0600';
|
||||||
}
|
}
|
||||||
# export and collect all the keys of this net
|
# export this host and collect all the other hosts
|
||||||
@@file { "/etc/tinc/${name}/hosts/${fqdn_tinc}":
|
@@tinc::host{"${fqdn_tinc}@${name}":
|
||||||
content => template('tinc/host.erb'),
|
port => $port,
|
||||||
tag => "tinc_host_for_${name}",
|
compression => $compression,
|
||||||
owner => root,
|
address => $host_address,
|
||||||
group => 0,
|
public_key => $tinc_keys[1],
|
||||||
mode => '0600';
|
tag => "tinc::host_for_${name}",
|
||||||
}
|
}
|
||||||
File<<| tag == "tinc_host_for_${name}" |>>
|
Tinc::Host<<| tag == "tinc::host_for_${name}" |>>
|
||||||
|
|
||||||
concat::fragment{"tinc_conf_header_${name}":
|
concat::fragment{"tinc_conf_header_${name}":
|
||||||
target => $tinc_config,
|
target => $tinc_config,
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
Address = <%= @host_address %>
|
Address = <%= @address %>
|
||||||
Port = <%= @port %>
|
Port = <%= @port %>
|
||||||
Compression = <%= @compression %> # 0=no,11=best lzo
|
Compression = <%= @compression %> # 0=no,11=best lzo
|
||||||
#
|
|
||||||
|
|
||||||
<%= @tinc_keys[1] %>
|
<%= @public_key %>
|
||||||
|
|
Loading…
Reference in a new issue