Skip to content

Commit

Permalink
Merge pull request #93 from luxflux/fix-linting-errors
Browse files Browse the repository at this point in the history
fix a lot of the linting warnings
  • Loading branch information
luxflux committed Sep 8, 2014
2 parents 67a87f6 + b3d8007 commit a71b0b2
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 136 deletions.
107 changes: 57 additions & 50 deletions manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
# Options: Integer or infinite
#
# [*auth_retry*]
# String. Controls how OpenVPN responds to username/password verification errors such
# as the client-side response to an AUTH_FAILED message from the server or verification
# failure of the private key password.
# String. Controls how OpenVPN responds to username/password verification
# errors such as the client-side response to an AUTH_FAILED message from
# the server or verification failure of the private key password.
# Default: none
# Options: 'none' or 'nointeract' or 'interact'
#
Expand All @@ -88,10 +88,11 @@
# Default: {}
#
# [*setenv_safe*]
# Hash. Set a custom environmental variable OPENVPN_name=value to pass to script.
# This directive is designed to be pushed by the server to clients, and the prepending
# of "OPENVPN_" to the environmental variable is a safety precaution to prevent a LD_PRELOAD
# style attack from a malicious or compromised server.
# Hash. Set a custom environmental variable OPENVPN_name=value to pass to
# script. This directive is designed to be pushed by the server to clients,
# and the prepending of "OPENVPN_" to the environmental variable is a
# safety precaution to prevent a LD_PRELOAD style attack from a malicious
# or compromised server.
# Default: {}
#
# [*up*]
Expand Down Expand Up @@ -173,57 +174,63 @@
provider => 'shell';
}

