Forge Home


Module for managing nsswitch.conf


13,498 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 2.3.0 (latest)
  • 2.2.0
  • 2.1.1
  • 2.1.0
  • 2.0.0
  • 1.3.0
  • 1.2.0
  • 1.1.0
  • 1.0.0
  • 0.1.0
  • 0.0.8
  • 0.0.7
  • 0.0.6
  • 0.0.5
  • 0.0.4
  • 0.0.3
  • 0.0.2
  • 0.0.1
released Jul 15th 2022
This version is compatible with:
  • Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >= 4.0.0 < 8.0.0
  • , , , , , , , , , , , , Gentoo, , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'trlinkin-nsswitch', '2.3.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add trlinkin-nsswitch
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install trlinkin-nsswitch --version 2.3.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.



trlinkin/nsswitch — version 2.3.0 Jul 15th 2022

nsswitch.conf module for Puppet

Build Status

A way of expressing nsswitch.conf configurations declaratively. This should manage the standard 15 databases NSS supports, plus the sudo entry respected by sudo since the 1.7.0 release.

Updated for Puppet 4 - No Puppet 3 Compatibility

The 2.x series of this module officially adopts the Puppet 4 parser syntax and other new Puppet features. The 2.x series will no longer work with Puppet 3 or earlier. One benefit is the removal of dependency the trlinkin-validate_multi module.


Currently this module has support for EL based Linux distributions, Fedora, Debian/Ubuntu, and Gentoo. This module by default will create a basic nsswitch.conf that uses defaults derived from what the distribution uses in the nsswitch.conf file on fresh install. These defaults have been verified on the mentioned distributions by the kindness and diligence of contributors, of which I'm very grateful.

Supported Systems

This module should be capable of supporting the following systems using Puppet versions 4 and 5 with the ruby versions that are released with the AIO (all in one installer). For an exact matrix see .travis.yml.

  • Debian/Ubuntu 10.04, 12.04
  • Solaris 10, 11, 11.1, 11.2, 11.3
  • Variants of Enterprise Linux 6 and 7 (Such as Amazon Linux, Scientific Linux, etc)
  • Fedora (defaults need validation)
  • Gentoo
  • FreeBSD 10.3, 10.4, 11.1
  • LinuxMint 17.2
  • SLES 11, 12

Testing has only confirmed functionality on the following:

  • Ubuntu 12.4
  • Fedora 19
  • Centos 6/7
  • RHEL 6/7


See for full API details.

nsswitch class

This is the class by which you will manage the nsswitch.conf file. There is one parameter per standard database NSS supports. The class accepts both strings and arrays as parameters. The benefit being, you could possibly merge an array of options with hiera. When using an array, each element should be the lookup service followed by the reaction statement.

Available parameters are:

  • passwd
  • group
  • shadow
  • hosts
  • bootparams
  • aliases
  • automount
  • ethers
  • netgroup
  • netmasks
  • network
  • protocols
  • publickey
  • rpc
  • services
  • shells
  • sudo

For more information on NSS, please see the man pages. man 5 nsswitch.conf


# defaults only
include nsswitch

# setting a simple lookup
class { 'nsswitch':
  publickey => 'nis',

# 'hosts' lookups contain a reaction statement for the 'dns' service
class { 'nsswitch':
  passwd => ['ldap','files'],
  hosts  => ['dns [!UNAVAIL=return]','files'],

Example nsswitch.conf with all defaults for RHEL systems

# This file is controlled by Puppet

passwd:     files
shadow:     files
group:      files
hosts:      files dns
bootparams: nisplus [NOTFOUND=return] files
ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files
netgroup:   nisplus
publickey:  nisplus
automount:  files nisplus
aliases:    files nisplus