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

Support to manage AUTOSTART on Debian/Ubuntu #144

Merged
merged 3 commits into from
Mar 8, 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
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ group :unit_tests do
gem 'puppet-lint', '1.0.1', :require => false
gem 'puppet-syntax', :require => false
gem 'metadata-json-lint', :require => false
# gem 'json', :require => false
end

group :development do
Expand All @@ -19,4 +18,4 @@ if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
end
15 changes: 12 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
# This module installs the openvpn service, configures vpn endpoints, generates
# client certificates, and generates client config files
#
# === Parameters
#
# [*autostart_all*]
# Boolean. Wether the openvpn instances should be started automatically on boot.
# Default: true
#
#
# === Examples
#
# * Installation:
# class { 'openvpn': }
# class { 'openvpn':
# autostart_all => true,
# }
#
#
# === Authors
Expand All @@ -32,7 +39,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
class openvpn {
class openvpn(
$autostart_all = true,
) {

class { 'openvpn::params': } ->
class { 'openvpn::install': } ->
Expand Down
7 changes: 6 additions & 1 deletion manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@
# String. Name of a openssl::ca resource to use config with
# Default: undef
#
# [*autostart*]
# Boolean. Enable autostart for this server if openvpn::autostart_all is false.
# Default: undef
#
# === Examples
#
# openvpn::client {
Expand Down Expand Up @@ -401,6 +405,7 @@
$sndbuf = undef,
$rcvbuf = undef,
$shared_ca = undef,
$autostart = undef,
) {

include openvpn
Expand Down Expand Up @@ -495,7 +500,7 @@
}
}

if $::osfamily == 'Debian' {
if ($::osfamily == 'Debian' and $::openvpn::autostart_all) or $autostart {
concat::fragment { "openvpn.default.autostart.${name}":
content => "AUTOSTART=\"\$AUTOSTART ${name}\"\n",
target => '/etc/default/openvpn',
Expand Down
29 changes: 22 additions & 7 deletions spec/defines/openvpn_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,29 @@

let(:facts) { { :osfamily => 'Debian', :operatingsystem => 'Debian', :concat_basedir => '/var/lib/puppet/concat' } }

# Configure to start vpn session
it { should contain_concat__fragment('openvpn.default.autostart.test_server').with(
'content' => "AUTOSTART=\"$AUTOSTART test_server\"\n",
'target' => '/etc/default/openvpn'
)}

it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^group\s+nogroup$/) }

context 'enabled autostart' do
let(:pre_condition) { 'class { "openvpn": autostart_all => true }' }

# Configure to start vpn session
it { should contain_concat__fragment('openvpn.default.autostart.test_server').with(
'content' => "AUTOSTART=\"$AUTOSTART test_server\"\n",
'target' => '/etc/default/openvpn'
)}
end

context 'disabled autostart_all' do
let(:pre_condition) { 'class { "openvpn": autostart_all => false }' }

# Configure to start vpn session
it { should_not contain_concat__fragment('openvpn.default.autostart.test_server') }

context 'but machine has autostart' do
before { params['autostart'] = true }
it { should contain_concat__fragment('openvpn.default.autostart.test_server') }
end
end
end

context 'ldap' do
Expand Down Expand Up @@ -427,5 +443,4 @@
:enable => true,
)}
end

end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require 'rubygems'
require 'bundler/setup'
require 'puppetlabs_spec_helper/module_spec_helper'