No release in over 3 years
Low commit activity in last 3 years
There's a lot of open issues
A pupet-lint to check you are not using legacy facts like `$::operatingsystem` or `$facts['operatingsystem']`. You should use the new structured facts like `$facts['os']['name']` instead
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Build Status Gem Total Downloads Latest Downloads

Overview

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.

Installing

From the command line

$ gem install puppet-lint-legacy_facts-check

In a Gemfile

gem 'puppet-lint-legacy_facts-check', :require => false

Checks

What you have done

$package_name = $::operatingsystem {
  'CentOS' => 'httpd',
  'Debian' => 'apache2',
}
$package_name = $facts['operatingsystem'] {
  'CentOS' => 'httpd',
  'Debian' => 'apache2',
}

What you should have done

$package_name = $facts['os']['name'] {
  'CentOS' => 'httpd',
  'Debian' => 'apache2',
}

Disabling the check

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

Limitations

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:

memoryfree_mb

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.

memorysize_mb

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.

swapfree_mb

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.

swapsize_mb

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.

blockdevices

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']), ',')

interfaces

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']), ',').

zones

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']), ',')

sshfp_dsa

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']"

sshfp_ecdsa

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']"

sshfp_ed25519

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']"

sshfp_rsa

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']"

License

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.