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 for dns_alt_names #95

Open
wants to merge 1 commit into
base: production
Choose a base branch
from
Open
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ The `puppet::config` class is responsible for altering the configuration of `$co

The version of the deep_merge package to install.

* **dns_alt_names**: (*array* Default: `undef`)

An array of alternative DNS names to use for the local host.

* **env_owner**: (*string* Default: `puppet`)

The user which should own hieradata and r10k repos
Expand Down
4 changes: 4 additions & 0 deletions manifests/master.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# The base directory path to have environments checked out into.
# @param deep_merge_version ([String] Default: 'installed')
# The version of the deep_merge package to install.
# @param dns_alt_names ([Array] Default: empty)
# An array of alternative DNS names to use for the local host
# @param env_owner [String] Default: 'puppet'
# The user which should own hieradata and r10k repos
# @param environmentpath (*absolute path* Default Puppet 4: ${codedir}/modules:${confdir}/modules Default Puppet 3: ${confdir}/modules:/usr/share/puppet/modules)
Expand Down Expand Up @@ -90,6 +92,7 @@
$autosign_method = 'file',
$basemodulepath = $::puppet::defaults::basemodulepath,
$deep_merge_version = 'installed',
$dns_alt_names = [],
$env_owner = 'puppet',
$environmentpath = $::puppet::defaults::environmentpath,
$environment_timeout = '0',
Expand Down Expand Up @@ -135,6 +138,7 @@
$hieradata_path,
)
validate_array(
$dns_alt_names,
$hiera_hierarchy,
)

Expand Down
25 changes: 25 additions & 0 deletions manifests/master/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$codedir = $::puppet::defaults::codedir
$reports_dir = $::puppet::defaults::reports_dir
$ca_server = $::puppet::ca_server
$dns_alt_names = $::puppet::master::dns_alt_names
$autosign_method = $::puppet::master::autosign_method
$autosign_file = $::puppet::master::autosign_file
$autosign_domains = $::puppet::master::autosign_domains
Expand Down Expand Up @@ -129,4 +130,28 @@
}
}

if (! empty($dns_alt_names) ) {

# need it as a string
$_dns_alt_names = join($dns_alt_names, ',')

# enable dns_alt_names
ini_setting { 'master dns_alt_names':
ensure => present,
path => "${confdir}/puppet.conf",
section => 'main',
setting => 'dns_alt_names',
value => $_dns_alt_names,
}
} else {
# disable dns_alt_names
ini_setting { 'master dns_alt_names':
ensure => absent,
path => "${confdir}/puppet.conf",
section => 'main',
setting => 'dns_alt_names',
value => $_dns_alt_names,
}
}

}
4 changes: 4 additions & 0 deletions manifests/profile/master.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# The base directory path to have environments checked out into.
# @param deep_merge_version ([String] Default: 'installed')
# The version of the deep_merge package to install.
# @param dns_alt_names ([Array] Default: empty)
# An array of alternative DNS names to use for the local host
# @param env_owner [String] Default: 'puppet'
# The user which should own hieradata and r10k repos
# @param environmentpath (*absolute path* Default Puppet 4: ${codedir}/modules:${confdir}/modules Default Puppet 3: ${confdir}/modules:/usr/share/puppet/modules)
Expand Down Expand Up @@ -111,6 +113,7 @@
$autosign_method = 'file',
$basemodulepath = undef,
$deep_merge_version = 'installed',
$dns_alt_names = undef,
$env_owner = 'puppet',
$environmentpath = undef,
$environment_timeout = '0',
Expand Down Expand Up @@ -159,6 +162,7 @@
autosign_file => $autosign_file,
autosign_method => $autosign_method,
basemodulepath => $basemodulepath,
dns_alt_names => $dns_alt_names,
deep_merge_version => $deep_merge_version,
env_owner => $env_owner,
environmentpath => $environmentpath,
Expand Down
13 changes: 13 additions & 0 deletions spec/classes/puppet_master_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,19 @@
end
end## autosign_method file autosign_domains not empty custom autosign_file

context 'when $::puppet::master::dns_alt_names is not empty' do
let(:pre_condition) {"class{'::puppet::master': dns_alt_names => ['bogan1.domain.com','bogan2.domain.com']}"}
it 'should add dns_alt_names in $confdir/puppet.conf' do
should contain_ini_setting('dns_alt_names').with({
'ensure' => 'present',
'path' => "#{confdir}/puppet.conf",
'section' => 'main',
'setting' => 'dns_alt_names',
'value' => 'bogan1.domain.com,bogan2.domain.com',
})
end
end## dns_alt_names not empty

context 'when ::puppet::ca_server is set and this is not the ca_server' do
let(:pre_condition){"class{'::puppet': ca_server => 'bogon.domain.com'}"}
let(:facts) do
Expand Down
6 changes: 3 additions & 3 deletions spec/classes/puppet_master_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
end
end#absolute path

['hiera_hierarchy'].each do |arrays|
['dns_alt_names','hiera_hierarchy'].each do |arrays|
context "when the #{arrays} parameter is not an array" do
let(:params) {{ arrays => 'this is a string'}}
let(:params) {{ arrays => 'this is not an array'}}
it 'should fail' do
# skip 'This does not work as is'
expect { catalogue }.to raise_error(Puppet::Error)#, /is not an Array./)
expect { catalogue }.to raise_error(Puppet::Error)#, /is not an Array./)
end
end
end#arrays
Expand Down