Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions manifests/tun.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# [*cert*]
# Certificate to use for this tunnel
#
# [*key*]
# Key to use for this tunnel
#
# [*client*]
# Whether this tunnel should be setup in client mode.
#
Expand Down Expand Up @@ -68,6 +71,7 @@
$connect,
$cafile = '',
$cert = 'UNSET',
$key = '',
$client = false,
$options = [ ],
$failover = 'rr',
Expand Down Expand Up @@ -95,6 +99,11 @@
default => $cafile,
}

$key_real = $key ? {
'UNSET' => '',
default => $key,
}

# Clients don't require a certificate but servers do
if $client {
$cert_default = ''
Expand All @@ -113,6 +122,9 @@
if $cert_real != '' {
validate_absolute_path( $cert_real )
}
if $key_real != '' {
validate_absolute_path( $key_real )
}
validate_bool( str2bool($client) )

if is_string($options) {
Expand Down
19 changes: 11 additions & 8 deletions templates/tun.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# This file managed by Puppet
<% if @cert_real != '' -%>
cert = <%= @cert_real %>
<% end -%>
<% if @cafile_real != '' -%>
CAfile = <%= @cafile_real %>
<% else -%>
# CAfile = /path/to/cafile.crt
<% end -%>

setuid = root
setgid = root
Expand Down Expand Up @@ -35,6 +27,17 @@ options = <%= option %>
<%- end -%>

[<%= @name %>]
<% if @cert_real != '' -%>
cert = <%= @cert_real %>
<% end -%>
<% if @cafile_real != '' -%>
CAfile = <%= @cafile_real %>
<% else -%>
# CAfile = /path/to/cafile.crt
<% end -%>
<% if @key_real != '' -%>
key = <%= @key_real %>
<% end -%>
<% if @accept -%>
accept=<%= @accept %>
<% end -%>
Expand Down