Skip to content

Drop legacy facts #1535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions manifests/backup/mysqlbackup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
Expand Down
6 changes: 3 additions & 3 deletions manifests/backup/mysqldump.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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')
}
}
Expand Down
6 changes: 3 additions & 3 deletions manifests/backup/xtrabackup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
Expand All @@ -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'
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/bindings.pp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
$daemon_dev_package_name = $mysql::params::daemon_dev_package_name,
$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 $perl_enable { include 'mysql::bindings::perl' }
Expand Down
46 changes: 23 additions & 23 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,35 @@
$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'
}
$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 {
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -365,7 +365,7 @@
}

default: {
case $::operatingsystem {
case $facts['os']['name'] {
'Alpine': {
$client_package_name = 'mariadb-client'
$server_package_name = 'mariadb'
Expand Down Expand Up @@ -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'
}
Expand Down Expand Up @@ -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.")
}
}
14 changes: 7 additions & 7 deletions manifests/server/account_security.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@
ensure => 'absent',
require => Anchor['mysql::server::end'],
}
if ($::fqdn != 'localhost.localdomain') {
if ($facts['networking']['fqdn'] != 'localhost.localdomain') {
mysql_user {
['[email protected]',
'@localhost.localdomain']:
ensure => 'absent',
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'],
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/server/root_password.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
}

# show_diff was added with puppet 3.0
if versioncmp($::puppetversion, '3.0') >= 0 {
if versioncmp($facts['puppetversion'], '3.0') >= 0 {
File["${::root_home}/.my.cnf"] { show_diff => false }
}
if $mysql::server::create_root_user {
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/05_mysql_xtrabackup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions spec/classes/graceful_failures_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
context 'on an unsupported OS' do
let(:facts) do
{
osfamily: 'UNSUPPORTED',
operatingsystem: 'UNSUPPORTED',
os: {
family: 'UNSUPPORTED',
name: 'UNSUPPORTED',
},
}
end

Expand Down
28 changes: 14 additions & 14 deletions spec/classes/mysql_backup_xtrabackup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,25 @@ class { 'mysql::server': }
)
end

package = if facts[:osfamily] == 'RedHat'
package = if facts[:os]['family'] == 'RedHat'
if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '8') >= 0
'percona-xtrabackup-24'
elsif Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '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'
elsif facts[:os]['name'] == 'Ubuntu'
if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '20') >= 0
'percona-xtrabackup-24'
elsif Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '16') >= 0
'percona-xtrabackup'
else
'percona-xtrabackup-24'
end
elsif facts[:osfamily] == 'Suse'
elsif facts[:os]['family'] == 'Suse'
'xtrabackup'
else
'percona-xtrabackup'
Expand All @@ -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]['family']
when 'FreeBSD', 'OpenBSD'
'$(date -v-sun +\%F)_full'
else
Expand Down Expand Up @@ -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[:operatingsystemmajrelease], '11') >= 0) ||
(facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '22') >= 0)
['BINLOG MONITOR', 'RELOAD', 'PROCESS', 'LOCK TABLES']
else
['RELOAD', 'PROCESS', 'LOCK TABLES', 'REPLICATION CLIENT']
Expand Down Expand Up @@ -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[:operatingsystemmajrelease], '11') >= 0) ||
(facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '22') >= 0)
['BINLOG MONITOR', 'RELOAD', 'PROCESS', 'LOCK TABLES', 'BACKUP_ADMIN']
else
['RELOAD', 'PROCESS', 'LOCK TABLES', 'REPLICATION CLIENT', 'BACKUP_ADMIN']
Expand Down Expand Up @@ -193,31 +193,31 @@ class { 'mysql::server': }
{ additional_cron_args: '--backup --skip-ssl' }.merge(default_params)
end

package = if facts[:osfamily] == 'RedHat'
package = if facts[:os]['family'] == 'RedHat'
if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '8') >= 0
'percona-xtrabackup-24'
elsif Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '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'
elsif facts[:os]['name'] == 'Ubuntu'
if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '20') >= 0
'percona-xtrabackup-24'
elsif Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '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
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/mysql_bindings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Loading