diff --git a/.github/workflows/mend.yml b/.github/workflows/mend.yml new file mode 100644 index 000000000..b4100a5af --- /dev/null +++ b/.github/workflows/mend.yml @@ -0,0 +1,15 @@ +name: "mend" + +on: + pull_request: + branches: + - "main" + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +jobs: + + mend: + uses: "puppetlabs/cat-github-actions/.github/workflows/mend_ruby.yml@main" + secrets: "inherit" diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cff88308a..f01626d45 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,8 +1,3 @@ --relative ---no-parameter_types-check ---no-parameter_documentation-check ---no-legacy_facts-check ---no-top_scope_facts-check --no-anchor_resource-check ---no-relative_classname_reference-check --no-params_empty_string_assignment-check diff --git a/.sync.yml b/.sync.yml index 47c485eee..04ddac558 100644 --- a/.sync.yml +++ b/.sync.yml @@ -36,10 +36,5 @@ Rakefile: changelog_since_tag: 'v11.0.3' Rakefile: extra_disabled_lint_checks: - - parameter_types - - parameter_documentation - - legacy_facts - - top_scope_facts - anchor_resource - - relative_classname_reference - params_empty_string_assignment diff --git a/Rakefile b/Rakefile index 9ceb18bf5..151f919c0 100644 --- a/Rakefile +++ b/Rakefile @@ -42,12 +42,7 @@ def changelog_future_release end PuppetLint.configuration.send('disable_relative') -PuppetLint.configuration.send('disable_parameter_types') -PuppetLint.configuration.send('disable_parameter_documentation') -PuppetLint.configuration.send('disable_legacy_facts') -PuppetLint.configuration.send('disable_top_scope_facts') PuppetLint.configuration.send('disable_anchor_resource') -PuppetLint.configuration.send('disable_relative_classname_reference') PuppetLint.configuration.send('disable_params_empty_string_assignment') diff --git a/examples/monitor.pp b/examples/monitor.pp index c56e6e67d..0bdeab9c6 100644 --- a/examples/monitor.pp +++ b/examples/monitor.pp @@ -3,7 +3,7 @@ $mysql_monitor_password = 'password' $mysql_monitor_username = 'monitoring' -$mysql_monitor_hostname = $::facts['networking']['hostname'] +$mysql_monitor_hostname = $facts['networking']['hostname'] mysql_user { "${mysql_monitor_username}@${mysql_monitor_hostname}": ensure => present, diff --git a/examples/mysql_db.pp b/examples/mysql_db.pp index c6bcf93a2..5a44b2d18 100644 --- a/examples/mysql_db.pp +++ b/examples/mysql_db.pp @@ -7,11 +7,11 @@ host => 'localhost', grant => ['SELECT', 'UPDATE'], } -mysql::db { "mydb_${fqdn}": +mysql::db { "mydb_${facts['networking']['fqdn']}": user => 'myuser', password => 'mypass', dbname => 'mydb', - host => $::fqdn, + host => $facts['networking']['fqdn'], grant => ['SELECT', 'UPDATE'], tag => $domain, } diff --git a/examples/mysql_login_path.pp b/examples/mysql_login_path.pp index b3b640b04..937d5c823 100644 --- a/examples/mysql_login_path.pp +++ b/examples/mysql_login_path.pp @@ -2,7 +2,7 @@ include apt apt::source { 'repo.mysql.com': location => 'http://repo.mysql.com/apt/debian', - release => $::lsbdistcodename, + release => $facts['os']['distro']['codename'], repos => 'mysql-8.0', key => { id => 'A4A9406876FCBD3C456770C88C718D3B5072E1F5', @@ -35,7 +35,7 @@ class { 'mysql::client': package_manage => false, package_name => 'mysql-community-client', - require => Class['::mysql::server'], + require => Class['mysql::server'], } mysql_login_path { 'client': @@ -54,7 +54,7 @@ password => Sensitive('blah'), port => 3306, owner => root, - require => Class['::mysql::server'], + require => Class['mysql::server'], } mysql_user { 'dan@localhost': diff --git a/examples/mysql_plugin.pp b/examples/mysql_plugin.pp index f075ad67c..008d542d2 100644 --- a/examples/mysql_plugin.pp +++ b/examples/mysql_plugin.pp @@ -2,7 +2,7 @@ root_password => 'password', } -$validate_password_soname = $::osfamily ? { +$validate_password_soname = $facts['os']['family'] ? { 'windows' => 'validate_password.dll', default => 'validate_password.so' } @@ -12,7 +12,7 @@ soname => $validate_password_soname, } -$auth_socket_soname = $::osfamily ? { +$auth_socket_soname = $facts['os']['family'] ? { 'windows' => 'auth_socket.dll', default => 'auth_socket.so' } diff --git a/manifests/backup/mysqlbackup.pp b/manifests/backup/mysqlbackup.pp index 99a9e960c..c5aa53f77 100644 --- a/manifests/backup/mysqlbackup.pp +++ b/manifests/backup/mysqlbackup.pp @@ -4,34 +4,34 @@ # @api private # class mysql::backup::mysqlbackup ( - $backupuser = '', - Variant[String, Sensitive[String]] $backuppassword = '', - $maxallowedpacket = '1M', - $backupdir = '', - $backupdirmode = '0700', - $backupdirowner = 'root', - $backupdirgroup = $mysql::params::root_group, - $backupcompress = true, - $backuprotate = 30, - $backupmethod = '', - $backup_success_file_path = undef, - $ignore_events = true, - $delete_before_dump = false, - $backupdatabases = [], - $file_per_database = false, - $include_triggers = true, - $include_routines = false, - $ensure = 'present', - $time = ['23', '5'], - $prescript = false, - $postscript = false, - $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', - $optional_args = [], - $incremental_backups = false, - $install_cron = true, - $compression_command = undef, - $compression_extension = undef, - $backupmethod_package = undef, + String $backupuser = '', + Variant[String, Sensitive[String]] $backuppassword = '', + String[1] $maxallowedpacket = '1M', + String $backupdir = '', + String[1] $backupdirmode = '0700', + String[1] $backupdirowner = 'root', + String[1] $backupdirgroup = $mysql::params::root_group, + Boolean $backupcompress = true, + Variant[Integer, String[1]] $backuprotate = 30, + String $backupmethod = '', + Optional[String[1]] $backup_success_file_path = undef, + Boolean $ignore_events = true, + Boolean $delete_before_dump = false, + Array[String[1]] $backupdatabases = [], + Boolean $file_per_database = false, + Boolean $include_triggers = true, + Boolean $include_routines = false, + Enum['present', 'absent'] $ensure = 'present', + Variant[Array[String[1]], Array[Integer]] $time = ['23', '5'], + Variant[Boolean, String[1], Array[String[1]]] $prescript = false, + Variant[Boolean, String[1], Array[String[1]]] $postscript = false, + String[1] $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', + Array[String[1]] $optional_args = [], + Boolean $incremental_backups = false, + Boolean $install_cron = true, + Optional[String[1]] $compression_command = undef, + Optional[String[1]] $compression_extension = undef, + Optional[String[1]] $backupmethod_package = undef, ) inherits mysql::params { $backuppassword_unsensitive = if $backuppassword =~ Sensitive { $backuppassword.unwrap @@ -74,9 +74,9 @@ } if $install_cron { - if $::osfamily == 'RedHat' { + if $facts['os']['family'] == 'RedHat' { ensure_packages('cronie') - } elsif $::osfamily != 'FreeBSD' { + } elsif $facts['os']['family'] != 'FreeBSD' { ensure_packages('cron') } } diff --git a/manifests/backup/mysqldump.pp b/manifests/backup/mysqldump.pp index 1e9fd3559..ee4e46d05 100644 --- a/manifests/backup/mysqldump.pp +++ b/manifests/backup/mysqldump.pp @@ -3,37 +3,37 @@ # @api private # class mysql::backup::mysqldump ( - $backupuser = '', - Variant[String, Sensitive[String]] $backuppassword = '', - $backupdir = '', - $maxallowedpacket = '1M', - $backupdirmode = '0700', - $backupdirowner = 'root', - $backupdirgroup = $mysql::params::root_group, - $backupcompress = true, - $backuprotate = 30, - $backupmethod = 'mysqldump', - $backup_success_file_path = undef, - $ignore_events = true, - $delete_before_dump = false, - $backupdatabases = [], - $file_per_database = false, - $include_triggers = false, - $include_routines = false, - $ensure = 'present', - $time = ['23', '5'], - $prescript = false, - $postscript = false, - $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', - $optional_args = [], - $mysqlbackupdir_ensure = 'directory', - $mysqlbackupdir_target = undef, - $incremental_backups = false, - $install_cron = true, - $compression_command = 'bzcat -zc', - $compression_extension = '.bz2', - $backupmethod_package = undef, - Array[String] $excludedatabases = [], + String $backupuser = '', + Variant[String, Sensitive[String]] $backuppassword = '', + String $backupdir = '', + String[1] $maxallowedpacket = '1M', + String[1] $backupdirmode = '0700', + String[1] $backupdirowner = 'root', + String[1] $backupdirgroup = $mysql::params::root_group, + Boolean $backupcompress = true, + Variant[Integer, String[1]] $backuprotate = 30, + String[1] $backupmethod = 'mysqldump', + Optional[String[1]] $backup_success_file_path = undef, + Boolean $ignore_events = true, + Boolean $delete_before_dump = false, + Array[String[1]] $backupdatabases = [], + Boolean $file_per_database = false, + Boolean $include_triggers = false, + Boolean $include_routines = false, + Enum['present', 'absent'] $ensure = 'present', + Variant[Array[String[1]], Array[Integer]] $time = ['23', '5'], + Variant[Boolean, String[1], Array[String[1]]] $prescript = false, + Variant[Boolean, String[1], Array[String[1]]] $postscript = false, + String[1] $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', + Array[String[1]] $optional_args = [], + String[1] $mysqlbackupdir_ensure = 'directory', + Optional[String[1]] $mysqlbackupdir_target = undef, + Boolean $incremental_backups = false, + Boolean $install_cron = true, + String[1] $compression_command = 'bzcat -zc', + String[1] $compression_extension = '.bz2', + Optional[String[1]] $backupmethod_package = undef, + Array[String] $excludedatabases = [], ) inherits mysql::params { $backuppassword_unsensitive = if $backuppassword =~ Sensitive { $backuppassword.unwrap @@ -41,7 +41,7 @@ $backuppassword } - unless $::osfamily == 'FreeBSD' { + unless $facts['os']['family'] == 'FreeBSD' { if $backupcompress and $compression_command == 'bzcat -zc' { ensure_packages(['bzip2']) Package['bzip2'] -> File['mysqlbackup.sh'] @@ -69,9 +69,9 @@ } if $install_cron { - if $::osfamily == 'RedHat' { + if $facts['os']['family'] == 'RedHat' { ensure_packages('cronie') - } elsif $::osfamily != 'FreeBSD' { + } elsif $facts['os']['family'] != 'FreeBSD' { ensure_packages('cron') } } diff --git a/manifests/backup/xtrabackup.pp b/manifests/backup/xtrabackup.pp index cf600d800..9bd6a7fa1 100644 --- a/manifests/backup/xtrabackup.pp +++ b/manifests/backup/xtrabackup.pp @@ -3,37 +3,37 @@ # @api private # class mysql::backup::xtrabackup ( - $backupuser = undef, - Optional[Variant[String, Sensitive[String]]] $backuppassword = undef, - $backupdir = '', - $maxallowedpacket = '1M', - $backupmethod = 'xtrabackup', - $backupdirmode = '0700', - $backupdirowner = 'root', - $backupdirgroup = $mysql::params::root_group, - $backupcompress = true, - $backuprotate = 30, - $backupscript_template = 'mysql/xtrabackup.sh.erb', - $backup_success_file_path = undef, - $ignore_events = true, - $delete_before_dump = false, - $backupdatabases = [], - $file_per_database = false, - $include_triggers = true, - $include_routines = false, - $ensure = 'present', - $time = ['23', '5'], - $prescript = false, - $postscript = false, - $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', - $optional_args = [], - $additional_cron_args = '--backup', - $incremental_backups = true, - $install_cron = true, - $compression_command = undef, - $compression_extension = undef, - $backupmethod_package = $mysql::params::xtrabackup_package_name, - Array[String] $excludedatabases = [], + Optional[String] $backupuser = undef, + Optional[Variant[String, Sensitive[String]]] $backuppassword = undef, + String $backupdir = '', + String[1] $maxallowedpacket = '1M', + String[1] $backupmethod = 'xtrabackup', + String[1] $backupdirmode = '0700', + String[1] $backupdirowner = 'root', + String[1] $backupdirgroup = $mysql::params::root_group, + Boolean $backupcompress = true, + Variant[Integer, String[1]] $backuprotate = 30, + String[1] $backupscript_template = 'mysql/xtrabackup.sh.erb', + Optional[String[1]] $backup_success_file_path = undef, + Boolean $ignore_events = true, + Boolean $delete_before_dump = false, + Array[String[1]] $backupdatabases = [], + Boolean $file_per_database = false, + Boolean $include_triggers = true, + Boolean $include_routines = false, + Enum['present', 'absent'] $ensure = 'present', + Variant[Array[String[1]], Array[Integer]] $time = ['23', '5'], + Variant[Boolean, String[1], Array[String[1]]] $prescript = false, + Variant[Boolean, String[1], Array[String[1]]] $postscript = false, + String[1] $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', + Array[String[1]] $optional_args = [], + String[1] $additional_cron_args = '--backup', + Boolean $incremental_backups = true, + Boolean $install_cron = true, + Optional[String[1]] $compression_command = undef, + Optional[String[1]] $compression_extension = undef, + String[1] $backupmethod_package = $mysql::params::xtrabackup_package_name, + Array[String] $excludedatabases = [], ) inherits mysql::params { ensure_packages($backupmethod_package) @@ -109,9 +109,9 @@ } if $install_cron { - if $::osfamily == 'RedHat' { + if $facts['os']['family'] == 'RedHat' { ensure_packages('cronie') - } elsif $::osfamily != 'FreeBSD' { + } elsif $facts['os']['family'] != 'FreeBSD' { ensure_packages('cron') } } @@ -138,7 +138,7 @@ } # Wether to use GNU or BSD date format. - case $::osfamily { + case $facts['os']['family'] { 'FreeBSD','OpenBSD': { $dateformat = '$(date -v-sun +\\%F)_full' } diff --git a/manifests/bindings.pp b/manifests/bindings.pp index abdd5528b..6f95ac4cb 100644 --- a/manifests/bindings.pp +++ b/manifests/bindings.pp @@ -25,88 +25,95 @@ # @param daemon_dev # Specifies whether `::mysql::bindings::daemon_dev` should be included. Valid values are `true`, `false`. # @param java_package_ensure -# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `java_enable => true`. +# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. +# Only applies if `java_enable => true`. # @param java_package_name # The name of the Java package to install. Only applies if `java_enable => true`. # @param java_package_provider # The provider to use to install the Java package. Only applies if `java_enable => true`. # @param perl_package_ensure -# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `perl_enable => true`. +# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. +# Only applies if `perl_enable => true`. # @param perl_package_name # The name of the Perl package to install. Only applies if `perl_enable => true`. # @param perl_package_provider # The provider to use to install the Perl package. Only applies if `perl_enable => true`. # @param php_package_ensure -# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `php_enable => true`. +# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. +# Only applies if `php_enable => true`. # @param php_package_name # The name of the PHP package to install. Only applies if `php_enable => true`. # @param php_package_provider # The provider to use to install the PHP package. Only applies if `php_enable => true`. # @param python_package_ensure -# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `python_enable => true`. +# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. +# Only applies if `python_enable => true`. # @param python_package_name # The name of the Python package to install. Only applies if `python_enable => true`. # @param python_package_provider # The provider to use to install the Python package. Only applies if `python_enable => true`. # @param ruby_package_ensure -# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `ruby_enable => true`. +# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. +# Only applies if `ruby_enable => true`. # @param ruby_package_name # The name of the Ruby package to install. Only applies if `ruby_enable => true`. # @param ruby_package_provider # What provider should be used to install the package. # @param client_dev_package_ensure -# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `client_dev => true`. +# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. +# Only applies if `client_dev => true`. # @param client_dev_package_name # The name of the client_dev package to install. Only applies if `client_dev => true`. # @param client_dev_package_provider # The provider to use to install the client_dev package. Only applies if `client_dev => true`. # @param daemon_dev_package_ensure -# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `daemon_dev => true`. +# Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. +# Only applies if `daemon_dev => true`. # @param daemon_dev_package_name # The name of the daemon_dev package to install. Only applies if `daemon_dev => true`. # @param daemon_dev_package_provider # The provider to use to install the daemon_dev package. Only applies if `daemon_dev => true`. # class mysql::bindings ( - $install_options = undef, + Optional[Array[String[1]]] $install_options = undef, # Boolean to determine if we should include the classes. - $java_enable = false, - $perl_enable = false, - $php_enable = false, - $python_enable = false, - $ruby_enable = false, - $client_dev = false, - $daemon_dev = false, + Boolean $java_enable = false, + Boolean $perl_enable = false, + Boolean $php_enable = false, + Boolean $python_enable = false, + Boolean $ruby_enable = false, + Boolean $client_dev = false, + Boolean $daemon_dev = false, # Settings for the various classes. - $java_package_ensure = $mysql::params::java_package_ensure, - $java_package_name = $mysql::params::java_package_name, - $java_package_provider = $mysql::params::java_package_provider, - $perl_package_ensure = $mysql::params::perl_package_ensure, - $perl_package_name = $mysql::params::perl_package_name, - $perl_package_provider = $mysql::params::perl_package_provider, - $php_package_ensure = $mysql::params::php_package_ensure, - $php_package_name = $mysql::params::php_package_name, - $php_package_provider = $mysql::params::php_package_provider, - $python_package_ensure = $mysql::params::python_package_ensure, - $python_package_name = $mysql::params::python_package_name, - $python_package_provider = $mysql::params::python_package_provider, - $ruby_package_ensure = $mysql::params::ruby_package_ensure, - $ruby_package_name = $mysql::params::ruby_package_name, - $ruby_package_provider = $mysql::params::ruby_package_provider, - $client_dev_package_ensure = $mysql::params::client_dev_package_ensure, - $client_dev_package_name = $mysql::params::client_dev_package_name, - $client_dev_package_provider = $mysql::params::client_dev_package_provider, - $daemon_dev_package_ensure = $mysql::params::daemon_dev_package_ensure, - $daemon_dev_package_name = $mysql::params::daemon_dev_package_name, - $daemon_dev_package_provider = $mysql::params::daemon_dev_package_provider + Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $java_package_ensure = $mysql::params::java_package_ensure, + String[1] $java_package_name = $mysql::params::java_package_name, + Optional[String[1]] $java_package_provider = $mysql::params::java_package_provider, + Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $perl_package_ensure = $mysql::params::perl_package_ensure, + String[1] $perl_package_name = $mysql::params::perl_package_name, + Optional[String[1]] $perl_package_provider = $mysql::params::perl_package_provider, + Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $php_package_ensure = $mysql::params::php_package_ensure, + String[1] $php_package_name = $mysql::params::php_package_name, + Optional[String[1]] $php_package_provider = $mysql::params::php_package_provider, + Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $python_package_ensure = $mysql::params::python_package_ensure, + String[1] $python_package_name = $mysql::params::python_package_name, + Optional[String[1]] $python_package_provider = $mysql::params::python_package_provider, + Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $ruby_package_ensure = $mysql::params::ruby_package_ensure, + String[1] $ruby_package_name = $mysql::params::ruby_package_name, + Optional[String[1]] $ruby_package_provider = $mysql::params::ruby_package_provider, + Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $client_dev_package_ensure = $mysql::params::client_dev_package_ensure, + Optional[String[1]] $client_dev_package_name = $mysql::params::client_dev_package_name, + Optional[String[1]] $client_dev_package_provider = $mysql::params::client_dev_package_provider, + Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $daemon_dev_package_ensure = $mysql::params::daemon_dev_package_ensure, + String[1] $daemon_dev_package_name = $mysql::params::daemon_dev_package_name, + Optional[String[1]] $daemon_dev_package_provider = $mysql::params::daemon_dev_package_provider ) inherits mysql::params { - case $::osfamily { + case $facts['os']['family'] { 'Archlinux': { - if $java_enable { fail("::mysql::bindings::java cannot be managed by puppet on ${::facts['os']['family']} as it is not in official repositories. Please disable java mysql binding.") } + if $java_enable { fail("::mysql::bindings::java cannot be managed by puppet on ${facts['os']['family']} as it is not in official repositories. Please disable java mysql binding.") } if $perl_enable { include 'mysql::bindings::perl' } - if $php_enable { warning("::mysql::bindings::php does not need to be managed by puppet on ${::facts['os']['family']} as it is included in mysql package by default.") } + if $php_enable { warning("::mysql::bindings::php does not need to be managed by puppet on ${facts['os']['family']} as it is included in mysql package by default.") } if $python_enable { include 'mysql::bindings::python' } - if $ruby_enable { fail("::mysql::bindings::ruby cannot be managed by puppet on ${::facts['os']['family']} as it is not in official repositories. Please disable ruby mysql binding.") } + if $ruby_enable { fail("::mysql::bindings::ruby cannot be managed by puppet on ${facts['os']['family']} as it is not in official repositories. Please disable ruby mysql binding.") } } default: { diff --git a/manifests/client.pp b/manifests/client.pp index 402d30e9e..f888e0e9a 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -18,15 +18,19 @@ # Whether to manage the MySQL client package. Defaults to `true`. # @param package_name # The name of the MySQL client package to install. +# @param package_provider +# Specify the provider of the package. Optional. Valid value is a String. +# @param package_source +# Specify the path to the package source. Optional. Valid value is a String # class mysql::client ( - $bindings_enable = $mysql::params::bindings_enable, - $install_options = undef, - $package_ensure = $mysql::params::client_package_ensure, - $package_manage = $mysql::params::client_package_manage, - $package_name = $mysql::params::client_package_name, - $package_provider = undef, - $package_source = undef, + Boolean $bindings_enable = $mysql::params::bindings_enable, + Optional[Array[String[1]]] $install_options = undef, + Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $package_ensure = $mysql::params::client_package_ensure, + Boolean $package_manage = $mysql::params::client_package_manage, + String[1] $package_name = $mysql::params::client_package_name, + Optional[String[1]] $package_provider = undef, + Optional[String[1]] $package_source = undef, ) inherits mysql::params { include 'mysql::client::install' diff --git a/manifests/db.pp b/manifests/db.pp index 09a48f41d..034f3247b 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -43,23 +43,25 @@ # Timeout, in seconds, for loading the sqlfiles. Defaults to 300. # @param import_cat_cmd # Command to read the sqlfile for importing the database. Useful for compressed sqlfiles. For example, you can use 'zcat' for .gz files. +# @param mysql_exec_path +# Specify the path in which mysql has been installed if done in the non-standard bin/sbin path. # define mysql::db ( - $user, - Variant[String, Sensitive[String]] $password, - $tls_options = undef, - String $dbname = $name, - $charset = 'utf8', - $collate = 'utf8_general_ci', - $host = 'localhost', - $grant = 'ALL', - $grant_options = undef, - Optional[Array] $sql = undef, - $enforce_sql = false, - Enum['absent', 'present'] $ensure = 'present', - $import_timeout = 300, - Enum['cat', 'zcat', 'bzcat'] $import_cat_cmd = 'cat', - $mysql_exec_path = undef, + String[1] $user, + Variant[String, Sensitive[String]] $password, + Optional[Array[String[1]]] $tls_options = undef, + String $dbname = $name, + String[1] $charset = 'utf8', + String[1] $collate = 'utf8_general_ci', + String[1] $host = 'localhost', + Variant[String[1], Array[String[1]]] $grant = 'ALL', + Optional[Variant[String[1], Array[String[1]]]] $grant_options = undef, + Optional[Array] $sql = undef, + Boolean $enforce_sql = false, + Enum['absent', 'present'] $ensure = 'present', + Integer $import_timeout = 300, + Enum['cat', 'zcat', 'bzcat'] $import_cat_cmd = 'cat', + Optional[String] $mysql_exec_path = undef, ) { include 'mysql::client' @@ -124,7 +126,7 @@ exec { "${dbname}-import": command => "${import_cat_cmd} ${shell_join($sql)} | mysql ${dbname}", logoutput => true, - environment => "HOME=${::root_home}", + environment => "HOME=${facts['root_home']}", refreshonly => ! $enforce_sql, path => "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:${_mysql_exec_path}", require => Mysql_grant["${user}@${host}/${table}"], diff --git a/manifests/params.pp b/manifests/params.pp index 4d5137533..9f3b22179 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -37,11 +37,11 @@ $daemon_dev_package_ensure = 'present' $daemon_dev_package_provider = undef - case $::osfamily { + case $facts['os']['family'] { 'RedHat': { - case $::operatingsystem { + case $facts['os']['name'] { 'Fedora': { - if versioncmp($::operatingsystemrelease, '19') >= 0 or $::operatingsystemrelease == 'Rawhide' { + if versioncmp($facts['os']['release']['full'], '19') >= 0 or $facts['os']['release']['full'] == 'Rawhide' { $provider = 'mariadb' } else { $provider = 'mysql' @@ -49,23 +49,23 @@ $python_package_name = 'MySQL-python' } 'Amazon': { - if versioncmp($::operatingsystemrelease, '2') >= 0 { + if versioncmp($facts['os']['release']['full'], '2') >= 0 { $provider = 'mariadb' } else { $provider = 'mysql' } } /^(RedHat|Rocky|CentOS|Scientific|OracleLinux|AlmaLinux)$/: { - if versioncmp($::operatingsystemmajrelease, '7') >= 0 { + if versioncmp($facts['os']['release']['major'], '7') >= 0 { $provider = 'mariadb' - if versioncmp($::operatingsystemmajrelease, '8') >= 0 { + if versioncmp($facts['os']['release']['major'], '8') >= 0 { $xtrabackup_package_name = 'percona-xtrabackup-24' } } else { $provider = 'mysql' $xtrabackup_package_name = 'percona-xtrabackup-20' } - if versioncmp($::operatingsystemmajrelease, '8') >= 0 { + if versioncmp($facts['os']['release']['major'], '8') >= 0 { $java_package_name = 'mariadb-java-client' $python_package_name = 'python3-PyMySQL' } else { @@ -119,7 +119,7 @@ } 'Suse': { - case $::operatingsystem { + case $facts['os']['name'] { 'OpenSuSE': { $socket = '/var/run/mysql/mysql.sock' $log_error = '/var/log/mysql/mysqld.log' @@ -141,7 +141,7 @@ $basedir = undef } default: { - fail("Unsupported platform: puppetlabs-${module_name} currently doesn\'t support ${::operatingsystem}.") + fail("Unsupported platform: puppetlabs-${module_name} currently doesn\'t support ${facts['os']['name']}.") } } $config_file = '/etc/my.cnf' @@ -207,26 +207,26 @@ $managed_dirs = ['tmpdir','basedir','datadir','innodb_data_home_dir','innodb_log_group_home_dir','innodb_undo_directory','innodb_tmpdir'] # mysql::bindings - if ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '10') >= 0) or - ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '20.04') >= 0) { + if ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'], '10') >= 0) or + ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '20.04') >= 0) { $java_package_name = 'libmariadb-java' } else { $java_package_name = 'libmysql-java' } $perl_package_name = 'libdbd-mysql-perl' - if ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '16.04') >= 0) or - ($::operatingsystem == 'Debian') { + if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16.04') >= 0) or + ($facts['os']['name'] == 'Debian') { $php_package_name = 'php-mysql' } else { $php_package_name = 'php5-mysql' } - if ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '16.04') < 0) or - ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '20.04') >= 0) or - ($::operatingsystem == 'Debian') { + if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16.04') < 0) or + ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '20.04') >= 0) or + ($facts['os']['name'] == 'Debian') { $xtrabackup_package_name = 'percona-xtrabackup-24' } - if ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '20.04') >= 0) or - ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '11') >= 0) { + if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '20.04') >= 0) or + ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'], '11') >= 0) { $python_package_name = 'python3-mysqldb' } else { $python_package_name = 'python-mysqldb' @@ -340,7 +340,7 @@ $config_file = '/etc/my.cnf' $includedir = undef $datadir = '/var/mysql' - $log_error = "/var/mysql/${::hostname}.err" + $log_error = "/var/mysql/${facts['networking']['hostname']}.err" $pidfile = '/var/mysql/mysql.pid' $root_group = 'wheel' $mysql_group = '_mysql' @@ -365,7 +365,7 @@ } default: { - case $::operatingsystem { + case $facts['os']['name'] { 'Alpine': { $client_package_name = 'mariadb-client' $server_package_name = 'mariadb' @@ -425,13 +425,13 @@ } default: { - fail("Unsupported platform: puppetlabs-${module_name} currently doesn\'t support ${::osfamily} or ${::operatingsystem}.") + fail("Unsupported platform: puppetlabs-${module_name} currently doesn\'t support ${facts['os']['family']} or ${facts['os']['name']}.") } } } } - case $::operatingsystem { + case $facts['os']['name'] { 'Ubuntu': { $server_service_provider = 'systemd' } @@ -516,7 +516,7 @@ } ## Additional graceful failures - if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '4' and $::operatingsystem != 'Amazon' { + if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '4' and $facts['os']['name'] != 'Amazon' { fail("Unsupported platform: puppetlabs-${module_name} only supports RedHat 6.0 and beyond.") } } diff --git a/manifests/server.pp b/manifests/server.pp index be98a5914..7f9d7d7f8 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -20,7 +20,8 @@ # @param manage_config_file # Whether the MySQL configuration file should be managed. Valid values are `true`, `false`. Defaults to `true`. # @param options -# A hash of options structured like the override_options, but not merged with the default options. Use this if you don't want your options merged with the default options. +# A hash of options structured like the override_options, but not merged with the default options. +# Use this if you don't want your options merged with the default options. # @param override_options # Specifies override options to pass into MySQL. Structured like a hash in the my.cnf file: See above for usage details. # @param package_ensure @@ -41,6 +42,8 @@ # Whether the service should be restarted when things change. Valid values are `true`, `false`. Defaults to `false`. # @param root_group # The name of the group used for root. Can be a group name or a group ID. See more about the [group](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-group). +# @param managed_dirs +# An array containing all directories to be managed. # @param mysql_group # The name of the group of the MySQL daemon user. Can be a group name or a group ID. See more about the [group](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-group). # @param mycnf_owner @@ -48,7 +51,11 @@ # @param mycnf_group # Name or group-id which owns the mysql-config-file. # @param root_password -# The MySQL root password. Puppet attempts to set the root password and update `/root/.my.cnf` with it. This is required if `create_root_user` or `create_root_my_cnf` are true. If `root_password` is 'UNSET', then `create_root_user` and `create_root_my_cnf` are assumed to be false --- that is, the MySQL root user and `/root/.my.cnf` are not created. Password changes are supported; however, the old password must be set in `/root/.my.cnf`. Effectively, Puppet uses the old password, configured in `/root/my.cnf`, to set the new password in MySQL, and then updates `/root/.my.cnf` with the new password. +# The MySQL root password. Puppet attempts to set the root password and update `/root/.my.cnf` with it. This is required +# if `create_root_user` or `create_root_my_cnf` are true. If `root_password` is 'UNSET', then `create_root_user` and +# `create_root_my_cnf` are assumed to be false --- that is, the MySQL root user and `/root/.my.cnf` are not created. +# Password changes are supported; however, the old password must be set in `/root/.my.cnf`. Effectively, Puppet uses the old +# password, configured in `/root/my.cnf`, to set the new password in MySQL, and then updates `/root/.my.cnf` with the new password. # @param service_enabled # Specifies whether the service should be enabled. Valid values are `true`, `false`. Defaults to `true`. # @param service_manage @@ -58,9 +65,17 @@ # @param service_provider # The provider to use to manage the service. For Ubuntu, defaults to 'upstart'; otherwise, default is undefined. # @param create_root_user -# Whether root user should be created. Valid values are `true`, `false`. Defaults to `true`. This is useful for a cluster setup with Galera. The root user has to be created only once. You can set this parameter true on one node and set it to false on the remaining nodes. +# Whether root user should be created. Valid values are `true`, `false`. Defaults to `true`. +# This is useful for a cluster setup with Galera. The root user has to be created only once. +# You can set this parameter true on one node and set it to false on the remaining nodes. # @param create_root_my_cnf -# Whether to create `/root/.my.cnf`. Valid values are `true`, `false`. Defaults to `true`. `create_root_my_cnf` allows creation of `/root/.my.cnf` independently of `create_root_user`. You can use this for a cluster setup with Galera where you want `/root/.my.cnf` to exist on all nodes. +# Whether to create `/root/.my.cnf`. Valid values are `true`, `false`. Defaults to `true`. +# `create_root_my_cnf` allows creation of `/root/.my.cnf` independently of `create_root_user`. +# You can use this for a cluster setup with Galera where you want `/root/.my.cnf` to exist on all nodes. +# @param create_root_login_file +# Whether to create a login file for root. Valid values are 'true', 'false'. +# @param login_file +# Specify the login file. # @param users # Optional hash of users to create, which are passed to [mysql_user](#mysql_user). # @param grants @@ -72,45 +87,46 @@ # @param manage_service # _Deprecated_ # @param old_root_password -# This parameter no longer does anything. It exists only for backwards compatibility. See the `root_password` parameter above for details on changing the root password. +# This parameter no longer does anything. It exists only for backwards compatibility. +# See the `root_password` parameter above for details on changing the root password. # class mysql::server ( - $config_file = $mysql::params::config_file, - $config_file_mode = $mysql::params::config_file_mode, - $includedir = $mysql::params::includedir, - $install_options = undef, - $manage_config_file = $mysql::params::manage_config_file, - Mysql::Options $options = {}, - $override_options = {}, - $package_ensure = $mysql::params::server_package_ensure, - $package_manage = $mysql::params::server_package_manage, - $package_name = $mysql::params::server_package_name, - $package_provider = undef, - $package_source = undef, - $purge_conf_dir = $mysql::params::purge_conf_dir, - $remove_default_accounts = false, - $restart = $mysql::params::restart, - $root_group = $mysql::params::root_group, - $managed_dirs = $mysql::params::managed_dirs, - $mysql_group = $mysql::params::mysql_group, - $mycnf_owner = $mysql::params::mycnf_owner, - $mycnf_group = $mysql::params::mycnf_group, - Variant[String, Sensitive[String]] $root_password = $mysql::params::root_password, - $service_enabled = $mysql::params::server_service_enabled, - $service_manage = $mysql::params::server_service_manage, - $service_name = $mysql::params::server_service_name, - $service_provider = $mysql::params::server_service_provider, - $create_root_user = $mysql::params::create_root_user, - $create_root_my_cnf = $mysql::params::create_root_my_cnf, - $create_root_login_file = $mysql::params::create_root_login_file, - $login_file = $mysql::params::login_file, - $users = {}, - $grants = {}, - $databases = {}, + String[1] $config_file = $mysql::params::config_file, + String[1] $config_file_mode = $mysql::params::config_file_mode, + Optional[String] $includedir = $mysql::params::includedir, + Optional[Array[String[1]]] $install_options = undef, + Variant[Boolean, String[1]] $manage_config_file = $mysql::params::manage_config_file, + Mysql::Options $options = {}, + Hash $override_options = {}, + Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $package_ensure = $mysql::params::server_package_ensure, + Boolean $package_manage = $mysql::params::server_package_manage, + String[1] $package_name = $mysql::params::server_package_name, + Optional[String[1]] $package_provider = undef, + Optional[String[1]] $package_source = undef, + Variant[Boolean, String[1]] $purge_conf_dir = $mysql::params::purge_conf_dir, + Variant[Boolean, String[1]] $remove_default_accounts = false, + Variant[Boolean, String[1]] $restart = $mysql::params::restart, + String[1] $root_group = $mysql::params::root_group, + Optional[Array[String[1]]] $managed_dirs = $mysql::params::managed_dirs, + String[1] $mysql_group = $mysql::params::mysql_group, + Optional[String[1]] $mycnf_owner = $mysql::params::mycnf_owner, + Optional[String[1]] $mycnf_group = $mysql::params::mycnf_group, + Variant[String, Sensitive[String]] $root_password = $mysql::params::root_password, + Variant[Boolean, String[1]] $service_enabled = $mysql::params::server_service_enabled, + Variant[Boolean, String[1]] $service_manage = $mysql::params::server_service_manage, + String[1] $service_name = $mysql::params::server_service_name, + Optional[String[1]] $service_provider = $mysql::params::server_service_provider, + Boolean $create_root_user = $mysql::params::create_root_user, + Boolean $create_root_my_cnf = $mysql::params::create_root_my_cnf, + Boolean $create_root_login_file = $mysql::params::create_root_login_file, + Optional[String[1]] $login_file = $mysql::params::login_file, + Hash $users = {}, + Hash $grants = {}, + Hash $databases = {}, # Deprecated parameters - $enabled = undef, - $manage_service = undef, - $old_root_password = undef + Optional[Variant[String[1], Boolean]] $enabled = undef, + Optional[Variant[String[1], Boolean]] $manage_service = undef, + Optional[Variant[String, Sensitive[String]]] $old_root_password = undef ) inherits mysql::params { # Deprecated parameters. if $enabled { diff --git a/manifests/server/account_security.pp b/manifests/server/account_security.pp index c054e543b..a6ccfc167 100644 --- a/manifests/server/account_security.pp +++ b/manifests/server/account_security.pp @@ -12,7 +12,7 @@ ensure => 'absent', require => Anchor['mysql::server::end'], } - if ($::fqdn != 'localhost.localdomain') { + if ($facts['networking']['fqdn'] != 'localhost.localdomain') { mysql_user { ['root@localhost.localdomain', '@localhost.localdomain']: @@ -20,17 +20,17 @@ require => Anchor['mysql::server::end'], } } - if ($::fqdn and $::fqdn != 'localhost') { + if ($facts['networking']['fqdn'] and $facts['networking']['fqdn'] != 'localhost') { mysql_user { - ["root@${::fqdn}", - "@${::fqdn}"]: + ["root@${facts['networking']['fqdn']}", + "@${facts['networking']['fqdn']}"]: ensure => 'absent', require => Anchor['mysql::server::end'], } } - if ($::fqdn != $::hostname) { - if ($::hostname != 'localhost') { - mysql_user { ["root@${::hostname}", "@${::hostname}"]: + if ($facts['networking']['fqdn'] != $facts['networking']['hostname']) { + if ($facts['networking']['hostname'] != 'localhost') { + mysql_user { ["root@${facts['networking']['hostname']}", "@${facts['networking']['hostname']}"]: ensure => 'absent', require => Anchor['mysql::server::end'], } diff --git a/manifests/server/backup.pp b/manifests/server/backup.pp index 9aa7d3e56..939418ca7 100644 --- a/manifests/server/backup.pp +++ b/manifests/server/backup.pp @@ -45,7 +45,8 @@ # @param ignore_events # Ignore the mysql.event table. # @param delete_before_dump -# Whether to delete old .sql files before backing up. Setting to true deletes old files before backing up, while setting to false deletes them after backup. +# Whether to delete old .sql files before backing up. +# Setting to true deletes old files before backing up, while setting to false deletes them after backup. # @param backupdatabases # Databases to backup (required if using xtrabackup provider). By default `[]` will back up all databases. # @param file_per_database @@ -62,7 +63,9 @@ # @param prescript # A script that is executed before the backup begins. # @param postscript -# A script that is executed when the backup is finished. This could be used to sync the backup to a central store. This script can be either a single line that is directly executed or a number of lines supplied as an array. It could also be one or more externally managed (executable) files. +# A script that is executed when the backup is finished. This could be used to sync the backup to a central store. +# This script can be either a single line that is directly executed or a number of lines supplied as an array. +# It could also be one or more externally managed (executable) files. # @param execpath # Allows you to set a custom PATH should your MySQL installation be non-standard places. Defaults to `/usr/bin:/usr/sbin:/bin:/sbin`. # @param provider @@ -70,7 +73,8 @@ # @param maxallowedpacket # Defines the maximum SQL statement size for the backup dump script. The default value is 1MB, as this is the default MySQL Server value. # @param optional_args -# Specifies an array of optional arguments which should be passed through to the backup tool. (Supported by the xtrabackup and mysqldump providers.) +# Specifies an array of optional arguments which should be passed through to the backup tool. +# (Supported by the xtrabackup and mysqldump providers.) # @param install_cron # Manage installation of cron package # @param compression_command @@ -83,36 +87,36 @@ # @param excludedatabases # Give a list of excluded databases when using file_per_database, e.g.: [ 'information_schema', 'performance_schema' ] class mysql::server::backup ( - $backupuser = undef, - Optional[Variant[String, Sensitive[String]]] $backuppassword = undef, - $backupdir = undef, - $backupdirmode = '0700', - $backupdirowner = 'root', - $backupdirgroup = $mysql::params::root_group, - $backupcompress = true, - $backuprotate = 30, - $backupmethod = undef, - $backup_success_file_path = '/tmp/mysqlbackup_success', - $ignore_events = true, - $delete_before_dump = false, - $backupdatabases = [], - $file_per_database = false, - $include_routines = false, - $include_triggers = false, - $ensure = 'present', - $time = ['23', '5'], - $prescript = false, - $postscript = false, - $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', - $provider = 'mysqldump', - $maxallowedpacket = '1M', - $optional_args = [], - $incremental_backups = true, - $install_cron = true, - $compression_command = undef, - $compression_extension = undef, - $backupmethod_package = $mysql::params::xtrabackup_package_name, - Array[String] $excludedatabases = [], + Optional[String[1]] $backupuser = undef, + Optional[Variant[String, Sensitive[String]]] $backuppassword = undef, + Optional[String[1]] $backupdir = undef, + String[1] $backupdirmode = '0700', + String[1] $backupdirowner = 'root', + String[1] $backupdirgroup = $mysql::params::root_group, + Boolean $backupcompress = true, + Variant[String[1], Integer] $backuprotate = 30, + Optional[String[1]] $backupmethod = undef, + String[1] $backup_success_file_path = '/tmp/mysqlbackup_success', + Boolean $ignore_events = true, + Boolean $delete_before_dump = false, + Array[String[1]] $backupdatabases = [], + Boolean $file_per_database = false, + Boolean $include_routines = false, + Boolean $include_triggers = false, + Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $ensure = 'present', + Variant[Array[String[1]], Array[Integer]] $time = ['23', '5'], + Variant[Boolean, String[1], Array[String[1]]] $prescript = false, + Variant[Boolean, String[1], Array[String[1]]] $postscript = false, + String[1] $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', + Enum['xtrabackup', 'mysqldump', 'mysqlbackup'] $provider = 'mysqldump', + String[1] $maxallowedpacket = '1M', + Array[String[1]] $optional_args = [], + Boolean $incremental_backups = true, + Boolean $install_cron = true, + Optional[String[1]] $compression_command = undef, + Optional[String[1]] $compression_extension = undef, + String[1] $backupmethod_package = $mysql::params::xtrabackup_package_name, + Array[String] $excludedatabases = [], ) inherits mysql::params { if $prescript and $provider =~ /(mysqldump|mysqlbackup)/ { warning("The 'prescript' option is not currently implemented for the ${provider} backup provider.") diff --git a/manifests/server/root_password.pp b/manifests/server/root_password.pp index d5facf88f..02f5ef2af 100644 --- a/manifests/server/root_password.pp +++ b/manifests/server/root_password.pp @@ -39,23 +39,23 @@ if $mysql::server::create_root_my_cnf and $root_password_set { # TODO: use EPP instead of ERB, as EPP can handle Data of Type Sensitive without further ado - file { "${::root_home}/.my.cnf": + file { "${facts['root_home']}/.my.cnf": content => template('mysql/my.cnf.pass.erb'), owner => 'root', mode => '0600', } # show_diff was added with puppet 3.0 - if versioncmp($::puppetversion, '3.0') >= 0 { - File["${::root_home}/.my.cnf"] { show_diff => false } + if versioncmp($facts['puppetversion'], '3.0') >= 0 { + File["${facts['root_home']}/.my.cnf"] { show_diff => false } } if $mysql::server::create_root_user { - Mysql_user['root@localhost'] -> File["${::root_home}/.my.cnf"] + Mysql_user['root@localhost'] -> File["${facts['root_home']}/.my.cnf"] } } if $mysql::server::create_root_login_file and $root_password_set { - file { "${::root_home}/.mylogin.cnf": + file { "${facts['root_home']}/.mylogin.cnf": source => $login_file, owner => 'root', mode => '0600', diff --git a/readmes/README_ja_JP.md b/readmes/README_ja_JP.md index 99d9bd555..21c54bc27 100644 --- a/readmes/README_ja_JP.md +++ b/readmes/README_ja_JP.md @@ -107,11 +107,11 @@ mysql::db { 'mydb': エクスポートされたリソースを含む別のリソース名を使用するには、次のようにします。 ```puppet - @@mysql::db { "mydb_${fqdn}": + @@mysql::db { "mydb_${facts['networking']['fqdn']}": user => 'myuser', password => 'mypass', dbname => 'mydb', - host => ${fqdn}, + host => ${facts['networking']['fqdn']}, grant => ['SELECT', 'UPDATE'], tag => $domain, } diff --git a/spec/acceptance/05_mysql_xtrabackup_spec.rb b/spec/acceptance/05_mysql_xtrabackup_spec.rb index 216e8cbb0..1d6d6cef0 100644 --- a/spec/acceptance/05_mysql_xtrabackup_spec.rb +++ b/spec/acceptance/05_mysql_xtrabackup_spec.rb @@ -40,7 +40,7 @@ class { 'mysql::server': root_password => 'password' } /RedHat/: { # RHEL/CentOS 5 is no longer supported by Percona, but older versions # of the repository are still available. - if versioncmp($::operatingsystemmajrelease, '6') >= 0 { + if versioncmp($facts['os']['release']['major'], '6') >= 0 { $percona_url = 'http://repo.percona.com/yum/percona-release-latest.noarch.rpm' $epel_url = "https://download.fedoraproject.org/pub/epel/epel-release-latest-${facts['os']['release']['major']}.noarch.rpm" } else { diff --git a/spec/classes/graceful_failures_spec.rb b/spec/classes/graceful_failures_spec.rb index 6380e0052..4b68868d4 100644 --- a/spec/classes/graceful_failures_spec.rb +++ b/spec/classes/graceful_failures_spec.rb @@ -6,8 +6,8 @@ context 'on an unsupported OS' do let(:facts) do { - osfamily: 'UNSUPPORTED', - operatingsystem: 'UNSUPPORTED', + os: { family: 'UNSUPPORTED', + name: 'UNSUPPORTED' }, } end diff --git a/spec/classes/mysql_backup_xtrabackup_spec.rb b/spec/classes/mysql_backup_xtrabackup_spec.rb index 914687523..70ac710cf 100644 --- a/spec/classes/mysql_backup_xtrabackup_spec.rb +++ b/spec/classes/mysql_backup_xtrabackup_spec.rb @@ -37,25 +37,25 @@ class { 'mysql::server': } ) end - package = if facts[:osfamily] == 'RedHat' - if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '8') >= 0 + package = if facts[:os]['family'] == 'RedHat' + if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '8') >= 0 'percona-xtrabackup-24' - elsif Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '7') >= 0 + elsif Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '7') >= 0 'percona-xtrabackup' else 'percona-xtrabackup-20' end - elsif facts[:operatingsystem] == 'Debian' + elsif facts[:os]['name'] == 'Debian' 'percona-xtrabackup-24' - elsif facts[:operatingsystem] == 'Ubuntu' - if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '20') >= 0 + elsif facts[:os]['name'] == 'Ubuntu' + if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '20') >= 0 'percona-xtrabackup-24' - elsif Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '16') >= 0 + elsif Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '16') >= 0 'percona-xtrabackup' else 'percona-xtrabackup-24' end - elsif facts[:osfamily] == 'Suse' + elsif facts[:os]['family'] == 'Suse' 'xtrabackup' else 'percona-xtrabackup' @@ -75,7 +75,7 @@ class { 'mysql::server': } end it 'contains the daily cronjob for weekdays 1-6' do - dateformat = case facts[:osfamily] + dateformat = case facts[:os]['name'] when 'FreeBSD', 'OpenBSD' '$(date -v-sun +\%F)_full' else @@ -114,8 +114,8 @@ class { 'mysql::server': } user: 'backupuser@localhost', table: '*.*', privileges: - if (facts[:operatingsystem] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '11') >= 0) || - (facts[:operatingsystem] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '22') >= 0) + if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '11') >= 0) || + (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22') >= 0) ['BINLOG MONITOR', 'RELOAD', 'PROCESS', 'LOCK TABLES'] else ['RELOAD', 'PROCESS', 'LOCK TABLES', 'REPLICATION CLIENT'] @@ -157,8 +157,8 @@ class { 'mysql::server': } user: 'backupuser@localhost', table: '*.*', privileges: - if (facts[:operatingsystem] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '11') >= 0) || - (facts[:operatingsystem] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '22') >= 0) + if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '11') >= 0) || + (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22') >= 0) ['BINLOG MONITOR', 'RELOAD', 'PROCESS', 'LOCK TABLES', 'BACKUP_ADMIN'] else ['RELOAD', 'PROCESS', 'LOCK TABLES', 'REPLICATION CLIENT', 'BACKUP_ADMIN'] @@ -193,31 +193,31 @@ class { 'mysql::server': } { additional_cron_args: '--backup --skip-ssl' }.merge(default_params) end - package = if facts[:osfamily] == 'RedHat' - if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '8') >= 0 + package = if facts[:os]['family'] == 'RedHat' + if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '8') >= 0 'percona-xtrabackup-24' - elsif Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '7') >= 0 + elsif Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '7') >= 0 'percona-xtrabackup' else 'percona-xtrabackup-20' end - elsif facts[:operatingsystem] == 'Debian' + elsif facts[:os]['name'] == 'Debian' 'percona-xtrabackup-24' - elsif facts[:operatingsystem] == 'Ubuntu' - if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '20') >= 0 + elsif facts[:os]['name'] == 'Ubuntu' + if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '20') >= 0 'percona-xtrabackup-24' - elsif Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '16') >= 0 + elsif Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '16') >= 0 'percona-xtrabackup' else 'percona-xtrabackup-24' end - elsif facts[:osfamily] == 'Suse' + elsif facts[:os]['family'] == 'Suse' 'xtrabackup' else 'percona-xtrabackup' end - dateformat = case facts[:osfamily] + dateformat = case facts[:os]['family'] when 'FreeBSD', 'OpenBSD' '$(date -v-sun +\%F)_full' else diff --git a/spec/classes/mysql_bindings_spec.rb b/spec/classes/mysql_bindings_spec.rb index ba0dc26ee..4b76554cd 100644 --- a/spec/classes/mysql_bindings_spec.rb +++ b/spec/classes/mysql_bindings_spec.rb @@ -4,7 +4,7 @@ describe 'mysql::bindings' do on_supported_os.each do |os, facts| - next if facts[:osfamily] == 'Archlinux' + next if facts[:os]['family'] == 'Archlinux' context "on #{os}" do let(:facts) do facts.merge(root_home: '/root') diff --git a/spec/classes/mysql_server_account_security_spec.rb b/spec/classes/mysql_server_account_security_spec.rb index 3750f5c2a..dc137d537 100644 --- a/spec/classes/mysql_server_account_security_spec.rb +++ b/spec/classes/mysql_server_account_security_spec.rb @@ -14,8 +14,10 @@ context 'with fqdn==myhost.mydomain' do let(:facts) do facts.merge(root_home: '/root', - fqdn: 'myhost.mydomain', - hostname: 'myhost') + networking: { + fqdn: 'myhost.mydomain', + hostname: 'myhost' + }) end ['root@myhost.mydomain', @@ -46,8 +48,10 @@ context 'with fqdn==localhost' do let(:facts) do facts.merge(root_home: '/root', - fqdn: 'localhost', - hostname: 'localhost') + networking: { + fqdn: 'localhost', + hostname: 'localhost' + }) end ['root@127.0.0.1', @@ -65,8 +69,10 @@ context 'with fqdn==localhost.localdomain' do let(:facts) do facts.merge(root_home: '/root', - fqdn: 'localhost.localdomain', - hostname: 'localhost') + networking: { + fqdn: 'localhost.localdomain', + hostname: 'localhost' + }) end ['root@127.0.0.1',