-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes GH-189
- Loading branch information
Showing
6 changed files
with
148 additions
and
0 deletions.
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
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,46 @@ | ||
# = Foreman Proxy PowerDNS DNS plugin | ||
# | ||
# This class installs the PowerDNS DNS plugin for Foreman proxy | ||
# | ||
# === Parameters: | ||
# | ||
# $mysql_hostname:: MySQL server hostname | ||
# | ||
# $mysql_username:: MySQL server username | ||
# | ||
# $mysql_password:: MySQL server password | ||
# | ||
# $mysql_database:: MySQL server database | ||
# | ||
# $manage_database:: Whether to manage the mysql database. Also includes the mysql server. | ||
# | ||
# $pdnssec:: pdnssec command to run rectify-zone with. Can be an empty string. | ||
# | ||
class foreman_proxy::plugin::dns::powerdns ( | ||
$mysql_hostname = $::foreman_proxy::plugin::dns::powerdns::params::mysql_hostname, | ||
$mysql_username = $::foreman_proxy::plugin::dns::powerdns::params::mysql_username, | ||
$mysql_password = $::foreman_proxy::plugin::dns::powerdns::params::mysql_password, | ||
$mysql_database = $::foreman_proxy::plugin::dns::powerdns::params::mysql_database, | ||
$manage_database = $::foreman_proxy::plugin::dns::powerdns::params::manage_database, | ||
$pdnssec = $::foreman_proxy::plugin::dns::powerdns::params::pdnssec, | ||
) inherits foreman_proxy::plugin::dns::powerdns::params { | ||
validate_bool($manage_database) | ||
validate_string($mysql_hostname, $mysql_username, $mysql_password, $mysql_database, $pdnssec) | ||
|
||
if $manage_database { | ||
include ::mysql::server | ||
mysql::db { $mysql_database: | ||
user => $mysql_username, | ||
password => $mysql_password, | ||
host => $mysql_hostname, | ||
grant => ['ALL'], | ||
} | ||
} | ||
|
||
foreman_proxy::plugin { 'dns_powerdns': | ||
} -> | ||
foreman_proxy::settings_file { 'dns_powerdns': | ||
module => false, | ||
template_path => 'foreman_proxy/plugin/dns_powerdns.yml.erb', | ||
} | ||
} |
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,8 @@ | ||
class foreman_proxy::plugin::dns::powerdns::params { | ||
$mysql_hostname = 'localhost' | ||
$mysql_username = 'pdns' | ||
$mysql_password = cache_data('smart_proxy_dns_powerdns_password', random_password(16)) | ||
$mysql_database = 'pdns' | ||
$manage_database = false | ||
$pdnssec = 'pdnssec' | ||
} |
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,72 @@ | ||
require 'spec_helper' | ||
|
||
describe 'foreman_proxy::plugin::dns::powerdns' do | ||
let :facts do | ||
on_supported_os['redhat-7-x86_64'] | ||
end | ||
|
||
let :pre_condition do | ||
'include ::foreman_proxy' | ||
end | ||
|
||
context 'default parameters' do | ||
let :params do | ||
{ | ||
:mysql_password => 'password', | ||
} | ||
end | ||
|
||
it { should compile.with_all_deps } | ||
|
||
it 'should install the correct plugin' do | ||
should contain_foreman_proxy__plugin('dns_powerdns') | ||
end | ||
|
||
it 'should contain the correct configuration' do | ||
verify_exact_contents(catalogue, '/etc/foreman-proxy/settings.d/dns_powerdns.yml', [ | ||
'---', | ||
':powerdns_mysql_hostname: "localhost"', | ||
':powerdns_mysql_username: "pdns"', | ||
':powerdns_mysql_password: "password"', | ||
':powerdns_mysql_database: "pdns"', | ||
':powerdns_pdnssec: "pdnssec"', | ||
]) | ||
end | ||
end | ||
|
||
context 'with manage_database => true' do | ||
let :params do | ||
{ | ||
:mysql_password => 'password', | ||
:manage_database => true, | ||
} | ||
end | ||
|
||
it { should compile.with_all_deps } | ||
|
||
it 'should install the correct plugin' do | ||
should contain_foreman_proxy__plugin('dns_powerdns') | ||
end | ||
|
||
it 'should contain the correct configuration' do | ||
verify_exact_contents(catalogue, '/etc/foreman-proxy/settings.d/dns_powerdns.yml', [ | ||
'---', | ||
':powerdns_mysql_hostname: "localhost"', | ||
':powerdns_mysql_username: "pdns"', | ||
':powerdns_mysql_password: "password"', | ||
':powerdns_mysql_database: "pdns"', | ||
':powerdns_pdnssec: "pdnssec"', | ||
]) | ||
end | ||
|
||
it 'should manage the database' do | ||
should contain_class('mysql::server') | ||
|
||
should contain_mysql__db('pdns') \ | ||
.with_user('pdns') \ | ||
.with_password('password') \ | ||
.with_host('localhost') \ | ||
.with_grant(['ALL']) | ||
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,6 @@ | ||
--- | ||
:powerdns_mysql_hostname: "<%= scope.lookupvar('::foreman_proxy::plugin::dns::powerdns::mysql_hostname') %>" | ||
:powerdns_mysql_username: "<%= scope.lookupvar('::foreman_proxy::plugin::dns::powerdns::mysql_username') %>" | ||
:powerdns_mysql_password: "<%= scope.lookupvar('::foreman_proxy::plugin::dns::powerdns::mysql_password') %>" | ||
:powerdns_mysql_database: "<%= scope.lookupvar('::foreman_proxy::plugin::dns::powerdns::mysql_database') %>" | ||
:powerdns_pdnssec: "<%= scope.lookupvar('::foreman_proxy::plugin::dns::powerdns::pdnssec') %>" |