From 87a801efceba4a4d2a8f68978ad8856c339a53aa Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 26 Nov 2024 14:26:21 +0100 Subject: [PATCH] Harden the datatypes --- REFERENCE.md | 68 ++++++++++++++++++++++++++++++++++++----------- manifests/init.pp | 32 +++++++++++----------- 2 files changed, 68 insertions(+), 32 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 6330d4d..b6d2779 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -143,16 +143,20 @@ The following parameters are available in the `patroni` class: * [`service_ensure`](#-patroni--service_ensure) * [`service_enable`](#-patroni--service_enable) * [`custom_pip_provider`](#-patroni--custom_pip_provider) +* [`is_standby`](#-patroni--is_standby) +* [`standby_cluster_host`](#-patroni--standby_cluster_host) +* [`standby_cluster_port`](#-patroni--standby_cluster_port) +* [`standby_cluster_primary_slot_name`](#-patroni--standby_cluster_primary_slot_name) ##### `scope` -Data type: `String` +Data type: `String[1]` Refer to Patroni Global `scope` setting ##### `namespace` -Data type: `String` +Data type: `String[1]` Refer to Patroni Global `namespace` setting @@ -927,7 +931,7 @@ Default value: `false` ##### `zookeeper_hosts` -Data type: `Array[String]` +Data type: `Array[String[1]]` Refer to Zookeeper configuration `hosts` setting @@ -943,7 +947,7 @@ Default value: `'automatic'` ##### `watchdog_device` -Data type: `String` +Data type: `Stdlib::Absolutepath` Refer to Watchdog configuration `device` setting @@ -967,7 +971,7 @@ Default value: `true` ##### `postgresql_version` -Data type: `Optional[String]` +Data type: `Optional[String[1]]` Version of postgresql passed to postgresql::globals class @@ -975,7 +979,7 @@ Default value: `undef` ##### `package_name` -Data type: `String` +Data type: `String[1]` Patroni package name, only used when `install_method` is `package` @@ -983,7 +987,7 @@ Default value: `'patroni'` ##### `version` -Data type: `String` +Data type: `String[1]` Version of Patroni to install @@ -991,7 +995,7 @@ Default value: `'present'` ##### `install_dependencies` -Data type: `Array` +Data type: `Array[String[1]]` Install dependencies, only used when `install_method` is `pip` @@ -1023,7 +1027,7 @@ Default value: `'/opt/app/patroni'` ##### `python_class_version` -Data type: `String` +Data type: `String[1]` The version of Python to pass to Python class Only used when `install_method` is `pip` @@ -1032,7 +1036,7 @@ Default value: `'36'` ##### `python_venv_version` -Data type: `String` +Data type: `String[1]` The version of Python to pass to Python virtualenv defined type Only used when `install_method` is `pip` @@ -1049,7 +1053,7 @@ Default value: `true` ##### `config_path` -Data type: `String` +Data type: `Stdlib::Absolutepath` Path to Patroni configuration file @@ -1057,7 +1061,7 @@ Default value: `'/opt/app/patroni/etc/postgresql.yml'` ##### `config_owner` -Data type: `String` +Data type: `String[1]` Patroni configuration file owner @@ -1065,7 +1069,7 @@ Default value: `'postgres'` ##### `config_group` -Data type: `String` +Data type: `String[1]` Patroni configuration file group @@ -1073,7 +1077,7 @@ Default value: `'postgres'` ##### `config_mode` -Data type: `String` +Data type: `Stdlib::Filemode` Patroni configuration file mode @@ -1081,7 +1085,7 @@ Default value: `'0600'` ##### `service_name` -Data type: `String` +Data type: `String[1]` Name of Patroni service @@ -1089,7 +1093,7 @@ Default value: `'patroni'` ##### `service_ensure` -Data type: `String` +Data type: `Enum['running', 'stopped']` Patroni service ensure property @@ -1111,6 +1115,38 @@ Use custom pip path when installing pip packages Default value: `undef` +##### `is_standby` + +Data type: `Boolean` + +Boolean to use Standby cluster + +Default value: `false` + +##### `standby_cluster_host` + +Data type: `String` + +Refer to Standby configuration `host` setting + +Default value: `'127.0.0.1'` + +##### `standby_cluster_port` + +Data type: `Stdlib::Port` + +Refer to Standby configuration `port` setting + +Default value: `5432` + +##### `standby_cluster_primary_slot_name` + +Data type: `Optional[String]` + +Refer to Standby configuration `slot` setting + +Default value: `'patroni'` + ## Resource types ### `patroni_dcs_config` diff --git a/manifests/init.pp b/manifests/init.pp index 9e09ac8..a4f09bb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -253,8 +253,8 @@ class patroni ( # Global Settings - String $scope, - String $namespace = '/service/', + String[1] $scope, + String[1] $namespace = '/service/', String $hostname = $facts['networking']['hostname'], # Bootstrap Settings @@ -373,31 +373,31 @@ # ZooKeeper Settings Boolean $use_zookeeper = false, - Array[String] $zookeeper_hosts = [], + Array[String[1]] $zookeeper_hosts = [], # Watchdog Settings Enum['off','automatic','required'] $watchdog_mode = 'automatic', - String $watchdog_device = '/dev/watchdog', + Stdlib::Absolutepath $watchdog_device = '/dev/watchdog', Integer $watchdog_safety_margin = 5, # Module Specific Settings Boolean $manage_postgresql = true, - Optional[String] $postgresql_version = undef, - String $package_name = 'patroni', - String $version = 'present', - Array $install_dependencies = [], + Optional[String[1]] $postgresql_version = undef, + String[1] $package_name = 'patroni', + String[1] $version = 'present', + Array[String[1]] $install_dependencies = [], Boolean $manage_python = true, Enum['package','pip'] $install_method = 'pip', Stdlib::Absolutepath $install_dir = '/opt/app/patroni', - String $python_class_version = '36', - String $python_venv_version = '3.6', + String[1] $python_class_version = '36', + String[1] $python_venv_version = '3.6', Boolean $manage_venv_package = true, - String $config_path = '/opt/app/patroni/etc/postgresql.yml', - String $config_owner = 'postgres', - String $config_group = 'postgres', - String $config_mode = '0600', - String $service_name = 'patroni', - String $service_ensure = 'running', + Stdlib::Absolutepath $config_path = '/opt/app/patroni/etc/postgresql.yml', + String[1] $config_owner = 'postgres', + String[1] $config_group = 'postgres', + Stdlib::Filemode $config_mode = '0600', + String[1] $service_name = 'patroni', + Enum['running', 'stopped'] $service_ensure = 'running', Boolean $service_enable = true, Optional[String[1]] $custom_pip_provider = undef, ) {