From 35ae81925a25945c39c706dcffd3e4d83bef44de Mon Sep 17 00:00:00 2001 From: Francesco Di Nucci Date: Tue, 16 Sep 2025 13:14:22 +0200 Subject: [PATCH] Set database locale to C.UTF-8 * EN_us.UTF-8 choice breaks install if the locale is not installed on the system, revert default DB locale to C.UTF-8 * Introduce database_locale to change it Kudos @JGodin-C2C @saimonn References puppetlabs/puppetlabs-puppetdb#412 puppetlabs/puppetlabs-puppetdb#421 puppetlabs/puppetlabs-puppetdb#422 --- REFERENCE.md | 9 +++++++++ manifests/database/postgresql.pp | 6 +++++- manifests/params.pp | 1 + spec/unit/classes/database/postgresql_spec.rb | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 4b6e50a..e9ffb63 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -919,6 +919,7 @@ The following parameters are available in the `puppetdb::database::postgresql` c * [`listen_addresses`](#-puppetdb--database--postgresql--listen_addresses) * [`puppetdb_server`](#-puppetdb--database--postgresql--puppetdb_server) * [`database_name`](#-puppetdb--database--postgresql--database_name) +* [`database_locale`](#-puppetdb--database--postgresql--database_locale) * [`database_username`](#-puppetdb--database--postgresql--database_username) * [`database_password`](#-puppetdb--database--postgresql--database_password) * [`database_port`](#-puppetdb--database--postgresql--database_port) @@ -963,6 +964,14 @@ Sets the name of the database. Defaults to `puppetdb`. Default value: `$puppetdb::params::database_name` +##### `database_locale` + +Data type: `Any` + +Sets the locale of the database. Defaults to `C.UTF-8`. + +Default value: `$puppetdb::params::database_locale` + ##### `database_username` Data type: `Any` diff --git a/manifests/database/postgresql.pp b/manifests/database/postgresql.pp index 825b3fe..7e23dba 100644 --- a/manifests/database/postgresql.pp +++ b/manifests/database/postgresql.pp @@ -12,6 +12,9 @@ # @param database_name # Sets the name of the database. Defaults to `puppetdb`. # +# @param database_locale +# Sets the locale of the database. Defaults to `C.UTF-8`. +# # @param database_username # Creates a user for access the database. Defaults to `puppetdb`. # @@ -74,6 +77,7 @@ $listen_addresses = $puppetdb::params::database_host, $puppetdb_server = $puppetdb::params::puppetdb_server, $database_name = $puppetdb::params::database_name, + $database_locale = $puppetdb::params::database_locale, $database_username = $puppetdb::params::database_username, Variant[String[1], Sensitive[String[1]]] $database_password = $puppetdb::params::database_password, $database_port = $puppetdb::params::database_port, @@ -150,7 +154,7 @@ user => $database_username, password => $database_password, encoding => 'UTF8', - locale => 'en_US.UTF-8', + locale => $database_locale, grant => 'all', port => $port, } diff --git a/manifests/params.pp b/manifests/params.pp index 382c342..e9ced31 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -35,6 +35,7 @@ $database_host = 'localhost' $database_port = '5432' $database_name = 'puppetdb' + $database_locale = 'C.UTF-8' $database_username = 'puppetdb' $database_password = 'puppetdb' $manage_db_password = true diff --git a/spec/unit/classes/database/postgresql_spec.rb b/spec/unit/classes/database/postgresql_spec.rb index 00e6e34..a6ada9c 100644 --- a/spec/unit/classes/database/postgresql_spec.rb +++ b/spec/unit/classes/database/postgresql_spec.rb @@ -63,7 +63,7 @@ grant: 'all', port: params[:database_port].to_i, encoding: 'UTF8', - locale: 'en_US.UTF-8' + locale: 'C.UTF-8' ) }