WIP: Implement type validation
Change-Id: I0ef6b0aaa8607b1dbf3c289d8631b9b85c6d6289
This commit is contained in:
parent
5734cafcee
commit
6404423629
|
@ -61,20 +61,20 @@
|
||||||
# string; optional; default to undef
|
# string; optional; default to undef
|
||||||
#
|
#
|
||||||
define openstacklib::db::mysql (
|
define openstacklib::db::mysql (
|
||||||
$password = undef,
|
Optional[String] $password = undef,
|
||||||
$plugin = undef,
|
Optional[String] $plugin = undef,
|
||||||
$dbname = $title,
|
String[1] $dbname = $title,
|
||||||
$user = $title,
|
String[1] $user = $title,
|
||||||
$host = '127.0.0.1',
|
Stdlb::Host $host = '127.0.0.1',
|
||||||
$charset = 'utf8',
|
String[1] $charset = 'utf8',
|
||||||
$collate = 'utf8_general_ci',
|
String[1] $collate = 'utf8_general_ci',
|
||||||
$allowed_hosts = [],
|
Variant[Stdlib::Host, Array[Stdlib::Host]] $allowed_hosts = [],
|
||||||
$privileges = 'ALL',
|
Variant[String, Array[String]] $privileges = 'ALL',
|
||||||
$create_user = true,
|
Boolean $create_user = true,
|
||||||
$create_grant = true,
|
Boolean $create_grant = true,
|
||||||
$tls_options = ['NONE'],
|
Variant[String, Array[String]] $tls_options = ['NONE'],
|
||||||
# DEPRECATED PARAMETER
|
# DEPRECATED PARAMETER
|
||||||
$password_hash = undef,
|
Optional[String] $password_hash = undef,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include mysql::server
|
include mysql::server
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
# [*privileges*]
|
# [*privileges*]
|
||||||
# the privileges to grant to this user
|
# the privileges to grant to this user
|
||||||
#
|
#
|
||||||
|
# [*allowed_host*]
|
||||||
|
# A string representing map of host and database. Should be formatted like
|
||||||
|
# <host>_<dbname>.
|
||||||
|
# Defaults to $name
|
||||||
|
#
|
||||||
# [*plugin*]
|
# [*plugin*]
|
||||||
# Authentication plugin to use when connecting to the MySQL server;
|
# Authentication plugin to use when connecting to the MySQL server;
|
||||||
# Defaults to undef
|
# Defaults to undef
|
||||||
|
@ -36,19 +41,17 @@
|
||||||
# Defaults to ['NONE']
|
# Defaults to ['NONE']
|
||||||
#
|
#
|
||||||
define openstacklib::db::mysql::host_access (
|
define openstacklib::db::mysql::host_access (
|
||||||
$user,
|
String[1] $user,
|
||||||
$password_hash,
|
String[1] $password_hash,
|
||||||
$database,
|
String[1] $database,
|
||||||
$privileges,
|
Variant[String, Array[String]] $privileges,
|
||||||
$plugin = undef,
|
Pattern[/_/] $allowed_host = $title
|
||||||
$create_user = true,
|
Optional[String] $plugin = undef,
|
||||||
$create_grant = true,
|
Boolean $create_user = true,
|
||||||
$tls_options = ['NONE'],
|
Boolean $create_grant = true,
|
||||||
|
Variant[String, Array[String]] $tls_options = ['NONE'],
|
||||||
) {
|
) {
|
||||||
|
|
||||||
validate_legacy(Pattern[/_/], 'validate_re', $title,
|
|
||||||
['_', 'Title must be $dbname_$host'])
|
|
||||||
|
|
||||||
$host = inline_template('<%= @title.split("_").last.downcase %>')
|
$host = inline_template('<%= @title.split("_").last.downcase %>')
|
||||||
|
|
||||||
if $create_user {
|
if $create_user {
|
||||||
|
|
|
@ -31,13 +31,13 @@
|
||||||
# string; required
|
# string; required
|
||||||
#
|
#
|
||||||
define openstacklib::db::postgresql (
|
define openstacklib::db::postgresql (
|
||||||
$password = undef,
|
Optional[String] $password = undef,
|
||||||
$dbname = $title,
|
String[1] $dbname = $title,
|
||||||
$user = $title,
|
String[1] $user = $title,
|
||||||
$encoding = undef,
|
Optional[String] $encoding = undef,
|
||||||
$privileges = 'ALL',
|
String $privileges = 'ALL',
|
||||||
# DEPRECATED PARAMETERS
|
# DEPRECATED PARAMETERS
|
||||||
$password_hash = undef,
|
Optional[String] $password_hash = undef,
|
||||||
){
|
){
|
||||||
|
|
||||||
if $password_hash != undef {
|
if $password_hash != undef {
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
# Defaults to 'present'
|
# Defaults to 'present'
|
||||||
#
|
#
|
||||||
class openstacklib::iscsid(
|
class openstacklib::iscsid(
|
||||||
$enabled = true,
|
Boolean $enabled = true,
|
||||||
$manage_service = true,
|
Boolean $manage_service = true,
|
||||||
$package_ensure = 'present'
|
String[1] $package_ensure = 'present'
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include openstacklib::params
|
include openstacklib::params
|
||||||
|
|
|
@ -62,16 +62,16 @@
|
||||||
# Defaults to true
|
# Defaults to true
|
||||||
#
|
#
|
||||||
define openstacklib::messaging::rabbitmq(
|
define openstacklib::messaging::rabbitmq(
|
||||||
$userid = 'guest',
|
String[1] $userid = 'guest',
|
||||||
$password = 'guest',
|
String[1] $password = 'guest',
|
||||||
$virtual_host = '/',
|
String[1] $virtual_host = '/',
|
||||||
$is_admin = false,
|
Boolean $is_admin = false,
|
||||||
$configure_permission = '.*',
|
String[1] $configure_permission = '.*',
|
||||||
$write_permission = '.*',
|
String[1] $write_permission = '.*',
|
||||||
$read_permission = '.*',
|
String[1] $read_permission = '.*',
|
||||||
$manage_user = true,
|
Boolean $manage_user = true,
|
||||||
$manage_user_permissions = true,
|
Boolean $manage_user_permissions = true,
|
||||||
$manage_vhost = true,
|
Boolean $manage_vhost = true,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if $manage_user {
|
if $manage_user {
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
# Defaults to $::openstacklib::params::openstackclient_package_name
|
# Defaults to $::openstacklib::params::openstackclient_package_name
|
||||||
#
|
#
|
||||||
class openstacklib::openstackclient(
|
class openstacklib::openstackclient(
|
||||||
$package_name = $::openstacklib::params::openstackclient_package_name,
|
String[1] $package_name = $::openstacklib::params::openstackclient_package_name,
|
||||||
$package_ensure = 'present',
|
String[1] $package_ensure = 'present',
|
||||||
) inherits openstacklib::params {
|
) inherits openstacklib::params {
|
||||||
|
|
||||||
ensure_packages($package_name, {
|
ensure_packages($package_name, {
|
||||||
|
|
|
@ -34,16 +34,14 @@
|
||||||
# Defaults to false.
|
# Defaults to false.
|
||||||
#
|
#
|
||||||
define openstacklib::policy (
|
define openstacklib::policy (
|
||||||
$policy_path = $name,
|
Stdlib::Absolutepath $policy_path = $name,
|
||||||
$policies = {},
|
Hash $policies = {},
|
||||||
$file_mode = '0640',
|
Stdlib::Filemode $file_mode = '0640',
|
||||||
$file_user = undef,
|
Optional[String] $file_user = undef,
|
||||||
$file_group = undef,
|
Optional[String] $file_group = undef,
|
||||||
$file_format = 'json',
|
Enum['json', 'yaml'] $file_format = 'json',
|
||||||
$purge_config = false,
|
Boolean $purge_config = false,
|
||||||
) {
|
) {
|
||||||
validate_legacy(Hash, 'validate_hash', $policies)
|
|
||||||
validate_legacy(Stdlib::Absolutepath, 'validate_absolute_path', $policy_path)
|
|
||||||
|
|
||||||
if empty($policies) {
|
if empty($policies) {
|
||||||
create_resources('openstacklib::policy::default', { $policy_path => {
|
create_resources('openstacklib::policy::default', { $policy_path => {
|
||||||
|
|
|
@ -37,14 +37,14 @@
|
||||||
# Defaults to false.
|
# Defaults to false.
|
||||||
#
|
#
|
||||||
define openstacklib::policy::base (
|
define openstacklib::policy::base (
|
||||||
$file_path,
|
Stdlib::Absolutepath $file_path,
|
||||||
$key,
|
String[1] $key,
|
||||||
$value = '',
|
String[1] $value = '',
|
||||||
$file_mode = '0640',
|
Stdlib::Filemode $file_mode = '0640',
|
||||||
$file_user = undef,
|
Optional[String] $file_user = undef,
|
||||||
$file_group = undef,
|
Optional[String] $file_group = undef,
|
||||||
$file_format = 'json',
|
Enum['json', 'yaml'] $file_format = 'json',
|
||||||
$purge_config = false,
|
Boolean $purge_config = false,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
ensure_resource('openstacklib::policy::default', $file_path, {
|
ensure_resource('openstacklib::policy::default', $file_path, {
|
||||||
|
|
|
@ -31,12 +31,12 @@
|
||||||
# Defaults to false.
|
# Defaults to false.
|
||||||
#
|
#
|
||||||
define openstacklib::policy::default (
|
define openstacklib::policy::default (
|
||||||
$file_path = $name,
|
Stdlib::Absolutepath $file_path = $name,
|
||||||
$file_mode = '0640',
|
Stdlib::Filemode $file_mode = '0640',
|
||||||
$file_user = undef,
|
Optional[String] $file_user = undef,
|
||||||
$file_group = undef,
|
Optional[String] $file_group = undef,
|
||||||
$file_format = 'json',
|
Enum['json', 'yaml'] $file_format = 'json',
|
||||||
$purge_config = false,
|
Boolean $purge_config = false,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
case $file_format {
|
case $file_format {
|
||||||
|
|
|
@ -22,11 +22,9 @@
|
||||||
# that should not autostart on install.
|
# that should not autostart on install.
|
||||||
#
|
#
|
||||||
class openstacklib::policyrcd(
|
class openstacklib::policyrcd(
|
||||||
$services
|
Array[String] $services
|
||||||
) {
|
) {
|
||||||
|
|
||||||
validate_legacy(Array, 'validate_array', $services)
|
|
||||||
|
|
||||||
if $::osfamily == 'Debian' {
|
if $::osfamily == 'Debian' {
|
||||||
# We put this out there so openstack services wont auto start
|
# We put this out there so openstack services wont auto start
|
||||||
# when installed.
|
# when installed.
|
||||||
|
|
|
@ -43,15 +43,15 @@
|
||||||
#
|
#
|
||||||
# [*timeout*]
|
# [*timeout*]
|
||||||
# The maximum time the command should take;
|
# The maximum time the command should take;
|
||||||
# string; optional; default to '60'
|
# string; optional; default to 60
|
||||||
#
|
#
|
||||||
# [*tries*]
|
# [*tries*]
|
||||||
# Number of times to retry validation;
|
# Number of times to retry validation;
|
||||||
# string; optional; default to '10'
|
# string; optional; default to 10
|
||||||
#
|
#
|
||||||
# [*try_sleep*]
|
# [*try_sleep*]
|
||||||
# Number of seconds between validation attempts;
|
# Number of seconds between validation attempts;
|
||||||
# string; optional; default to '2'
|
# string; optional; default to 2
|
||||||
#
|
#
|
||||||
# [*onlyif*]
|
# [*onlyif*]
|
||||||
# Run the exec if all conditions in the array return true.
|
# Run the exec if all conditions in the array return true.
|
||||||
|
@ -66,17 +66,17 @@
|
||||||
# string; optional; default to empty array
|
# string; optional; default to empty array
|
||||||
#
|
#
|
||||||
define openstacklib::service_validation(
|
define openstacklib::service_validation(
|
||||||
$command,
|
String[1] $command,
|
||||||
$service_name = $name,
|
String[1] $service_name = $name,
|
||||||
$path = '/usr/bin:/bin:/usr/sbin:/sbin',
|
String[1] $path = '/usr/bin:/bin:/usr/sbin:/sbin',
|
||||||
$provider = shell,
|
String[1] $provider = 'shell',
|
||||||
$refreshonly = false,
|
Boolean $refreshonly = false,
|
||||||
$timeout = '60',
|
Variant[Pattern[/\d+/], Integer] $timeout = 60,
|
||||||
$tries = '10',
|
Variant[Pattern[/\d+/], Integer] $tries = 10,
|
||||||
$try_sleep = '2',
|
Variant[Pattern[/\d+/], Integer] $try_sleep = 2,
|
||||||
$onlyif = undef,
|
Optional[String] $onlyif = undef,
|
||||||
$unless = undef,
|
Optional[String] $unless = undef,
|
||||||
$environment = [],
|
Array[String] $environment = [],
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if $onlyif and $unless {
|
if $onlyif and $unless {
|
||||||
|
@ -101,4 +101,3 @@ define openstacklib::service_validation(
|
||||||
-> Exec<| title == "execute ${service_name} validation" |>
|
-> Exec<| title == "execute ${service_name} validation" |>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
type Openstacklib::Array = Variant [
|
||||||
|
Array[String],
|
||||||
|
String,
|
||||||
|
Openstacklib::Default
|
||||||
|
]
|
|
@ -0,0 +1,5 @@
|
||||||
|
type Openstacklib::Boolean = Variant[
|
||||||
|
Boolean,
|
||||||
|
Enum['true', 'false', 'True', 'False'],
|
||||||
|
Openstacklib::Default
|
||||||
|
]
|
|
@ -0,0 +1 @@
|
||||||
|
type Openstacklib::Default = Enum['<SERVICE DEFAULT>']
|
|
@ -0,0 +1,6 @@
|
||||||
|
type Openstacklib::Float = Variant[
|
||||||
|
Float,
|
||||||
|
Pattern[/\d*/],
|
||||||
|
Pattern[/\d*\.\d+/],
|
||||||
|
Openstacklib::Default
|
||||||
|
]
|
|
@ -0,0 +1,5 @@
|
||||||
|
type Openstacklib::Integer = Variant[
|
||||||
|
Integer,
|
||||||
|
Pattern[/\d*/],
|
||||||
|
Openstacklib::Default
|
||||||
|
]
|
|
@ -0,0 +1,4 @@
|
||||||
|
type Openstacklib::String = Variant[
|
||||||
|
String,
|
||||||
|
Openstacklib::Default
|
||||||
|
]
|
Loading…
Reference in New Issue