file {
[ "/etc/openvpn/${server}/download-configs/${name}",
"/etc/openvpn/${server}/download-configs/${name}/keys"]:
ensure => directory;
file { "/etc/openvpn/${server}/download-configs/${name}":
ensure => directory,
}

file { "/etc/openvpn/${server}/download-configs/${name}/keys":
ensure => directory,
}

"/etc/openvpn/${server}/download-configs/${name}/keys/${name}.crt":
ensure => link,
target => "/etc/openvpn/${server}/easy-rsa/keys/${name}.crt",
require => Exec["generate certificate for ${name} in context of ${server}"];
file { "/etc/openvpn/${server}/download-configs/${name}/keys/${name}.crt":
ensure => link,
target => "/etc/openvpn/${server}/easy-rsa/keys/${name}.crt",
require => Exec["generate certificate for ${name} in context of ${server}"],
}

"/etc/openvpn/${server}/download-configs/${name}/keys/${name}.key":
ensure => link,
target => "/etc/openvpn/${server}/easy-rsa/keys/${name}.key",
require => Exec["generate certificate for ${name} in context of ${server}"];
file { "/etc/openvpn/${server}/download-configs/${name}/keys/${name}.key":
ensure => link,
target => "/etc/openvpn/${server}/easy-rsa/keys/${name}.key",
require => Exec["generate certificate for ${name} in context of ${server}"],
}

"/etc/openvpn/${server}/download-configs/${name}/keys/ca.crt":
ensure => link,
target => "/etc/openvpn/${server}/easy-rsa/keys/ca.crt",
require => Exec["generate certificate for ${name} in context of ${server}"];
file { "/etc/openvpn/${server}/download-configs/${name}/keys/ca.crt":
ensure => link,
target => "/etc/openvpn/${server}/easy-rsa/keys/ca.crt",
require => Exec["generate certificate for ${name} in context of ${server}"],
}

"/etc/openvpn/${server}/download-configs/${name}/${name}.conf":
owner => root,
group => root,
mode => '0444',
content => template('openvpn/client.erb'),
notify => Exec["tar the thing ${server} with ${name}"];
file { "/etc/openvpn/${server}/download-configs/${name}/${name}.conf":
owner => root,
group => root,
mode => '0444',
content => template('openvpn/client.erb'),
notify => Exec["tar the thing ${server} with ${name}"],
}

exec {
"tar the thing ${server} with ${name}":
cwd => "/etc/openvpn/${server}/download-configs/",
command => "/bin/rm ${name}.tar.gz; tar --exclude=\\*.conf.d -chzvf ${name}.tar.gz ${name}",
refreshonly => true,
require => [ File["/etc/openvpn/${server}/download-configs/${name}/${name}.conf"],
File["/etc/openvpn/${server}/download-configs/${name}/keys/ca.crt"],
File["/etc/openvpn/${server}/download-configs/${name}/keys/${name}.key"],
File["/etc/openvpn/${server}/download-configs/${name}/keys/${name}.crt"]
],
notify => Exec["generate ${name}.ovpn in ${server}"];
exec { "tar the thing ${server} with ${name}":
cwd => "/etc/openvpn/${server}/download-configs/",
command => "/bin/rm ${name}.tar.gz; tar --exclude=\\*.conf.d -chzvf ${name}.tar.gz ${name}",
refreshonly => true,
require => [
File["/etc/openvpn/${server}/download-configs/${name}/${name}.conf"],
File["/etc/openvpn/${server}/download-configs/${name}/keys/ca.crt"],
File["/etc/openvpn/${server}/download-configs/${name}/keys/${name}.key"],
File["/etc/openvpn/${server}/download-configs/${name}/keys/${name}.crt"]
],
notify => Exec["generate ${name}.ovpn in ${server}"],
}

exec {
"generate ${name}.ovpn in ${server}":
cwd => "/etc/openvpn/${server}/download-configs/",
command => "/bin/rm ${name}.ovpn; cat ${name}/${name}.conf|perl -lne 'if(m|^ca keys/ca.crt|){ chomp(\$ca=`cat ${name}/keys/ca.crt`); print \"<ca>\n\$ca\n</ca>\"} elsif(m|^cert keys/${name}.crt|) { chomp(\$crt=`cat ${name}/keys/${name}.crt`); print \"<cert>\n\$crt\n</cert>\"} elsif(m|^key keys/${name}.key|){ chomp(\$key=`cat ${name}/keys/${name}.key`); print \"<key>\n\$key\n</key>\"} else { print} ' > ${name}.ovpn",
refreshonly => true,
require => [ File["/etc/openvpn/${server}/download-configs/${name}/${name}.conf"],
File["/etc/openvpn/${server}/download-configs/${name}/keys/ca.crt"],
File["/etc/openvpn/${server}/download-configs/${name}/keys/${name}.key"],
File["/etc/openvpn/${server}/download-configs/${name}/keys/${name}.crt"],
],
exec { "generate ${name}.ovpn in ${server}":
cwd => "/etc/openvpn/${server}/download-configs/",
command => "/bin/rm ${name}.ovpn; cat ${name}/${name}.conf | perl -lne 'if(m|^ca keys/ca.crt|){ chomp(\$ca=`cat ${name}/keys/ca.crt`); print \"<ca>\n\$ca\n</ca>\"} elsif(m|^cert keys/${name}.crt|) { chomp(\$crt=`cat ${name}/keys/${name}.crt`); print \"<cert>\n\$crt\n</cert>\"} elsif(m|^key keys/${name}.key|){ chomp(\$key=`cat ${name}/keys/${name}.key`); print \"<key>\n\$key\n</key>\"} else { print} ' > ${name}.ovpn",
refreshonly => true,
require => [
File["/etc/openvpn/${server}/download-configs/${name}/${name}.conf"],
File["/etc/openvpn/${server}/download-configs/${name}/keys/ca.crt"],
File["/etc/openvpn/${server}/download-configs/${name}/keys/${name}.key"],
File["/etc/openvpn/${server}/download-configs/${name}/keys/${name}.crt"],
],
}

file { "/etc/openvpn/${server}/download-configs/${name}.ovpn":
Expand Down
14 changes: 10 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

case $::osfamily {
'RedHat': {
if($::operatingsystemmajrelease >= 6) { # Redhat/Centos >= 6
# Redhat/Centos >= 6
if($::operatingsystemmajrelease >= 6) {
# http://docs.puppetlabs.com/references/latest/function.html#versioncmp
if(versioncmp($::operatingsystemrelease, '6.4') < 0) { # Version < 6.4
$easyrsa_source = '/usr/share/openvpn/easy-rsa/2.0'
Expand All @@ -39,7 +40,8 @@
'Debian': { # Debian/Ubuntu
case $::lsbdistid {
'Debian': {
if(versioncmp($::lsbdistrelease, '8.0.0') >= 0) { # Version > 8.0.0, jessie
# Version > 8.0.0, jessie
if(versioncmp($::lsbdistrelease, '8.0.0') >= 0) {
$additional_packages = ['easy-rsa', 'openvpn-auth-ldap']
$easyrsa_source = '/usr/share/easy-rsa/'
$ldap_auth_plugin_location = '/usr/lib/openvpn/openvpn-auth-ldap.so'
Expand All @@ -48,18 +50,22 @@
}
}
'Ubuntu': {
if(versioncmp($::lsbdistrelease, '13.10') >= 0) { # Version > 13.10, saucy
# Version > 13.10, saucy
if(versioncmp($::lsbdistrelease, '13.10') >= 0) {
$additional_packages = ['easy-rsa', 'openvpn-auth-ldap']
$easyrsa_source = '/usr/share/easy-rsa/'
$ldap_auth_plugin_location = '/usr/lib/openvpn/openvpn-auth-ldap.so'
} else {
$easyrsa_source = '/usr/share/doc/openvpn/examples/easy-rsa/2.0'
}
}
default: {
fail("Not supported OS / Distribution: ${::osfamily}/${::lsbdistid}")
}
}
}
default: {
fail("Not supported OS family ${osfamily}")
fail("Not supported OS family ${::osfamily}")
}
}

Expand Down
21 changes: 10 additions & 11 deletions manifests/revoke.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# == Define: openvpn::revoke
#
# This define creates a revocation on a certificate for a specified openvpn server.
# This define creates a revocation on a certificate for a specified openvpn
# server.
#
# === Parameters
#
Expand All @@ -11,7 +12,8 @@
# === Note
#
# In order for a certificate to be revoked, it must exist first.
# You cannot declare a revoked certificate that has not been created by the module.
# You cannot declare a revoked certificate that has not been created by the
# module.
#
# === Examples
#
Expand Down Expand Up @@ -45,21 +47,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
define openvpn::revoke(
$server
) {
define openvpn::revoke($server) {

Openvpn::Server[$server] ->
Openvpn::Revoke[$name]

Openvpn::Client[$name] ->
Openvpn::Revoke[$name]

exec {
"revoke certificate for ${name} in context of ${server}":
command => ". ./vars && ./revoke-full ${name} ; test $? -eq 2 && touch revoked/${name}",
cwd => "/etc/openvpn/${server}/easy-rsa",
creates => "/etc/openvpn/${server}/easy-rsa/revoked/${name}",
provider => 'shell';
exec { "revoke certificate for ${name} in context of ${server}":
command => ". ./vars && ./revoke-full ${name} ; test $? -eq 2 && touch revoked/${name}",
cwd => "/etc/openvpn/${server}/easy-rsa",
creates => "/etc/openvpn/${server}/easy-rsa/revoked/${name}",
provider => 'shell';
}
}
Loading

0 comments on commit a71b0b2

Please sign in to comment.