Support mysql/mariadb options

This change introduces the new class to manage [mysql] options and
[mariadb] options so that users can configure behavior of the guest
agent to launch and manage mysql instances and mariadb instances.

This also introduces support for options to manage container registry
used to pull container images.

Change-Id: Ic7b1d555cf2090f7278980edf226ddf318be489f
This commit is contained in:
Takashi Kajinami 2023-02-20 13:56:40 +09:00
parent 0ca65d22c5
commit 12131677e9
7 changed files with 373 additions and 16 deletions

View File

@ -72,6 +72,18 @@
# (optional) Default password Length for root password.
# Defaults to $::os_service_default.
#
# [*container_registry*]
# (optional) URL to the registry.
# Defaults to $::os_service_default.
#
# [*container_registry_username*]
# (optional) The registry username.
# Defaults to $::os_service_default.
#
# [*container_registry_password*]
# (optional) The plaintext registry password.
# Defaults to $::os_service_default.
#
# DEPRECATED PARAMETERS
#
# [*backup_aes_cbc_key*]
@ -79,23 +91,26 @@
# Defaults to undef
#
class trove::guestagent(
$enabled = false,
$manage_service = true,
$package_ensure = 'present',
$debug = $::os_service_default,
$log_file = '/var/log/trove/trove-guestagent.log',
$log_dir = '/var/log/trove',
$use_syslog = $::os_service_default,
$log_facility = $::os_service_default,
$swift_url = $::os_service_default,
$swift_service_type = $::os_service_default,
$default_transport_url = $::trove::default_transport_url,
$rabbit_use_ssl = $::trove::rabbit_use_ssl,
$root_grant = $::os_service_default,
$root_grant_option = $::os_service_default,
$default_password_length = $::os_service_default,
$enabled = false,
$manage_service = true,
$package_ensure = 'present',
$debug = $::os_service_default,
$log_file = '/var/log/trove/trove-guestagent.log',
$log_dir = '/var/log/trove',
$use_syslog = $::os_service_default,
$log_facility = $::os_service_default,
$swift_url = $::os_service_default,
$swift_service_type = $::os_service_default,
$default_transport_url = $::trove::default_transport_url,
$rabbit_use_ssl = $::trove::rabbit_use_ssl,
$root_grant = $::os_service_default,
$root_grant_option = $::os_service_default,
$default_password_length = $::os_service_default,
$container_registry = $::os_service_default,
$container_registry_username = $::os_service_default,
$container_registry_password = $::os_service_default,
# DEPRECATED PARAMETERS
$backup_aes_cbc_key = undef,
$backup_aes_cbc_key = undef,
) inherits trove {
include trove::deps
@ -175,4 +190,10 @@ class trove::guestagent(
package_ensure => $package_ensure,
}
trove_guestagent_config {
'guest_agent/container_registry': value => $container_registry;
'guest_agent/container_registry_username': value => $container_registry_username;
'guest_agent/container_registry_password': value => $container_registry_password, secret => true;
}
}

View File

@ -0,0 +1,95 @@
# == Class trove::guestagent::mariadb
#
# Configure the mariadb options
#
# == Parameters
#
# [*docker_image*]
# (optional) Database docker image.
# Defaults to $::os_service_default
#
# [*backup_docker_image*]
# (optional) The docker image used for backup and restore.
# Defaults to $::os_service_default
#
# [*icmp*]
# (optional) Whether to permit ICMP.
# Defaults to $::os_service_default.
#
# [*root_on_create*]
# (optional) Enable the automatic creation of the root user for the service
# during instance-create.
# Defaults to $::os_service_default
#
# [*usage_timeout*]
# (optional) Maximum time (in seconds) to wait for a Guest to become active.
# Defaults to $::os_service_default
#
# [*volume_support*]
# (optional) Whether to provision a Cinder volume for datadir
# Defaults to $::os_service_default
#
# [*ignore_users*]
# (optional) Users to exclude when listing users.
# Defaults to $::os_service_default
#
# [*ignore_dbs*]
# (optional) Databases to exclude when listing databases.
# Defaults to $::os_service_default
#
# [*guest_log_exposed_logs*]
# (optional) List of Guest Logs to expose for publishing.
# Defaults to $::os_service_default
#
# [*guest_log_long_query_time*]
# (optional) The time in milliseconds that a statement must take in in order
# to be logged in the slow_query log.
# Defaults to $::os_service_default
#
# [*cluster_support*]
# (optional) Enable clusters to be created and managed.
# Defaults to $::os_service_default
#
# [*min_cluster_member_count*]
# (optional) Minimum number of members in MariaDB cluster.
# Defaults to $::os_service_default
#
# [*default_password_length*]
# (optional) Character length of generated passwords.
# Defaults to $::os_service_default
#
class trove::guestagent::mariadb (
$docker_image = $::os_service_default,
$backup_docker_image = $::os_service_default,
$icmp = $::os_service_default,
$root_on_create = $::os_service_default,
$usage_timeout = $::os_service_default,
$volume_support = $::os_service_default,
$ignore_users = $::os_service_default,
$ignore_dbs = $::os_service_default,
$guest_log_exposed_logs = $::os_service_default,
$guest_log_long_query_time = $::os_service_default,
$cluster_support = $::os_service_default,
$min_cluster_member_count = $::os_service_default,
$default_password_length = $::os_service_default,
) {
include trove::deps
trove_guestagent_config {
'mariadb/docker_image': value => $docker_image;
'mariadb/backup_docker_image': value => $backup_docker_image;
'mariadb/icmp': value => $icmp;
'mariadb/root_on_create': value => $root_on_create;
'mariadb/usage_timeout': value => $usage_timeout;
'mariadb/volume_support': value => $volume_support;
'mariadb/ignore_users': value => join(any2array($ignore_users), ',');
'mariadb/ignore_dbs': value => join(any2array($ignore_dbs), ',');
'mariadb/guest_log_exposed_logs': value => join(any2array($guest_log_exposed_logs), ',');
'mariadb/guest_log_long_query_time': value => $guest_log_long_query_time;
'mariadb/cluster_support': value => $cluster_support;
'mariadb/min_cluster_member_count': value => $min_cluster_member_count;
'mariadb/default_password_length': value => $default_password_length;
}
}

