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
(PDB-3587) Add puppetlabs-postgresql 5.x support and integrate rspec-puppetfacts #260
Conversation
Converted $database_port into an integer for compatibility with puppetlabs-postgresql 5.x
The manage_pg_repo defaulted to 'true' in all cases. This proved to be a problem on supported OSes that weren't of the Redhat or Debian families as puppetlabs-postgresql only supports managing Debian or Redhat Postgresql repositories. The parameter now defaults to true only when $osfamily is Redhat or Debian
manifests/database/postgresql.pp
Outdated
@@ -20,7 +20,7 @@ | |||
class { '::postgresql::server': | |||
ip_mask_allow_all_users => '0.0.0.0/0', | |||
listen_addresses => $listen_addresses, | |||
port => $database_port, | |||
port => 0 + $database_port, |
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.
Is this the cheap way of casting $database_port to an integer?
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.
Yes, I was trying to avoid breaking any functionality with this PR.
There is the scanf function as well, but required a minimum of Puppet 3.7.5, so that would also be a breaking change.
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.
We're going to roll a major release soon and bring the minimum required version to Puppet 4, so scanf
should be ok here.
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.
@mullr Sounds good, I'll update that line of code
default_facts = { | ||
puppetversion: Puppet.version, | ||
facterversion: Facter.version | ||
} |
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.
Vox Pupuli configs \o/
on_supported_os.each do |os, facts| | ||
context "on #{os}" do | ||
let(:facts) do | ||
facts.merge({ |
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.
do you want to move the selinux and iptables fact to default_module_facts.yml?
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.
The selinux fact changes in different tests, but the iptables fact never changes.
let(:facts) do | ||
facts.merge({ | ||
:puppetversion => Puppet.version, | ||
:fqdn => 'puppetdb.example.com', |
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.
instead of mocking the fqdn fact you can set the node: https://github.com/voxpupuli/puppet-zabbix/blob/master/spec/classes/agent_spec.rb#L4-L6
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.
Apparently mocking node for some reason doesn't carry over to fqdn in these tests
it { should contain_puppetdb_conn_validator('puppetdb_conn').with( | ||
:puppetdb_server => 'puppetdb.example.com', | ||
:puppetdb_port => '8081', | ||
:use_ssl => 'true') } |
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.
can you pull the } into the next line?
Updated the spec_helper_acceptance.rb file to utilize a few more beaker helper gems to simplify agent and dependency installs. Updated the puppetserver and puppetlabs release install logic to use Puppet Collections and supported packages.
Updated base_spec.rb to utilize the newer, supported directory paths and corrected the ntp panic attribute which is no longer a boolean value.
@@ -17,7 +17,12 @@ | |||
$puppetdb_version = $puppetdb::globals::version | |||
$database = $puppetdb::globals::database | |||
$manage_dbserver = true | |||
$manage_pg_repo = true | |||
|
|||
if $::osfamily =~ /RedHat|Debian/ { |
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.
Isn't this equal to $manage_pg_repo = $::osfamily =~ /RedHat|Debian/
?
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.
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.
can you use the new facts hash here? $facts['os']['family']
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.
@bastelfreak I'll leave that for a Puppet 4 or Facts Hash PR. Wanted to keep the scope of this PR as close as possible to just making the module compatible with puppetlabs-postgresql
5.x for now.
@@ -87,6 +87,10 @@ | |||
{ | |||
"name": "puppetlabs/stdlib", | |||
"version_requirement": ">= 4.2.2 <5.0.0" | |||
}, | |||
{ | |||
"name": "puppetlabs/ntp", |
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.
This is only needed for acceptance testing. It feels wrong to add this as a regular dependency and should be fixed in the spec_helper_acceptance
.
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.
Let's discuss this in #263
@dhollinger THANK YOU THANK YOU THANK YOU for this PR. |
@dhollinger I'd like to do in next wednesday, after US holidays. |
Casts
$database_port
inpostgresql.pp
to an integer to make module compatible withpuppetlabs-postgresql
5.xFix an issue where
puppetlabs-puppetdb
would passtrue
tomanaged_pg_repo
by default for all supported OSes, howeverpuppetlabs-postgresql
can only manage the pg repo if theosfamily
is RedHat or Debian.Added rspec-puppet-facts to the unit tests and updated the beaker tests with beaker-puppet_install_helper and beaker-module_install_helper. These simplify test setup (it also happened to be the easiest way to get tests working consistently).