Skip to content
This repository was archived by the owner on Jul 18, 2022. It is now read-only.

client config: add parameter to specify connections to client #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
31 changes: 16 additions & 15 deletions manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@
# Example: ['2001:db8::/32']
#
define openvpn::client (
String $server,
String $auth = 'SHA1',
String $port = '1194',
String $proto = 'udp',
String $dev = 'tun',
String $ca = 'ca.crt',
String $cert = $name,
String $ns_cert_type = 'server',
Integer $verb = 3,
String $cipher = 'AES-192-CBC',
String $compression = 'lzo',
Optional[String] $tls_auth_key = undef,
Array $custom_options = [],
Array $route_ipv4 = [],
Array $route_ipv6 = [],
String $server,
String $auth = 'SHA1',
String $port = '1194',
String $proto = 'udp',
String $dev = 'tun',
String $ca = 'ca.crt',
String $cert = $name,
String $ns_cert_type = 'server',
Integer $verb = 3,
String $cipher = 'AES-192-CBC',
String $compression = 'lzo',
Optional[String] $tls_auth_key = undef,
Optional[Array[Hash]] $connections = undef,
Array $custom_options = [],
Array $route_ipv4 = [],
Array $route_ipv6 = [],
) {

include openvpn
Expand Down
10 changes: 10 additions & 0 deletions templates/client.conf.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
client
dev <%= @dev %>
proto <%= @proto %>
<% if @connections -%>
<%- @connections.each do | connection | -%>
<%- %><connection>
<%- connection.each do | key, val | -%>
<%= key %> <%= val %>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be left aligned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no there is not need to left align. the config file would look like:

<connection>
       remote somehost.somewhere.com
       port 1194
       proto udp
</connection>
<connection>
       remote otherhost
       .....

so it's much more readable if not left aligned.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see.

<%- end -%>
<%- %></connection>
<%- end -%>
<% else -%>
remote <%= @server %> <%= @port %>
<% end -%>
resolv-retry infinite
nobind
persist-key
Expand Down