Skip to content

Commit

Permalink
Added class puppet::puppetdb::database
Browse files Browse the repository at this point in the history
  • Loading branch information
aursu committed Nov 4, 2024
1 parent 2f99381 commit 8b37631
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fixtures:
ref: 6.1.0
lsys_postgresql:
repo: aursu/lsys_postgresql
ref: 0.50.5
ref: 0.52.0
openssh:
repo: aursu/openssh
ref: 0.9.1
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,12 @@ node on Puppet server.

*No new known issues have been identified.*

## Release 0.24.0
## Release 0.25.0

**Features**

* Added `puppet::agent` Puppet agent installation class
* Added PuppetDB database class `puppet::puppetdb::database`

**Bugfixes**

Expand Down
5 changes: 2 additions & 3 deletions manifests/puppetdb.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
database => $postgres_database_name,
}

Class['postgresql::server'] -> Class['puppetdb']
Postgresql::Server::Extension["${postgres_database_name}-pg_trgm"] -> Class['puppetdb']
# Class['puppetdb::database::postgresql'] is declared inside Class['puppetdb']
Class['lsys_postgresql'] -> Class['puppetdb::database::postgresql']
}

if $manage_cron {
Expand Down Expand Up @@ -87,7 +87,6 @@

automatic_dlo_cleanup => $automatic_dlo_cleanup,
}

contain puppetdb

unless $ssl_deploy_certs {
Expand Down
61 changes: 61 additions & 0 deletions manifests/puppetdb/database.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# @summary Manages the PostgreSQL database setup for PuppetDB.
#
# The `puppet::puppetdb::database` class sets up a PostgreSQL database for PuppetDB,
# including user credentials, database creation, and the required `pg_trgm` extension.
# It ensures that the `puppetdb::database::postgresql` class is properly configured
# with database parameters and integrates with the `lsys_postgresql` module for server management.
#
# **Class Workflow:**
# - **Database Setup:** Configures the database name, user, and password for PuppetDB, with defaults
# for easy deployment.
# - **Extension Management:** Adds the `pg_trgm` extension to enable trigram-based text search,
# which is commonly used in PuppetDB for efficient data querying.
# - **Dependency Management:** Ensures the `lsys_postgresql` server is set up prior to the PuppetDB
# database configuration and that the extension is created before PuppetDB accesses the database.
#
# @param database_name [String] The name of the database for PuppetDB. Defaults to 'puppetdb'.
# @param database_username [String] The username for connecting to the PuppetDB database. Defaults to 'puppetdb'.
# @param database_password [String] The password for the PuppetDB database user. Defaults to 'puppetdb'.
#
# **Dependencies:**
# - `lsys_postgresql`: Manages the PostgreSQL server setup.
# - `puppetdb::database::postgresql`: Configures the database-specific settings for PuppetDB.
# - `postgresql::server::extension`: Ensures the `pg_trgm` extension is installed.
#
# @example Basic usage
# include puppet::puppetdb::database
#
# @example Custom database configuration
# class { 'puppet::puppetdb::database':
# database_name => 'customdb',
# database_username => 'customuser',
# database_password => 'custompassword',
# }
#
# This example sets up a custom database and user for PuppetDB, using the `customdb` database
# with `customuser` credentials.
#
class puppet::puppetdb::database (
String $database_name = 'puppetdb',
String $database_username = 'puppetdb',
String $database_password = 'puppetdb',
) {
include lsys_postgresql

postgresql::server::extension { "${database_name}-pg_trgm":
extension => 'pg_trgm',
database => $database_name,
}

class { 'puppetdb::database::postgresql':
database_name => $database_name,
database_username => $database_username,
database_password => $database_password,
database_port => "${lsys_postgresql::database_port}", # lint:ignore:only_variable_string
manage_server => false,
manage_database => true,
}
contain puppetdb::database::postgresql

Class['lsys_postgresql'] -> Class['puppetdb::database::postgresql']
}
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aursu-puppet",
"version": "0.24.0",
"version": "0.25.0",
"author": "aursu",
"summary": "Puppet server installation and setup",
"license": "Apache-2.0",
Expand All @@ -22,7 +22,7 @@
},
{
"name": "aursu/lsys_postgresql",
"version_requirement": ">= 0.50.5 < 1.0.0"
"version_requirement": ">= 0.52.0 < 1.0.0"
},
{
"name": "aursu/openssh",
Expand Down
13 changes: 13 additions & 0 deletions spec/classes/puppetdb/database_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'puppet::puppetdb::database' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }

it { is_expected.to compile.with_all_deps }
end
end
end

0 comments on commit 8b37631

Please sign in to comment.