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

Added cipher and push route option to client(specific) config.. #80

Closed
wants to merge 4 commits into from
Closed
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
5 changes: 5 additions & 0 deletions manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
# String. The IP or hostname of the openvpn server service
# Default: FQDN
#
# [*cipher*]
# String, Cipher to use for packet encryption
# Default: None
#
# [*resolv_retry*]
# Integer/String. How many seconds should the openvpn client try to resolve
# the server's hostname
Expand Down Expand Up @@ -129,6 +133,7 @@
$auth_retry = 'none',
$verb = '3',
$pam = false,
$cipher = '',
$authuserpass = false,
) {

Expand Down
5 changes: 5 additions & 0 deletions manifests/client_specific_config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
# Array. Array of iroute combinations.
# Default: []
#
# [*route*]
# Array. Array of route combinations pushed to client.
# Default: []
#
# [*ifconfig*]
# String. IP configuration to push to the client.
# Default: false
Expand Down Expand Up @@ -67,6 +71,7 @@
define openvpn::client_specific_config(
$server,
$iroute = [],
$route = [],
$ifconfig = false,
$dhcp_options = [],
$redirect_gateway = false
Expand Down
2 changes: 2 additions & 0 deletions spec/defines/openvpn_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
'nobind' => false,
'persist_key' => false,
'persist_tun' => false,
'cipher' => 'BF-CBC',
'port' => '123',
'proto' => 'udp',
'remote_host' => 'somewhere',
Expand Down Expand Up @@ -97,6 +98,7 @@
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^verb\s+1$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^mute\s+10$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^auth-retry\s+interact$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^cipher\s+BF-CBC$/)}
end

end
2 changes: 2 additions & 0 deletions spec/defines/openvpn_client_specific_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
{:server => 'test_server',
:iroute => ['10.0.1.0 255.255.255.0'],
:ifconfig => '10.10.10.2 255.255.255.0',
:route => ['10.200.100.0 255.255.255.0 10.10.10.1'],
:dhcp_options => ['DNS 8.8.8.8'],
:redirect_gateway => true}
end
Expand All @@ -44,5 +45,6 @@
it { should contain_file('/etc/openvpn/test_server/client-configs/test_client').with_content(/^ifconfig-push 10.10.10.2 255.255.255.0$/) }
it { should contain_file('/etc/openvpn/test_server/client-configs/test_client').with_content(/^push dhcp-option DNS 8.8.8.8$/) }
it { should contain_file('/etc/openvpn/test_server/client-configs/test_client').with_content(/^push redirect-gateway def1$/) }
it { should contain_file('/etc/openvpn/test_server/client-configs/test_client').with_content(/^push "route 10.200.100.0 255.255.255.0 10.10.10.1"$/) }
end
end
3 changes: 3 additions & 0 deletions templates/client.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ persist-key
<% if scope.lookupvar('persist_tun') -%>
persist-tun
<% end -%>
<% if scope.lookupvar('cipher') -%>
cipher <%= scope.lookupvar('cipher') %>
<% end %>
<% if scope.lookupvar('mute_replay_warnings') -%>
mute-replay-warnings
<% end -%>
Expand Down
10 changes: 7 additions & 3 deletions templates/client_specific_config.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% scope.lookupvar('iroute').each do |route| -%>
iroute <%= route %>
<% scope.lookupvar('iroute').each do |iroute| -%>
iroute <%= iroute %>
<% end -%>
<% if ifconfig = scope.lookupvar('ifconfig') -%>
ifconfig-push <%= ifconfig %>
Expand All @@ -9,4 +9,8 @@ push dhcp-option <%= option %>
<% end -%>
<% if @redirect_gateway -%>
push redirect-gateway def1
<% end %>
<% end -%>
<% scope.lookupvar('route').each do |route| -%>
push "route <%= route %>"
<% end -%>