-
Notifications
You must be signed in to change notification settings - Fork 112
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
Added support to modify service startup #130
Merged
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7fb92df
Addded a bind startup feature
Cicco0 4aa176b
Add rspec testing files
Cicco0 1dbba3d
Merge branch 'feature/startup' into feature/service-startup
Cicco0 3844d0b
Fix rspec files
Cicco0 ad4c1a9
Renaming from startup to default and documentation fix
Cicco0 bf7c6b8
Merge branch 'master' into feature/service-startup
Cicco0 007c610
Move dns::server::default from init.pp to install.pp
Cicco0 51d5b90
Include Dns::Server::Default in config.pp
Cicco0 4674d5c
Remove wrong include in install.pp
Cicco0 15adc46
Remove space from Template
Cicco0 a026357
Merge remote-tracking branch 'upstream/master' into feature/service-s…
Cicco0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ | |
# include dns::install | ||
# include dns::config | ||
# include dns::service | ||
include dns::server::default | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# == Class: dns::server::default | ||
# | ||
class dns::server::default ( | ||
|
||
$default_file = $dns::server::params::default_file, | ||
$default_template = $dns::server::params::default_template, | ||
|
||
$resolvconf = undef, | ||
$options = undef, | ||
$rootdir = undef, | ||
$enable_zone_write = undef, | ||
$enable_sdb = undef, | ||
$disable_named_dbus = undef, | ||
$keytab_file = undef, | ||
$disable_zone_checking = undef, | ||
|
||
) inherits dns::server::params { | ||
|
||
if ! defined(Class['::dns::server']) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is incorrect now, this class should be safe to include no matter what |
||
fail('You must include the ::dns::server base class before using any dns default defined resources') | ||
} | ||
|
||
validate_absolute_path( $default_file ) | ||
|
||
if $resolvconf != '' { | ||
validate_re( $resolvconf, '^(yes|no)$', 'The resolvconf value is not type of a string yes / no.' ) | ||
} | ||
|
||
if $rootdir != '' { | ||
validate_absolute_path( $rootdir ) | ||
} | ||
|
||
validate_re( $enable_zone_write, '^(yes|no|\s*)$', 'The enable_zone_write value is not type of a string yes / no or empty.' ) | ||
|
||
validate_re( $enable_sdb, '^(yes|no|1|0|\s*)$', 'The enable_sdb value is not type of a string yes / no / 1 / 0 or empty.' ) | ||
|
||
if $keytab_file != '' { | ||
validate_absolute_path( $keytab_file ) | ||
} | ||
|
||
validate_re( $disable_zone_checking, '^(yes|no|\s*)$', 'The disable_zone_checking value is not type of a string yes / no or empty.' ) | ||
|
||
file { $default_file: | ||
ensure => present, | ||
owner => $::dns::server::params::owner, | ||
group => $::dns::server::params::group, | ||
mode => '0644', | ||
content => template("${module_name}/${default_template}"), | ||
notify => Class['dns::server::service'], | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
require 'spec_helper' | ||
|
||
describe 'dns::server::default', :type => :type do | ||
|
||
let :pre_condition do | ||
'class { "::dns::server": }' | ||
end | ||
|
||
context "on an unsupported OS" do | ||
it{ should raise_error(/dns::server is incompatible with this osfamily/) } | ||
end | ||
|
||
context 'by default on debian' do | ||
|
||
let(:facts) {{ :osfamily => 'Debian', :concat_basedir => '/tmp' }} | ||
|
||
context "passing correct values and paths" do | ||
|
||
context 'passing `no` to resolvconf' do | ||
let(:params) {{ :resolvconf => 'no' }} | ||
it { should contain_file('/etc/default/bind9').with_content(/RESOLVCONF=no/) } | ||
end | ||
|
||
context 'passing `yes` to resolvconf' do | ||
let(:params) {{ :resolvconf => 'yes' }} | ||
it { should contain_file('/etc/default/bind9').with_content(/RESOLVCONF=yes/) } | ||
end | ||
|
||
context 'passing `-u bind -4` to options' do | ||
let(:params) {{ :options => '-u bind -4' }} | ||
it { should contain_file('/etc/default/bind9').with_content(/OPTIONS="-u bind -4"/) } | ||
end | ||
|
||
context 'passing `-u bind -6` to options' do | ||
let(:params) {{ :options => '-u bind -6' }} | ||
it { should contain_file('/etc/default/bind9').with_content(/OPTIONS="-u bind -6"/) } | ||
end | ||
|
||
end | ||
|
||
context "passing wrong values and paths" do | ||
|
||
context 'passing wrong value to resolvconf for hit an error' do | ||
let(:params) {{ :resolvconf => 'WrongValue' }} | ||
it{ should raise_error(/The resolvconf value is not type of a string yes \/ no./)} | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
context 'by default on redhat' do | ||
|
||
let(:facts) {{ :osfamily => 'RedHat', :concat_basedir => '/tmp' }} | ||
|
||
context "passing correct values and paths" do | ||
|
||
context 'passing path `/chroot` to rootdir' do | ||
let(:params) {{ :rootdir => '/chroot' }} | ||
it { should contain_file('/etc/sysconfig/named').with_content(/ROOTDIR="\/chroot"/) } | ||
end | ||
|
||
context 'passing `-u named` to options' do | ||
let(:params) {{ :options => '-u named' }} | ||
it { should contain_file('/etc/sysconfig/named').with_content(/OPTIONS="-u named"/) } | ||
end | ||
|
||
context 'passing `yes` to enable_zone_write' do | ||
let(:params) {{ :enable_zone_write => 'yes' }} | ||
it { should contain_file('/etc/sysconfig/named').with_content(/ENABLE_ZONE_WRITE=yes/) } | ||
end | ||
|
||
context 'passing `no` to enable_zone_write' do | ||
let(:params) {{ :enable_zone_write => 'no' }} | ||
it { should contain_file('/etc/sysconfig/named').with_content(/ENABLE_ZONE_WRITE=no/) } | ||
end | ||
|
||
context 'passing `yes` to enable_sdb' do | ||
let(:params) {{ :enable_sdb => 'yes' }} | ||
it { should contain_file('/etc/sysconfig/named').with_content(/ENABLE_SDB=yes/) } | ||
end | ||
|
||
context 'passing `no` to enable_sdb' do | ||
let(:params) {{ :enable_sdb => 'no' }} | ||
it { should contain_file('/etc/sysconfig/named').with_content(/ENABLE_SDB=no/) } | ||
end | ||
|
||
context 'passing `1` to enable_sdb' do | ||
let(:params) {{ :enable_sdb => '1' }} | ||
it { should contain_file('/etc/sysconfig/named').with_content(/ENABLE_SDB=1/) } | ||
end | ||
|
||
context 'passing `0` to enable_sdb' do | ||
let(:params) {{ :enable_sdb => '0' }} | ||
it { should contain_file('/etc/sysconfig/named').with_content(/ENABLE_SDB=0/) } | ||
end | ||
|
||
context 'passing `yes` to disable_named_dbus' do | ||
let(:params) {{ :disable_named_dbus => 'yes' }} | ||
it { should contain_file('/etc/sysconfig/named').with_content(/DISABLE_NAMED_DBUS=yes/) } | ||
end | ||
|
||
context 'passing `no` to disable_named_dbus' do | ||
let(:params) {{ :disable_named_dbus => 'no' }} | ||
it { should contain_file('/etc/sysconfig/named').with_content(/DISABLE_NAMED_DBUS=no/) } | ||
end | ||
|
||
context 'passing path `/usr/local/samba/private/dns.keytab` to keytab_file' do | ||
let(:params) {{ :keytab_file => '/usr/local/samba/private/dns.keytab' }} | ||
it { should contain_file('/etc/sysconfig/named').with_content(/KEYTAB_FILE="\/usr\/local\/samba\/private\/dns.keytab/) } | ||
end | ||
|
||
context 'passing `yes` to disable_zone_checking' do | ||
let(:params) {{ :disable_zone_checking => 'yes' }} | ||
it { should contain_file('/etc/sysconfig/named').with_content(/DISABLE_ZONE_CHECKING=yes/) } | ||
end | ||
|
||
context 'passing `no` to disable_zone_checking' do | ||
let(:params) {{ :disable_zone_checking => 'no' }} | ||
it { should contain_file('/etc/sysconfig/named').with_content(/DISABLE_ZONE_CHECKING=no/) } | ||
end | ||
|
||
end | ||
|
||
context "passing wrong values and paths" do | ||
|
||
context 'passing wrong value to rootdir for hit an error' do | ||
let(:params) {{ :rootdir => 'chroot' }} | ||
it{ should raise_error(/"chroot" is not an absolute path./)} | ||
end | ||
|
||
context 'passing wrong value to enable_zone_write for hit an error' do | ||
let(:params) {{ :enable_zone_write => 'WrongValue' }} | ||
it{ should raise_error(/The enable_zone_write value is not type of a string yes \/ no./)} | ||
end | ||
|
||
context 'passing wrong value to enable_sdb for hit an error' do | ||
let(:params) {{ :enable_sdb => 'WrongValue' }} | ||
it{ should raise_error(/The enable_sdb value is not type of a string yes \/ no \/ 1 \/ 0 or empty./)} | ||
end | ||
|
||
context 'passing wrong value to keytab_file for hit an error' do | ||
let(:params) {{ :keytab_file => 'usr/local/samba/private/dns.keytab' }} | ||
it{ should raise_error(/"usr\/local\/samba\/private\/dns.keytab" is not an absolute path./)} | ||
end | ||
|
||
context 'passing wrong value to disable_zone_checking for hit an error' do | ||
let(:params) {{ :disable_zone_checking => 'chroot' }} | ||
it{ should raise_error(/The disable_zone_checking value is not type of a string yes \/ no or empty./)} | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# run resolvconf? | ||
<% if @resolvconf -%> | ||
RESOLVCONF=<%= @resolvconf %> | ||
<% else %> | ||
RESOLVCONF= no | ||
<% end -%> | ||
|
||
# startup options for the server | ||
<% if @options -%> | ||
OPTIONS="<%= @options %>" | ||
<% else %> | ||
OPTIONS="-u bind" | ||
<% end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# BIND named process options | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Currently, you can use the following options: | ||
# | ||
# ROOTDIR="/some/where" -- will run named in a chroot environment. | ||
# you must set up the chroot environment | ||
# (install the bind-chroot package) before | ||
# doing this. | ||
# | ||
# OPTIONS="whatever" -- These additional options will be passed to named | ||
# at startup. Don't add -t here, use ROOTDIR instead. | ||
# | ||
# ENABLE_ZONE_WRITE=yes -- If SELinux is disabled, then allow named to write | ||
# its zone files and create files in its $ROOTDIR/var/named | ||
# directory, necessary for DDNS and slave zone transfers. | ||
# Slave zones should reside in the $ROOTDIR/var/named/slaves | ||
# directory, in which case you would not need to enable zone | ||
# writes. If SELinux is enabled, you must use only the | ||
# 'named_write_master_zones' variable to enable zone writes. | ||
# | ||
# ENABLE_SDB=yes -- This enables use of 'named_sdb', which has support | ||
# -- for the ldap, pgsql and dir zone database backends | ||
# -- compiled in, to be used instead of named. | ||
# | ||
# DISABLE_NAMED_DBUS=[1y]-- If NetworkManager is enabled in any runlevel, then | ||
# the initscript will by default enable named's D-BUS | ||
# support with the named -D option. This setting disables | ||
# this behavior. | ||
# | ||
# KEYTAB_FILE="/dir/file" -- Specify named service keytab file (for GSS-TSIG) | ||
# | ||
# DISABLE_ZONE_CHECKING -- By default, initscript calls named-checkzone | ||
# utility for every zone to ensure all zones are | ||
# valid before named starts. If you set this option | ||
# to 'yes' then initscript doesn't perform those checks. | ||
<% if @rootdir -%> | ||
ROOTDIR="<%= @rootdir %>" | ||
<% end -%> | ||
|
||
<% if @options -%> | ||
OPTIONS="<%= @options %>" | ||
<% end -%> | ||
|
||
<% if @enable_zone_write -%> | ||
ENABLE_ZONE_WRITE=<%= @enable_zone_write %> | ||
<% end -%> | ||
|
||
<% if @enable_sdb -%> | ||
ENABLE_SDB=<%= @enable_sdb %> | ||
<% end -%> | ||
|
||
<% if @disable_named_dbus -%> | ||
DISABLE_NAMED_DBUS=<%= @disable_named_dbus %> | ||
<% end -%> | ||
|
||
<% if @keytab_file -%> | ||
KEYTAB_FILE="<%= @keytab_file %>" | ||
<% end -%> | ||
|
||
<% if @disable_zone_checking -%> | ||
DISABLE_ZONE_CHECKING=<%= @disable_zone_checking %> | ||
<% end -%> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be in dns::server::install? Seems out of place here