View File

@ -0,0 +1,83 @@
# == Class trove::guestagent::mysql
#
# Configure the mysql options
#
# == Parameters
#
# [*docker_image*]
# (optional) Database docker image.
# Defaults to $::os_service_default
#
# [*backup_docker_image*]
# (optional) The docker image used for backup and restore.
# Defaults to $::os_service_default
#
# [*icmp*]
# (optional) Whether to permit ICMP.
# Defaults to $::os_service_default.
#
# [*root_on_create*]
# (optional) Enable the automatic creation of the root user for the service
# during instance-create.
# Defaults to $::os_service_default
#
# [*usage_timeout*]
# (optional) Maximum time (in seconds) to wait for a Guest to become active.
# Defaults to $::os_service_default
#
# [*volume_support*]
# (optional) Whether to provision a Cinder volume for datadir
# Defaults to $::os_service_default
#
# [*ignore_users*]
# (optional) Users to exclude when listing users.
# Defaults to $::os_service_default
#
# [*ignore_dbs*]
# (optional) Databases to exclude when listing databases.
# Defaults to $::os_service_default
#
# [*guest_log_exposed_logs*]
# (optional) List of Guest Logs to expose for publishing.
# Defaults to $::os_service_default
#
# [*guest_log_long_query_time*]
# (optional) The time in milliseconds that a statement must take in in order
# to be logged in the slow_query log.
# Defaults to $::os_service_default
#
# [*default_password_length*]
# (optional) Character length of generated passwords.
# Defaults to $::os_service_default
#
class trove::guestagent::mysql (
$docker_image = $::os_service_default,
$backup_docker_image = $::os_service_default,
$icmp = $::os_service_default,
$root_on_create = $::os_service_default,
$usage_timeout = $::os_service_default,
$volume_support = $::os_service_default,
$ignore_users = $::os_service_default,
$ignore_dbs = $::os_service_default,
$guest_log_exposed_logs = $::os_service_default,
$guest_log_long_query_time = $::os_service_default,
$default_password_length = $::os_service_default,
) {
include trove::deps
trove_guestagent_config {
'mysql/docker_image': value => $docker_image;
'mysql/backup_docker_image': value => $backup_docker_image;
'mysql/icmp': value => $icmp;
'mysql/root_on_create': value => $root_on_create;
'mysql/usage_timeout': value => $usage_timeout;
'mysql/volume_support': value => $volume_support;
'mysql/ignore_users': value => join(any2array($ignore_users), ',');
'mysql/ignore_dbs': value => join(any2array($ignore_dbs), ',');
'mysql/guest_log_exposed_logs': value => join(any2array($guest_log_exposed_logs), ',');
'mysql/guest_log_long_query_time': value => $guest_log_long_query_time;
'mysql/default_password_length': value => $default_password_length;
}
}

View File

@ -0,0 +1,15 @@
---
features:
- |
The following two new classes have been added.
- ``trove::guestagent::mariadb``
- ``trove::guestagent::mysql``
- |
The following three parameters have been added to the ``trove::guestagent``
class.
- ``container_registry``
- ``container_registry_username``
- ``container_registry_password``

View File

