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

Fix autostart_all behaviour (replaces #160) #163

Merged
merged 6 commits into from
May 12, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Support to send ipv6 routes ([#153](https://github.com/luxflux/puppet-openvpn/pull/153), [#154](https://github.com/luxflux/puppet-openvpn/pull/154))
* Support for `nobind` param for server in client mode ([#156](https://github.com/luxflux/puppet-openvpn/pull/156))
* Fixing autostart_all behaviour ([#163](https://github.com/luxflux/puppet-openvpn/pull/163))

## 2.8.0

Expand Down
2 changes: 1 addition & 1 deletion manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@
}
}

if ($::osfamily == 'Debian' and $::openvpn::autostart_all) or $autostart {
if $::osfamily == 'Debian' and !$::openvpn::autostart_all and $autostart {
concat::fragment { "openvpn.default.autostart.${name}":
content => "AUTOSTART=\"\$AUTOSTART ${name}\"\n",
target => '/etc/default/openvpn',
Expand Down
20 changes: 19 additions & 1 deletion spec/classes/openvpn_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,28 @@
it { should create_class('openvpn::config') }

context "on Debian based machines" do
let (:facts) { { :osfamily => 'Debian', :concat_basedir => '/var/lib/puppet/concat' } }
let (:facts) { {
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:concat_basedir => '/var/lib/puppet/concat'
} }

it { should contain_concat('/etc/default/openvpn') }
it { should contain_concat__fragment('openvpn.default.header') }

context "enabled autostart_all" do
let(:pre_condition) { 'class { "openvpn": autostart_all => true }' }
it { should contain_concat__fragment('openvpn.default.header').with(
'content' => /^AUTOSTART="all"/
)}
end

context "disabled autostart_all" do
let(:pre_condition) { 'class { "openvpn": autostart_all => false }' }
it { should contain_concat__fragment('openvpn.default.header').with(
'content' => /^AUTOSTART=""/
)}
end
end

end
14 changes: 6 additions & 8 deletions spec/defines/openvpn_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,25 +364,23 @@
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^group\s+nogroup$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^plugin /usr/lib/openvpn/openvpn-auth-pam.so login$}) }

context 'enabled autostart' do
context 'enabled autostart_all' 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'
)}
it { should_not contain_concat__fragment('openvpn.default.autostart.test_server') }
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') }
it { should contain_concat__fragment('openvpn.default.autostart.test_server').with(
'content' => "AUTOSTART=\"$AUTOSTART test_server\"\n",
'target' => '/etc/default/openvpn'
)}
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions templates/etc-default-openvpn.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@
#STATUSREFRESH=0
# Optional arguments to openvpn's command line
OPTARGS=""
<% if scope.lookupvar('::openvpn::autostart_all') -%>
AUTOSTART="all"
<% else -%>
AUTOSTART=""
<% end -%>