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

feature: Add possibilty to not manage the openvpn service with puppet. #158

Merged
merged 1 commit into from
May 19, 2015
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
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# [*autostart_all*]
# Boolean. Wether the openvpn instances should be started automatically on boot.
# Default: true
# [*manage_service*]
# Boolean. Wether the openvpn service should be managed by puppet.
# Default: true
#
#
# === Examples
Expand Down Expand Up @@ -41,6 +44,7 @@
#
class openvpn(
$autostart_all = true,
$manage_service = true,
) {

class { 'openvpn::params': } ->
Expand Down
25 changes: 16 additions & 9 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -438,11 +438,16 @@
Class['openvpn::install'] ->
Openvpn::Server[$name]

if $::openvpn::params::systemd {
$lnotify = Service["openvpn@${name}"]
} else {
$lnotify = Service['openvpn']
Openvpn::Server[$name] -> Service['openvpn']
if $::openvpn::manage_service {
if $::openvpn::params::systemd {
$lnotify = Service["openvpn@${name}"]
} else {
$lnotify = Service['openvpn']
Openvpn::Server[$name] -> Service['openvpn']
}
}
else {
$lnotify = undef
}

# Selection block to enable or disable tls-server flag
Expand Down Expand Up @@ -559,10 +564,12 @@
}

if $::openvpn::params::systemd {
service { "openvpn@${name}":
ensure => running,
enable => true,
require => [ File["/etc/openvpn/${name}.conf"], Openvpn::Ca[$ca_name] ]
if $::openvpn::manage_service {
service { "openvpn@${name}":
ensure => running,
enable => true,
require => [ File["/etc/openvpn/${name}.conf"], Openvpn::Ca[$ca_name] ]
}
}
}

Expand Down
12 changes: 7 additions & 5 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
# limitations under the License.
#
class openvpn::service {
service { 'openvpn':
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true,
if $::openvpn::manage_service {
service { 'openvpn':
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true,
}
}
}
9 changes: 8 additions & 1 deletion spec/classes/openvpn_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

describe 'openvpn::service', :type => :class do

let (:facts) { { :concat_basedir => '/var/lib/puppet/concat' } }
let (:pre_condition) { 'class { "openvpn": manage_service => true }' }
let (:facts) do
{
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:concat_basedir => '/var/lib/puppet/concat',
}
end

it { should create_class('openvpn::service') }
it { should contain_service('openvpn').with(
Expand Down