Skip to content

Commit 08a16b2

Browse files
committed
(CONT-359) Syntax update
Code now compliant with rules regarding: legacy facts
1 parent 8c5ba7b commit 08a16b2

14 files changed

+58
-55
lines changed

.puppet-lint.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
--relative
22
--no-parameter_types-check
33
--no-parameter_documentation-check
4-
--no-legacy_facts-check
54
--no-top_scope_facts-check
65
--no-anchor_resource-check
76
--no-relative_classname_reference-check

.sync.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Rakefile:
3838
extra_disabled_lint_checks:
3939
- parameter_types
4040
- parameter_documentation
41-
- legacy_facts
4241
- top_scope_facts
4342
- anchor_resource
4443
- relative_classname_reference

Rakefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ end
4444
PuppetLint.configuration.send('disable_relative')
4545
PuppetLint.configuration.send('disable_parameter_types')
4646
PuppetLint.configuration.send('disable_parameter_documentation')
47-
PuppetLint.configuration.send('disable_legacy_facts')
4847
PuppetLint.configuration.send('disable_top_scope_facts')
4948
PuppetLint.configuration.send('disable_anchor_resource')
5049
PuppetLint.configuration.send('disable_relative_classname_reference')

examples/mysql_db.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
host => 'localhost',
88
grant => ['SELECT', 'UPDATE'],
99
}
10-
mysql::db { "mydb_${fqdn}":
10+
mysql::db { "mydb_${facts['networking']['fqdn']}":
1111
user => 'myuser',
1212
password => 'mypass',
1313
dbname => 'mydb',
14-
host => $::fqdn,
14+
host => $facts['networking']['fqdn'],
1515
grant => ['SELECT', 'UPDATE'],
1616
tag => $domain,
1717
}

examples/mysql_login_path.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
include apt
33
apt::source { 'repo.mysql.com':
44
location => 'http://repo.mysql.com/apt/debian',
5-
release => $::lsbdistcodename,
5+
release => $facts['os']['distro']['codename'],
66
repos => 'mysql-8.0',
77
key => {
88
id => 'A4A9406876FCBD3C456770C88C718D3B5072E1F5',

examples/mysql_plugin.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
root_password => 'password',
33
}
44

5-
$validate_password_soname = $::osfamily ? {
5+
$validate_password_soname = $facts['os']['family'] ? {
66
'windows' => 'validate_password.dll',
77
default => 'validate_password.so'
88
}
@@ -12,7 +12,7 @@
1212
soname => $validate_password_soname,
1313
}
1414

15-
$auth_socket_soname = $::osfamily ? {
15+
$auth_socket_soname = $facts['os']['family'] ? {
1616
'windows' => 'auth_socket.dll',
1717
default => 'auth_socket.so'
1818
}

manifests/backup/mysqlbackup.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@
7474
}
7575

7676
if $install_cron {
77-
if $::osfamily == 'RedHat' {
77+
if $facts['os']['family'] == 'RedHat' {
7878
ensure_packages('cronie')
79-
} elsif $::osfamily != 'FreeBSD' {
79+
} elsif $facts['os']['family'] != 'FreeBSD' {
8080
ensure_packages('cron')
8181
}
8282
}

manifests/backup/mysqldump.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
$backuppassword
4242
}
4343

44-
unless $::osfamily == 'FreeBSD' {
44+
unless $facts['os']['family'] == 'FreeBSD' {
4545
if $backupcompress and $compression_command == 'bzcat -zc' {
4646
ensure_packages(['bzip2'])
4747
Package['bzip2'] -> File['mysqlbackup.sh']
@@ -69,9 +69,9 @@
6969
}
7070

7171
if $install_cron {
72-
if $::osfamily == 'RedHat' {
72+
if $facts['os']['family'] == 'RedHat' {
7373
ensure_packages('cronie')
74-
} elsif $::osfamily != 'FreeBSD' {
74+
} elsif $facts['os']['family'] != 'FreeBSD' {
7575
ensure_packages('cron')
7676
}
7777
}

manifests/backup/xtrabackup.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@
109109
}
110110

111111
if $install_cron {
112-
if $::osfamily == 'RedHat' {
112+
if $facts['os']['family'] == 'RedHat' {
113113
ensure_packages('cronie')
114-
} elsif $::osfamily != 'FreeBSD' {
114+
} elsif $facts['os']['family'] != 'FreeBSD' {
115115
ensure_packages('cron')
116116
}
117117
}
@@ -138,7 +138,7 @@
138138
}
139139

140140
# Wether to use GNU or BSD date format.
141-
case $::osfamily {
141+
case $facts['os']['family'] {
142142
'FreeBSD','OpenBSD': {
143143
$dateformat = '$(date -v-sun +\\%F)_full'
144144
}

manifests/bindings.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
$daemon_dev_package_name = $mysql::params::daemon_dev_package_name,
101101
$daemon_dev_package_provider = $mysql::params::daemon_dev_package_provider
102102
) inherits mysql::params {
103-
case $::osfamily {
103+
case $facts['os']['family'] {
104104
'Archlinux': {
105105
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.") }
106106
if $perl_enable { include 'mysql::bindings::perl' }

manifests/params.pp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,35 @@
3737
$daemon_dev_package_ensure = 'present'
3838
$daemon_dev_package_provider = undef
3939

40-
case $::osfamily {
40+
case $facts['os']['family'] {
4141
'RedHat': {
42-
case $::operatingsystem {
42+
case $facts['os']['name'] {
4343
'Fedora': {
44-
if versioncmp($::operatingsystemrelease, '19') >= 0 or $::operatingsystemrelease == 'Rawhide' {
44+
if versioncmp($facts['os']['release']['full'], '19') >= 0 or $facts['os']['release']['full'] == 'Rawhide' {
4545
$provider = 'mariadb'
4646
} else {
4747
$provider = 'mysql'
4848
}
4949
$python_package_name = 'MySQL-python'
5050
}
5151
'Amazon': {
52-
if versioncmp($::operatingsystemrelease, '2') >= 0 {
52+
if versioncmp($facts['os']['release']['full'], '2') >= 0 {
5353
$provider = 'mariadb'
5454
} else {
5555
$provider = 'mysql'
5656
}
5757
}
5858
/^(RedHat|Rocky|CentOS|Scientific|OracleLinux|AlmaLinux)$/: {
59-
if versioncmp($::operatingsystemmajrelease, '7') >= 0 {
59+
if versioncmp($facts['os']['release']['major'], '7') >= 0 {
6060
$provider = 'mariadb'
61-
if versioncmp($::operatingsystemmajrelease, '8') >= 0 {
61+
if versioncmp($facts['os']['release']['major'], '8') >= 0 {
6262
$xtrabackup_package_name = 'percona-xtrabackup-24'
6363
}
6464
} else {
6565
$provider = 'mysql'
6666
$xtrabackup_package_name = 'percona-xtrabackup-20'
6767
}
68-
if versioncmp($::operatingsystemmajrelease, '8') >= 0 {
68+
if versioncmp($facts['os']['release']['major'], '8') >= 0 {
6969
$java_package_name = 'mariadb-java-client'
7070
$python_package_name = 'python3-PyMySQL'
7171
} else {
@@ -119,7 +119,7 @@
119119
}
120120

121121
'Suse': {
122-
case $::operatingsystem {
122+
case $facts['os']['name'] {
123123
'OpenSuSE': {
124124
$socket = '/var/run/mysql/mysql.sock'
125125
$log_error = '/var/log/mysql/mysqld.log'
@@ -141,7 +141,7 @@
141141
$basedir = undef
142142
}
143143
default: {
144-
fail("Unsupported platform: puppetlabs-${module_name} currently doesn\'t support ${::operatingsystem}.")
144+
fail("Unsupported platform: puppetlabs-${module_name} currently doesn\'t support ${facts['os']['name']}.")
145145
}
146146
}
147147
$config_file = '/etc/my.cnf'
@@ -207,26 +207,26 @@
207207
$managed_dirs = ['tmpdir','basedir','datadir','innodb_data_home_dir','innodb_log_group_home_dir','innodb_undo_directory','innodb_tmpdir']
208208

209209
# mysql::bindings
210-
if ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '10') >= 0) or
211-
($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '20.04') >= 0) {
210+
if ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'], '10') >= 0) or
211+
($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '20.04') >= 0) {
212212
$java_package_name = 'libmariadb-java'
213213
} else {
214214
$java_package_name = 'libmysql-java'
215215
}
216216
$perl_package_name = 'libdbd-mysql-perl'
217-
if ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '16.04') >= 0) or
218-
($::operatingsystem == 'Debian') {
217+
if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16.04') >= 0) or
218+
($facts['os']['name'] == 'Debian') {
219219
$php_package_name = 'php-mysql'
220220
} else {
221221
$php_package_name = 'php5-mysql'
222222
}
223-
if ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '16.04') < 0) or
224-
($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '20.04') >= 0) or
225-
($::operatingsystem == 'Debian') {
223+
if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16.04') < 0) or
224+
($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '20.04') >= 0) or
225+
($facts['os']['name'] == 'Debian') {
226226
$xtrabackup_package_name = 'percona-xtrabackup-24'
227227
}
228-
if ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '20.04') >= 0) or
229-
($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '11') >= 0) {
228+
if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '20.04') >= 0) or
229+
($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'], '11') >= 0) {
230230
$python_package_name = 'python3-mysqldb'
231231
} else {
232232
$python_package_name = 'python-mysqldb'
@@ -340,7 +340,7 @@
340340
$config_file = '/etc/my.cnf'
341341
$includedir = undef
342342
$datadir = '/var/mysql'
343-
$log_error = "/var/mysql/${::hostname}.err"
343+
$log_error = "/var/mysql/${facts['os']['hostname']}.err"
344344
$pidfile = '/var/mysql/mysql.pid'
345345
$root_group = 'wheel'
346346
$mysql_group = '_mysql'
@@ -365,7 +365,7 @@
365365
}
366366

367367
default: {
368-
case $::operatingsystem {
368+
case $facts['os']['name'] {
369369
'Alpine': {
370370
$client_package_name = 'mariadb-client'
371371
$server_package_name = 'mariadb'
@@ -425,13 +425,13 @@
425425
}
426426

427427
default: {
428-
fail("Unsupported platform: puppetlabs-${module_name} currently doesn\'t support ${::osfamily} or ${::operatingsystem}.")
428+
fail("Unsupported platform: puppetlabs-${module_name} currently doesn\'t support ${facts['os']['family']} or ${facts['os']['name']}.")
429429
}
430430
}
431431
}
432432
}
433433

434-
case $::operatingsystem {
434+
case $facts['os']['name'] {
435435
'Ubuntu': {
436436
$server_service_provider = 'systemd'
437437
}
@@ -516,7 +516,7 @@
516516
}
517517

518518
## Additional graceful failures
519-
if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '4' and $::operatingsystem != 'Amazon' {
519+
if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '4' and $facts['os']['name'] != 'Amazon' {
520520
fail("Unsupported platform: puppetlabs-${module_name} only supports RedHat 6.0 and beyond.")
521521
}
522522
}

manifests/server/account_security.pp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@
1212
ensure => 'absent',
1313
require => Anchor['mysql::server::end'],
1414
}
15-
if ($::fqdn != 'localhost.localdomain') {
15+
if ($facts['networking']['fqdn'] != 'localhost.localdomain') {
1616
mysql_user {
1717
['root@localhost.localdomain',
1818
'@localhost.localdomain']:
1919
ensure => 'absent',
2020
require => Anchor['mysql::server::end'],
2121
}
2222
}
23-
if ($::fqdn and $::fqdn != 'localhost') {
23+
if ($facts['networking']['fqdn'] and $facts['networking']['fqdn'] != 'localhost') {
2424
mysql_user {
25-
["root@${::fqdn}",
26-
"@${::fqdn}"]:
25+
["root@${facts['networking']['fqdn']}",
26+
"@${facts['networking']['fqdn']}"]:
2727
ensure => 'absent',
2828
require => Anchor['mysql::server::end'],
2929
}
3030
}
31-
if ($::fqdn != $::hostname) {
32-
if ($::hostname != 'localhost') {
33-
mysql_user { ["root@${::hostname}", "@${::hostname}"]:
31+
if ($facts['networking']['fqdn'] != $facts['networking']['hostname']) {
32+
if ($facts['networking']['hostname'] != 'localhost') {
33+
mysql_user { ["root@${facts['networking']['hostname']}", "@${facts['networking']['hostname']}"]:
3434
ensure => 'absent',
3535
require => Anchor['mysql::server::end'],
3636
}

readmes/README_ja_JP.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ mysql::db { 'mydb':
107107
エクスポートされたリソースを含む別のリソース名を使用するには、次のようにします。
108108

109109
```puppet
110-
@@mysql::db { "mydb_${fqdn}":
110+
@@mysql::db { "mydb_${facts['networking']['fqdn']}":
111111
user => 'myuser',
112112
password => 'mypass',
113113
dbname => 'mydb',
114-
host => ${fqdn},
114+
host => ${facts['networking']['fqdn']},
115115
grant => ['SELECT', 'UPDATE'],
116116
tag => $domain,
117117
}

spec/classes/mysql_server_account_security_spec.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
context 'with fqdn==myhost.mydomain' do
1515
let(:facts) do
1616
facts.merge(root_home: '/root',
17-
fqdn: 'myhost.mydomain',
18-
hostname: 'myhost')
17+
networking: {
18+
fqdn: 'myhost.mydomain',
19+
hostname: 'myhost'
20+
})
1921
end
2022

2123
['root@myhost.mydomain',
@@ -46,8 +48,10 @@
4648
context 'with fqdn==localhost' do
4749
let(:facts) do
4850
facts.merge(root_home: '/root',
49-
fqdn: 'localhost',
50-
hostname: 'localhost')
51+
networking: {
52+
fqdn: 'localhost',
53+
hostname: 'localhost'
54+
})
5155
end
5256

5357
['root@127.0.0.1',
@@ -65,8 +69,10 @@
6569
context 'with fqdn==localhost.localdomain' do
6670
let(:facts) do
6771
facts.merge(root_home: '/root',
68-
fqdn: 'localhost.localdomain',
69-
hostname: 'localhost')
72+
networking: {
73+
fqdn: 'localhost.localdomain',
74+
hostname: 'localhost'
75+
})
7076
end
7177

7278
['root@127.0.0.1',

0 commit comments

Comments
 (0)