Puppet 3.5 optionally added structured facts as well as the global facts hash. They were both turned on by default in puppet 4.
This linter will convert from legacy facts like $::operatingsystem
or legacy
hashed facts like $facts['operatingsystem']
to the new structured facts like
$facts['os']['name']
.
If you only want to convert from facts like $::operatingsystem
to the facts
hash like $facts['operatingsystem']
, you want the top scope facts
linter.
$ gem install puppet-lint-legacy_facts-check
gem 'puppet-lint-legacy_facts-check', :require => false
$package_name = $::operatingsystem {
'CentOS' => 'httpd',
'Debian' => 'apache2',
}
$package_name = $facts['operatingsystem'] {
'CentOS' => 'httpd',
'Debian' => 'apache2',
}
$package_name = $facts['os']['name'] {
'CentOS' => 'httpd',
'Debian' => 'apache2',
}
To disable this check, you can add --no-legacy_facts
to your puppet-lint
command line.
$ puppet-lint --no-legacy_facts path/to/file.pp
Alternatively, if you’re calling puppet-lint via the Rake task, you should
insert the following line to your Rakefile
.
PuppetLint.configuration.send('disable_legacy_facts')
Alternatively, you can disable it directly in your puppet manifest.
# lint:ignore:legacy_facts
$package_name = $facts['operatingsystem'] {
'CentOS' => 'httpd',
'Debian' => 'apache2',
}
# lint:endignore
The linter will only find and work on top scope facts like $::osfamily
,
non-top scope facts like $osfamily
will not be found or fixed.
Some facts have no equivalent in the structured fact list:
There is no fact that returns exclusively in MiB.
The closest equivalent is $facts['memory']['system'][available']
or
$facts['memory']['system']['available_bytes']
.
See facter documentation on memory.
There is no fact that returns exclusively in MiB.
The closest equivalent is $facts['memory']['system']['total']
or
$facts['memory']['system']['total_bytes']
.
See facter documentation on memory.
There is no fact that returns exclusively in MiB.
The closest equivalent is $facts['memory']['swap']['available']
or
$facts['memory']['swap']['available_bytes']
.
See facter documentation on memory.
There is no fact that returns exclusively in MiB.
The closest equivalent is $facts['memory']['swap']['used']
or
$facts['memory']['swap']['used_bytes']
.
See facter documentation on memory.
This returns a string containing all block devices separated by a comma.
This can be duplicated using
puppetlabs/stdlib and the
following: join(keys($facts['disks']), ',')
This returns a string containing all interfaces separated by a comma.
This can be duplicated using
puppetlabs/stdlib and the
following: join(keys($facts['networking']['interfaces']), ',')
.
This returns a string containing all zone names separated by a comma.
This can be duplicated using
puppetlabs/stdlib and the
following: join(keys($facts['solaris_zones']['zones']), ',')
This returns a string containing both the SHA1 and SHA256 fingerprint for the DSA algorithm.
This can be duplicated using the following string:
"$facts['ssh']['dsa']['fingerprints']['sha1'] $facts['ssh']['dsa']['fingerprints']['sha256']"
This returns a string containing both the SHA1 and SHA256 fingerprint for the ECDSA algorithm.
This can be duplicated using the following string:
"$facts['ssh']['ecdsa']['fingerprints']['sha1'] $facts['ssh']['ecdsa']['fingerprints']['sha256']"
This returns a string containing both the SHA1 and SHA256 fingerprint for the Ed25519 algorithm.
This can be duplicated using the following string:
"$facts['ssh']['ed25519']['fingerprints']['sha1'] $facts['ssh']['ed25519']['fingerprints']['sha256']"
This returns a string containing both the SHA1 and SHA256 fingerprint for the RSA algorithm.
This can be duplicated using the following string:
"$facts['ssh']['rsa']['fingerprints']['sha1'] $facts['ssh']['rsa']['fingerprints']['sha256']"
Copyright 2016 Mark McKinstry
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.