@ -0,0 +1,72 @@
require 'spec_helper'
describe 'trove::guestagent::mariadb' do
shared_examples 'trove::guestagent::mariadb' do
context 'with defaults' do
it 'configures mariadb options with defaultss' do
is_expected.to contain_trove_guestagent_config('mariadb/docker_image').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mariadb/backup_docker_image').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mariadb/icmp').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mariadb/root_on_create').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mariadb/usage_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mariadb/volume_support').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mariadb/ignore_users').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mariadb/ignore_dbs').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mariadb/guest_log_exposed_logs').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mariadb/guest_log_long_query_time').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mariadb/default_password_length').with_value('<SERVICE DEFAULT>')
end
end
context 'with parameters overridden' do
let :params do
{
:docker_image => 'mariadb',
:backup_docker_image => 'openstacktrove/db-backup-mariadb:1.1.0',
:icmp => false,
:root_on_create => false,
:usage_timeout => 400,
:volume_support => true,
:ignore_users => ['os_admin', 'root'],
:ignore_dbs => ['mariadb', 'information_schema', 'performance_schema', 'sys'],
:guest_log_exposed_logs => ['general', 'slow_query'],
:guest_log_long_query_time => 1000,
:cluster_support => true,
:min_cluster_member_count => 3,
:default_password_length => 36,
}
end
it 'configures mariadb options with given values' do
is_expected.to contain_trove_guestagent_config('mariadb/docker_image').with_value('mariadb')
is_expected.to contain_trove_guestagent_config('mariadb/backup_docker_image').with_value('openstacktrove/db-backup-mariadb:1.1.0')
is_expected.to contain_trove_guestagent_config('mariadb/icmp').with_value(false)
is_expected.to contain_trove_guestagent_config('mariadb/root_on_create').with_value(false)
is_expected.to contain_trove_guestagent_config('mariadb/usage_timeout').with_value(400)
is_expected.to contain_trove_guestagent_config('mariadb/volume_support').with_value(true)
is_expected.to contain_trove_guestagent_config('mariadb/ignore_users').with_value('os_admin,root')
is_expected.to contain_trove_guestagent_config('mariadb/ignore_dbs').with_value('mariadb,information_schema,performance_schema,sys')
is_expected.to contain_trove_guestagent_config('mariadb/guest_log_exposed_logs').with_value('general,slow_query')
is_expected.to contain_trove_guestagent_config('mariadb/guest_log_long_query_time').with_value(1000)
is_expected.to contain_trove_guestagent_config('mariadb/cluster_support').with_value(true)
is_expected.to contain_trove_guestagent_config('mariadb/min_cluster_member_count').with_value(3)
is_expected.to contain_trove_guestagent_config('mariadb/default_password_length').with_value(36)
end
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
context "on #{os}" do
it_configures 'trove::guestagent::mariadb'
end
end
end

View File

@ -0,0 +1,68 @@
require 'spec_helper'
describe 'trove::guestagent::mysql' do
shared_examples 'trove::guestagent::mysql' do
context 'with defaults' do
it 'configures mysql options with defaultss' do
is_expected.to contain_trove_guestagent_config('mysql/docker_image').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mysql/backup_docker_image').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mysql/icmp').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mysql/root_on_create').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mysql/usage_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mysql/volume_support').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mysql/ignore_users').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mysql/ignore_dbs').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mysql/guest_log_exposed_logs').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mysql/guest_log_long_query_time').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('mysql/default_password_length').with_value('<SERVICE DEFAULT>')
end
end
context 'with parameters overridden' do
let :params do
{
:docker_image => 'mysql',
:backup_docker_image => 'openstacktrove/db-backup-mysql:1.1.0',
:icmp => false,
:root_on_create => false,
:usage_timeout => 400,
:volume_support => true,
:ignore_users => ['os_admin', 'root'],
:ignore_dbs => ['mysql', 'information_schema', 'performance_schema', 'sys'],
:guest_log_exposed_logs => ['general', 'slow_query'],
:guest_log_long_query_time => 1000,
:default_password_length => 36,
}
end
it 'configures mysql options with given values' do
is_expected.to contain_trove_guestagent_config('mysql/docker_image').with_value('mysql')
is_expected.to contain_trove_guestagent_config('mysql/backup_docker_image').with_value('openstacktrove/db-backup-mysql:1.1.0')
is_expected.to contain_trove_guestagent_config('mysql/icmp').with_value(false)
is_expected.to contain_trove_guestagent_config('mysql/root_on_create').with_value(false)
is_expected.to contain_trove_guestagent_config('mysql/usage_timeout').with_value(400)
is_expected.to contain_trove_guestagent_config('mysql/volume_support').with_value(true)
is_expected.to contain_trove_guestagent_config('mysql/ignore_users').with_value('os_admin,root')
is_expected.to contain_trove_guestagent_config('mysql/ignore_dbs').with_value('mysql,information_schema,performance_schema,sys')
is_expected.to contain_trove_guestagent_config('mysql/guest_log_exposed_logs').with_value('general,slow_query')
is_expected.to contain_trove_guestagent_config('mysql/guest_log_long_query_time').with_value(1000)
is_expected.to contain_trove_guestagent_config('mysql/default_password_length').with_value(36)
end
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
context "on #{os}" do
it_configures 'trove::guestagent::mysql'
end
end
end

View File

@ -82,6 +82,9 @@ describe 'trove::guestagent' do
is_expected.to contain_trove_guestagent_config('DEFAULT/root_grant_option').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('DEFAULT/default_password_length').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('DEFAULT/backup_aes_cbc_key').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('guest_agent/container_registry').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('guest_agent/container_registry_username').with_value('<SERVICE DEFAULT>')
is_expected.to contain_trove_guestagent_config('guest_agent/container_registry_password').with_value('<SERVICE DEFAULT>').with_secret(true)
end
it 'configures trove-guestagent with default logging parameters' do