Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client pull option and allow remote_host to be an array of servers #195

Merged
merged 1 commit into from
May 3, 2016
Merged
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
7 changes: 6 additions & 1 deletion manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# Options: tcp or udp
#
# [*remote_host*]
# String. The IP or hostname of the openvpn server service
# String/Array. The IP or hostname of the openvpn server service.
# Default: FQDN
#
# [*cipher*]
Expand Down Expand Up @@ -141,6 +141,10 @@
# archive.
# Default: undef
#
# [*pull*]
# Boolean. Allow server to push options like dns or routes
# Default: false
#
# === Examples
#
# openvpn::client {
Expand Down Expand Up @@ -206,6 +210,7 @@
$custom_options = {},
$expire = undef,
$readme = undef,
$pull = false,
) {

if $pam {
Expand Down
7 changes: 6 additions & 1 deletion spec/defines/openvpn_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
it { should_not contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^verify-x509-name/)}
it { should_not contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^sndbuf/)}
it { should_not contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^rcvbuf/)}
it { should_not contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^pull/)}
end

context "setting all of the parameters" do
Expand All @@ -78,7 +79,7 @@
'tls_cipher' => 'TLS-DHE-RSA-WITH-AES-256-CBC-SHA',
'port' => '123',
'proto' => 'udp',
'remote_host' => 'somewhere',
'remote_host' => ['somewhere', 'galaxy'],
'resolv_retry' => '2m',
'auth_retry' => 'interact',
'verb' => '1',
Expand All @@ -89,6 +90,7 @@
'sndbuf' => 393216,
'rcvbuf' => 393215,
'readme' => 'readme text',
'pull' => true,
} }
let(:facts) { {
:fqdn => 'somehost',
Expand All @@ -105,6 +107,7 @@
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^dev\s+tap$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^proto\s+udp$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^remote\s+somewhere\s+123$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^remote\s+galaxy\s+123$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^comp-something$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^resolv-retry\s+2m$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^verb\s+1$/)}
Expand All @@ -119,6 +122,8 @@
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^sndbuf\s+393216$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^rcvbuf\s+393215$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/README').with_content(/^readme text$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^pull$/)}

end

context "omitting the cipher key" do
Expand Down
8 changes: 7 additions & 1 deletion templates/client.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ cert keys/<%= @name %>/<%= @name %>.crt
key keys/<%= @name %>/<%= @name %>.key
dev <%= @dev %>
proto <%= @proto %>
remote <%= @remote_host %> <%= @port %>
<% @remote_host = [@remote_host] unless @remote_host.kind_of?(Array) -%>
<% @remote_host.each do |item| -%>
remote <%= item %> <%= @port %>
<% end -%>
<% if @compression != '' -%>
<%= @compression %>
<% end -%>
resolv-retry <%= @resolv_retry %>
auth-retry <%= @auth_retry %>
<% if @pull -%>
pull
<% end -%>
<% if @nobind -%>
nobind
<% end -%>
Expand Down