Skip to content

Commit

Permalink
Merge pull request #69 from luxflux/Philio-common_name
Browse files Browse the repository at this point in the history
Common Name for the server, fixes #65
  • Loading branch information
luxflux committed May 10, 2014
2 parents 0531030 + 0a66efc commit ddf426c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
9 changes: 7 additions & 2 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
# [*email*]
# String. Email address to be used for the SSL certificate
#
# [*common_name*]
# String. Common name to be used for the SSL certificate
# Default: server
#
# [*compression*]
# String. Which compression algorithim to use
# Default: comp-lzo
Expand Down Expand Up @@ -236,6 +240,7 @@
$city,
$organization,
$email,
$common_name = 'server',
$compression = 'comp-lzo',
$dev = 'tun0',
$user = 'nobody',
Expand Down Expand Up @@ -359,9 +364,9 @@
File["/etc/openvpn/${name}/easy-rsa/openssl.cnf"] ];

"generate server cert ${name}":
command => '. ./vars && ./pkitool --server server',
command => ". ./vars && ./pkitool --server ${common_name}",
cwd => "/etc/openvpn/${name}/easy-rsa",
creates => "/etc/openvpn/${name}/easy-rsa/keys/server.key",
creates => "/etc/openvpn/${name}/easy-rsa/keys/${common_name}.key",
provider => 'shell',
require => Exec["initca ${name}"];
}
Expand Down
15 changes: 8 additions & 7 deletions spec/defines/openvpn_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
'management' => true,
'management_ip' => '1.3.3.7',
'management_port' => 1337,
'common_name' => 'mylittlepony',
} }

let(:facts) { {
Expand All @@ -105,19 +106,19 @@
} }

it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^mode\s+server$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^client\-config\-dir\s+\/etc\/openvpn\/test_server\/client\-configs$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^ca\s+\/etc\/openvpn\/test_server\/keys\/ca.crt$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^cert\s+\/etc\/openvpn\/test_server\/keys\/server.crt$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^key\s+\/etc\/openvpn\/test_server\/keys\/server.key$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^dh\s+\/etc\/openvpn\/test_server\/keys\/dh2048.pem$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^client-config-dir\s+/etc/openvpn/test_server/client-configs$}) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^ca\s+/etc/openvpn/test_server/keys/ca.crt$}) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^cert\s+/etc/openvpn/test_server/keys/mylittlepony.crt$}) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^key\s+/etc/openvpn/test_server/keys/mylittlepony.key$}) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^dh\s+/etc/openvpn/test_server/keys/dh2048.pem$}) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^proto\s+udp$/) }
it { should_not contain_file('/etc/openvpn/test_server.conf').with_content(/^proto\s+tls-server$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^port\s+123$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^fake_compression$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^group\s+someone$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^user\s+someone$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^log\-append\s+\/var\/log\/openvpn\/test_server\.log$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^status\s+\/var\/log\/openvpn\/test_server_status\.log$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^log\-append\s+/var/log/openvpn/test_server\.log$}) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^status\s+/var/log/openvpn/test_server_status\.log$}) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^dev\s+tun1$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^local\s+2\.3\.4\.5$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^server\s+2\.3\.4\.0\s+255\.255\.0\.0$/) }
Expand Down
4 changes: 2 additions & 2 deletions templates/server.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
mode server
client-config-dir /etc/openvpn/<%= scope.lookupvar('name') %>/client-configs
ca /etc/openvpn/<%= scope.lookupvar('name') %>/keys/ca.crt
cert /etc/openvpn/<%= scope.lookupvar('name') %>/keys/server.crt
key /etc/openvpn/<%= scope.lookupvar('name') %>/keys/server.key
cert /etc/openvpn/<%= scope.lookupvar('name') %>/keys/<%= scope.lookupvar('common_name') %>.crt
key /etc/openvpn/<%= scope.lookupvar('name') %>/keys/<%= scope.lookupvar('common_name') %>.key
dh /etc/openvpn/<%= scope.lookupvar('name') %>/keys/dh<%= scope.lookupvar('ssl_key_size') %>.pem
crl-verify /etc/openvpn/<%= scope.lookupvar('name') %>/crl.pem
<% if scope.lookupvar('proto') == 'tcp' -%>
Expand Down

0 comments on commit ddf426c

Please sign in to comment.