Skip to content

Commit

Permalink
Merge pull request #195 from Project0/pull_client
Browse files Browse the repository at this point in the history
Add client pull option and allow remote_host to be an array of servers
  • Loading branch information
luxflux committed May 3, 2016
2 parents 10060f8 + 8797784 commit 58f3403
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
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 @@ -63,6 +63,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 @@ -79,7 +80,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 @@ -90,6 +91,7 @@
'sndbuf' => 393216,
'rcvbuf' => 393215,
'readme' => 'readme text',
'pull' => true,
} }
let(:facts) { {
:fqdn => 'somehost',
Expand All @@ -106,6 +108,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 @@ -120,6 +123,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
@@ -1,12 +1,18 @@
client
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

0 comments on commit 58f3403

Please sign in to comment.