Skip to content
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
32 changes: 26 additions & 6 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ The following parameters are available in the `puppetdb` class:
* [`node_ttl`](#-puppetdb--node_ttl)
* [`node_purge_ttl`](#-puppetdb--node_purge_ttl)
* [`report_ttl`](#-puppetdb--report_ttl)
* [`facts_blacklist`](#-puppetdb--facts_blacklist)
* [`facts_blocklist`](#-puppetdb--facts_blocklist)
* [`facts_blocklist_type`](#-puppetdb--facts_blocklist_type)
* [`gc_interval`](#-puppetdb--gc_interval)
* [`node_purge_gc_batch_limit`](#-puppetdb--node_purge_gc_batch_limit)
* [`conn_max_age`](#-puppetdb--conn_max_age)
Expand Down Expand Up @@ -428,13 +429,22 @@ The length of time reports should be stored before being deleted. (defaults to

Default value: `$puppetdb::params::report_ttl`

##### <a name="-puppetdb--facts_blacklist"></a>`facts_blacklist`
##### <a name="-puppetdb--facts_blocklist"></a>`facts_blocklist`

Data type: `Optional[Array]`

A list of fact names to be ignored whenever submitted.

Default value: `$puppetdb::params::facts_blacklist`
Default value: `$puppetdb::params::facts_blocklist`

##### <a name="-puppetdb--facts_blocklist_type"></a>`facts_blocklist_type`

Data type: `Optional[Enum['literal', 'regex']]`

Select mode for interpreting the fact-blocklist, either literally or as
Java regular expressions.

Default value: `$puppetdb::params::facts_blocklist_type`

##### <a name="-puppetdb--gc_interval"></a>`gc_interval`

Expand Down Expand Up @@ -1395,7 +1405,8 @@ The following parameters are available in the `puppetdb::server` class:
* [`node_ttl`](#-puppetdb--server--node_ttl)
* [`node_purge_ttl`](#-puppetdb--server--node_purge_ttl)
* [`report_ttl`](#-puppetdb--server--report_ttl)
* [`facts_blacklist`](#-puppetdb--server--facts_blacklist)
* [`facts_blocklist`](#-puppetdb--server--facts_blocklist)
* [`facts_blocklist_type`](#-puppetdb--server--facts_blocklist_type)
* [`gc_interval`](#-puppetdb--server--gc_interval)
* [`node_purge_gc_batch_limit`](#-puppetdb--server--node_purge_gc_batch_limit)
* [`conn_max_age`](#-puppetdb--server--conn_max_age)
Expand Down Expand Up @@ -1656,13 +1667,22 @@ The length of time reports should be stored before being deleted. (defaults to

Default value: `$puppetdb::params::report_ttl`

##### <a name="-puppetdb--server--facts_blacklist"></a>`facts_blacklist`
##### <a name="-puppetdb--server--facts_blocklist"></a>`facts_blocklist`

Data type: `Optional[Array]`

A list of fact names to be ignored whenever submitted.

Default value: `$puppetdb::params::facts_blacklist`
Default value: `$puppetdb::params::facts_blocklist`

##### <a name="-puppetdb--facts_blocklist_type"></a>`facts_blocklist_type`

Data type: `Optional[Enum['literal', 'regex']]`

Select mode for interpreting the fact-blocklist, either literally or as
Java regular expressions.

Default value: `$puppetdb::params::facts_blocklist_type`

##### <a name="-puppetdb--server--gc_interval"></a>`gc_interval`

Expand Down
12 changes: 9 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@
# The length of time reports should be stored before being deleted. (defaults to
# `14d`, which is a 14-day period). This option is supported in PuppetDB >= 1.1.0.
#
# @param facts_blacklist
# @param facts_blocklist
# A list of fact names to be ignored whenever submitted.
#
# @param facts_blocklist_type
# Control how to interpret the facts-blocklist setting, either literally,
# or as Java regular expressions.
#
# @param gc_interval
# This controls how often (in minutes) to compact the database. The compaction
# process reclaims space and deletes unnecessary rows. If not supplied, the
Expand Down Expand Up @@ -388,7 +392,8 @@
Pattern[/\A[0-9dhms]+\Z/] $node_ttl = $puppetdb::params::node_ttl,
Pattern[/\A[0-9dhms]+\Z/] $node_purge_ttl = $puppetdb::params::node_purge_ttl,
Pattern[/\A[0-9dhms]+\Z/] $report_ttl = $puppetdb::params::report_ttl,
Optional[Array] $facts_blacklist = $puppetdb::params::facts_blacklist,
Optional[Array] $facts_blocklist = $puppetdb::params::facts_blocklist,
Optional[Enum['literal', 'regex']] $facts_blocklist_type = $puppetdb::params::facts_blocklist_type,
Variant[Integer[0], Pattern[/\A[0-9]+\Z/]] $gc_interval = $puppetdb::params::gc_interval,
Variant[Integer[0], Pattern[/\A[0-9]+\Z/]] $node_purge_gc_batch_limit = $puppetdb::params::node_purge_gc_batch_limit,
Variant[Integer[0], Pattern[/\A[0-9]+\Z/]] $conn_max_age = $puppetdb::params::conn_max_age,
Expand Down Expand Up @@ -464,7 +469,8 @@
node_ttl => $node_ttl,
node_purge_ttl => $node_purge_ttl,
report_ttl => $report_ttl,
facts_blacklist => $facts_blacklist,
facts_blocklist => $facts_blocklist,
facts_blocklist_type => $facts_blocklist_type,
gc_interval => $gc_interval,
node_purge_gc_batch_limit => $node_purge_gc_batch_limit,
conn_max_age => $conn_max_age,
Expand Down
3 changes: 2 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
$node_purge_ttl = '14d'
$report_ttl = '14d'

$facts_blacklist = undef
$facts_blocklist = undef
$facts_blocklist_type = undef

$gc_interval = '60'
$node_purge_gc_batch_limit = '25'
Expand Down
11 changes: 8 additions & 3 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@
# The length of time reports should be stored before being deleted. (defaults to
# `14d`, which is a 14-day period). This option is supported in PuppetDB >= 1.1.0.
#
# @param facts_blacklist
# @param facts_blocklist
# A list of fact names to be ignored whenever submitted.
#
# @param facts_blocklist_type
# Control how to interpret the facts-blocklist setting, either literally,
# or as Java regular expressions.
#
# @param gc_interval
# This controls how often (in minutes) to compact the database. The compaction
# process reclaims space and deletes unnecessary rows. If not supplied, the
Expand Down Expand Up @@ -344,7 +348,7 @@
Pattern[/\A[0-9dhms]+\Z/] $node_ttl = $puppetdb::params::node_ttl,
Pattern[/\A[0-9dhms]+\Z/] $node_purge_ttl = $puppetdb::params::node_purge_ttl,
Pattern[/\A[0-9dhms]+\Z/] $report_ttl = $puppetdb::params::report_ttl,
Optional[Array] $facts_blacklist = $puppetdb::params::facts_blacklist,
Optional[Array] $facts_blocklist = $puppetdb::params::facts_blocklist,
Variant[Integer[0], Pattern[/\A[0-9]+\Z/]] $gc_interval = $puppetdb::params::gc_interval,
Variant[Integer[0], Pattern[/\A[0-9]+\Z/]] $node_purge_gc_batch_limit = $puppetdb::params::node_purge_gc_batch_limit,
Variant[Integer[0], Pattern[/\A[0-9]+\Z/]] $conn_max_age = $puppetdb::params::conn_max_age,
Expand Down Expand Up @@ -472,7 +476,8 @@
node_ttl => $node_ttl,
node_purge_ttl => $node_purge_ttl,
report_ttl => $report_ttl,
facts_blacklist => $facts_blacklist,
facts_blocklist => $facts_blocklist,
facts_blocklist_type => $facts_blocklist_type,
gc_interval => $gc_interval,
node_purge_gc_batch_limit => $node_purge_gc_batch_limit,
conn_max_age => $conn_max_age,
Expand Down
24 changes: 16 additions & 8 deletions manifests/server/database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
Pattern[/\A[0-9dhms]+\Z/] $node_ttl = $puppetdb::params::node_ttl,
Pattern[/\A[0-9dhms]+\Z/] $node_purge_ttl = $puppetdb::params::node_purge_ttl,
Pattern[/\A[0-9dhms]+\Z/] $report_ttl = $puppetdb::params::report_ttl,
Optional[Array] $facts_blacklist = $puppetdb::params::facts_blacklist,
Optional[Array] $facts_blocklist = $puppetdb::params::facts_blocklist,
Optional[Enum['literal', 'regex']] $facts_blocklist_type = $puppetdb::params::facts_blocklist_type,
Variant[Integer[0], Pattern[/\A[0-9]+\Z/]] $gc_interval = $puppetdb::params::gc_interval,
Variant[Integer[0], Pattern[/\A[0-9]+\Z/]] $node_purge_gc_batch_limit = $puppetdb::params::node_purge_gc_batch_limit,
Variant[Integer[0], Pattern[/\A[0-9]+\Z/]] $conn_max_age = $puppetdb::params::conn_max_age,
Expand Down Expand Up @@ -168,16 +169,23 @@
}
}

if ($facts_blacklist) and length($facts_blacklist) != 0 {
$joined_facts_blacklist = join($facts_blacklist, ', ')
ini_setting { 'puppetdb_facts_blacklist':
setting => 'facts-blacklist',
value => $joined_facts_blacklist,
if ($facts_blocklist) and length($facts_blocklist) != 0 {
$joined_facts_blocklist = join($facts_blocklist, ', ')
ini_setting { 'puppetdb_facts_blocklist':
setting => 'facts-blocklist',
value => $joined_facts_blocklist,
}
} else {
ini_setting { 'puppetdb_facts_blacklist':
ini_setting { 'puppetdb_facts_blocklist':
ensure => absent,
setting => 'facts-blacklist',
setting => 'facts-blocklist',
}
}

if $facts_blocklist_type {
ini_setting { 'puppetdb_facts_blocklist_type':
setting => 'facts-blocklist-type',
value => $joined_facts_blocklist,
}
}
}
55 changes: 49 additions & 6 deletions spec/unit/classes/server/database_ini_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,39 +148,82 @@
}
it { is_expected.not_to contain_ini_setting('puppetdb_database_max_pool_size') }
it {
is_expected.to contain_ini_setting('puppetdb_facts_blacklist')
is_expected.to contain_ini_setting('puppetdb_facts_blocklist')
.with(
'ensure' => 'absent',
'path' => "#{pdbconfdir}/database.ini",
'section' => 'database',
'setting' => 'facts-blacklist',
'setting' => 'facts-blocklist',
)
}
it {
is_expected.to contain_ini_setting('puppetdb_facts_blocklist')
.with(
'ensure' => 'absent',
'path' => "#{pdbconfdir}/database.ini",
'section' => 'database',
'setting' => 'facts-blocklist-type',
)
}
end
end

describe 'when using facts_blacklist' do
describe 'when using facts_blocklist' do
let(:params) do
{
'facts_blacklist' => [
'facts_blocklist' => [
'one_fact',
'another_fact',
],
}
end

it {
is_expected.to contain_ini_setting('puppetdb_facts_blacklist')
is_expected.to contain_ini_setting('puppetdb_facts_blocklist')
.with(
'ensure' => 'present',
'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
'section' => 'database',
'setting' => 'facts-blacklist',
'setting' => 'facts-blocklist',
'value' => 'one_fact, another_fact',
)
}
end

describe 'when using "literal" facts_blocklist_type' do
let(:params) do
{'facts_blocklist_type' => 'literal'}
end

it {
is_expected.to contain_ini_setting('puppetdb_facts_blocklist')
.with(
'ensure' => 'present',
'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
'section' => 'database',
'setting' => 'facts-blocklist-type',
'value' => 'literal',
)
}
end

describe 'when using "regex" facts_blocklist_type' do
let(:params) do
{'facts_blocklist_type' => 'regex'}
end

it {
is_expected.to contain_ini_setting('puppetdb_facts_blocklist')
.with(
'ensure' => 'present',
'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
'section' => 'database',
'setting' => 'facts-blocklist-type',
'value' => 'regex',
)
}
end

describe 'when setting max pool size' do
context 'on current PuppetDB' do
describe 'to a numeric value' do
Expand Down