Forge Home

hosts

A template-based module to manage /etc/hosts

101,129 downloads

406 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

  • 4.1.0 (latest)
  • 4.0.4
  • 4.0.3
  • 4.0.2
  • 4.0.1
  • 4.0.0
  • 3.2.1
  • 3.2.0
  • 3.1.0
  • 3.0.1
  • 3.0.0
  • 2.4.0
  • 2.3.1
  • 2.3.0
  • 2.2.7
  • 2.2.6
  • 2.2.5
  • 2.2.4
  • 2.2.3
  • 2.2.2
  • 2.2.1
  • 2.2.0
  • 2.1.1
  • 2.1.0
  • 2.0.5
  • 2.0.4
  • 2.0.3
  • 2.0.2
  • 2.0.1
  • 2.0.0
  • 1.0.2
  • 1.0.1 (deleted)
  • 0.1.3 (deleted)
  • 0.1.2 (deleted)
  • 0.1.0 (deleted)
released Feb 8th 2016
This version is compatible with:
  • Puppet Enterprise >= 3.2.0
  • Puppet >= 3.0.0
  • Gentoo, RedHat, Debian, Ubuntu, CentOS, Solaris, SLES, SLED, FreeBSD, Darwin, AIX

Start using this module

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

Add this module to your Puppetfile:

mod 'chrekh-hosts', '2.0.5'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add chrekh-hosts
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install chrekh-hosts --version 2.0.5

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.

Download
Tags: hosts

Documentation

chrekh/hosts — version 2.0.5 Feb 8th 2016

hosts

A template-based module to manage /etc/hosts. The main goal for this module is to add entries for localhost and primary address based on existing ip-adresses on existing interfaces. Tested by me on Gentoo, SLES, RedHat, and OS X. But it should work or any Linux and Unix-like OS.

This module unconditionally overwrites your hosts file. You have been warned! There are two reasons that this is template-based.

1) Currently the default host type don't allow multiple IP for a hostname (not even a IPv4 and a IPv6).

2) I prefer to manage files with puppet exclusively, or not at all.

Usage

class { 'hosts': }

Parameters

file

The file to add host entries to.

  • Default: '/etc/hosts'

lo_ipv4

List of IPv4 addresses for localhost. Empty list means no entry.

  • Default: [ IPv4 loopback addresses ]

lo_ipv6

List of IPv6 addresses for localhost. Empty list means no entry.

  • Default: [ IPv6 loopback addresses ]

lo_names

List of names for localhost.

  • Default: [ 'localhost' ]

primary_ipv4

List of IPv4 addresses. Empty list means no entry.

  • Default: [ IPv4 addresses (not loopback or multicast) ]

primary_ipv6

List of IPv6 addresses. Empty list means no entry.

  • Default: [ IPv6 addresses (not loopback, multicast, or linklocal) ]

primary_names

List of names for primary addresses.

  • Default: [ $::fqdn, $::hostname ]

one_primary_ipv4

If true, only use the first address from primary_ipv4

  • Default: true

one_primary_ipv6

If true, only use the first address from primary_ipv6

  • Default: true

entries

A hash with additional host entries to add.

  • Default: {}

Example

class { 'hosts':
    one_primary_ipv4 => false, 
    one_primary_ipv6 => false,
    entries => { '192.168.2.1' => [ 'foo.bar.org', 'foo' ] }
}

Hiera example

hosts::one_primary_ipv4: false
hosts::one_primary_ipv6: false
hosts::entries:
  '::2':
    - 'localhost2'
  '2001:db8:abba::1':
    - 'foo.bar.org'
    - 'foo'